Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP Tip for Today
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
VFP Tip for Today
Miscellaneous
Thread ID:
00238302
Message ID:
00238302
Views:
63
You learn something new every day, or I did at least.

While working on a function to return an array of values, I noticed a feature I was never aware of until now. I was playing with redefining a variable from character to an array in case a character was passed to a UDF instead of an array. For example:
laFiles = ""   && a character value instead of an array
** next, retrieve all the folders in C:\Windows
lnRetVal = GetFolders(@laFiles, "C:\Windows")
My UDF, GetFolders, redefines laFiles as an array and populates it with all the C:\Windows subfolders.

When I was through, laFiles was a 16x5 array. Then I typed laFiles = "" in the command window. Instead of laFiles being an empty character variable, all the array elements were initialized to a blank character field.

So, instead of leaving all array elements defaulting to a logical false or looping through the entire array to initialize all elements, you can initialize all elements to the same value with 1 command.

I am using VFP 6 SP3, so I would be interested to know if prior versions did this and I am just late in catching on to this.
Mark McCasland
Midlothian, TX USA
Next
Reply
Map
View

Click here to load this message in the networking platform