Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sensing an empty array
Message
From
18/05/2007 14:45:56
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
18/05/2007 14:16:13
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01226737
Message ID:
01226911
Views:
18
>>>Hi. I am doing an Array of a folder's contents. How do I test for an empty directory?
>>Thanks, Randy
>
>>If you use adir(), check the return value. It will return the number of files found. From help: "If the array exists and ADIR( ) returns 0 because no matching files are found, the array remains unchanged. If the array doesn't exist and ADIR( ) returns 0, the array isn't created."
>
>ADIR() also returns the names of the subdirectories -- so there may not be any files but can have a return >0 due to subdirectories.

In that case, there would be no problem about the empty array, as the question indicates. Looping through the array, the programmer can test whether the object in question is a directory, or not.

Also, directories are only included if the programmer explicitly asks for it, through the third parameter.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform