1. Marcos Bolonha
  2. PowerBuilder
  3. Monday, 28 September 2020 23:12 PM UTC

Hi,

I'm using GetFolder function to get a folder name but the PB is "freezing" when I try to access a folder that has subfolders with thousand of files.

 

string path_source

integer li_rtn 

li_rtn = GetFolder( "Folder", path_source )

 

PB 2019 R2 - Build 2328

Thanks for any help.

Marcos

Olan Knight Accepted Answer Pending Moderation
  1. Thursday, 1 October 2020 23:56 PM UTC
  2. PowerBuilder
  3. # 1

Treeviews & Folders

The issue is the time it takes to read the datastore and create each individual node in a treeview.

The default behavior is to read every single item at the current level +
    every single item at the level below the current one +
            every single item at every level below that level +
                and so on until the data has been read down to the last row.

Meanwhile, all we usually want is to get to the current folder. We usually have no need to go below the level we seek.

That's why I suggested LIMITS be placed on both object creation functions. Both a LEVEL limit and a NODE limit are reasonable and would be very useful.


Olan

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Tuesday, 29 September 2020 23:38 PM UTC
  2. PowerBuilder
  3. # 2

Marcos -

The exact same thing happens when you create a treeview that has many, MANY nodes - it takes forever to build the structure. Once the structure has been created, it will be painted.

One answer is to find a folder with fewer sub-folders, then code your way to the correct folder if the parent folder is the one you want.

In my own code, I've implemented a LIMIT on the treeview creation that stops at a set number, then display a query to the user: "1500 rows have been retrieved. Continue retrieving data? Y/N". If the user says NO then I paint the treeview. You might be able to do something like that.

~~~~~~~~~~~

I definitely think that some kind of LIMIT parameter needs to be on any object that gets, reads, or builds something that is required to wait on fun-units;i.e. sub-nodes or dub-folders. JMHO.


Olan

Comment
  1. Roland Smith
  2. Friday, 2 October 2020 00:56 AM UTC
In a treeview only create the top level. Use the itempopulate event to populate lower nodes as needed.
  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 2 October 2020 02:00 AM UTC
great idea Roland, or a DDLB (visible or not) and using the DirList() function.
  1. Helpful
  1. Olan Knight
  2. Friday, 2 October 2020 13:38 PM UTC
Concur.

I cannot believe I did not think of that.

DOH!

:)
  1. Helpful
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Monday, 28 September 2020 23:17 PM UTC
  2. PowerBuilder
  3. # 3

If you delete the thousands of files and leave just a few files in the same folder on the environment that has the problem, does the problem go away?  Basically, I'm suggesting a troubleshooting step to see if really the problem is the amount of files.

Also, have you tried compiling your app as a 64-bit .EXE and seeing if it has the same problem?

Comment
  1. Chris Pollach @Appeon
  2. Tuesday, 29 September 2020 17:12 PM UTC
Adding on to Armeen's suggestion ... what happens when you compile your PB app into M-Code (machine code) performance wise?
  1. Helpful
  1. Marcos Bolonha
  2. Thursday, 1 October 2020 22:02 PM UTC
Hi Armeen and Chris,



Thanks for replying.



The same problem when compiling as 64-bit and machine code.



I think the problem is related to the time it takes to read and create the folders sctructure, as Olan Knight said in his comments. Maybe the solution will be create a treeview and limit the "node numbers" to be read. Of course it isn't the best way, since we have a GetFolder function, but I really need give to the user a way to select folders with big number of files.



Marcos
  1. Helpful
There are no comments made yet.
Marcos Bolonha Accepted Answer Pending Moderation
  1. Monday, 28 September 2020 23:17 PM UTC
  2. PowerBuilder
  3. # 4

The problem is the network drives. Local folders are working ok.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.