Listing files in a directory

Just starting out? Need help? Post your questions and find answers here.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Listing files in a directory

Post by Danilo »

ts-soft wrote:Here another one.
It just crashes when calling without the optional argument:

Code: Select all

BrowseDirectory("C:\")
:twisted:
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Listing files in a directory

Post by ts-soft »

This argument isn't optional, it looks only as :lol:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Re: Listing files in a directory

Post by TerryHough »

@ts-soft
ts-soft wrote:Here another one.
Interesting. Frankly since the manual says Prototypes are for "advanced" programmers I never use them. Maybe I should try to learn more about them. :lol:

But I'm not sure there is any improvement in your approach.

When testing your code here (XP Pro) it averages 10 times longer than my posted routine which builds the tree display. Yours only counts the files while mine builds the tree, so it isn't an "apples to apples" comparison. I expected my code should take longer but it doesn't.

Yours is counting the subfolders multiple times and including them in the file count. The file count is overstated. I think your count increment is misplaced.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Listing files in a directory

Post by ts-soft »

Okay, the result is more to test some files added. CountList(Files()) gives the exactly result.

Have you made the speedtest without debugger? A routine, that fills any gadget can't faster as this routine :wink:

Prototypes not only for advanced programmers. This is required for everyone uses any DLL!
Callfunction... is for bad programmers :mrgreen:

Greetings - Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply