DBSetProp()

Set Path, Set("Path")

This command lets you specify a series of directories that FoxPro should search when you ask for a file. Although it serves the same purpose, it's not connected to the DOS search path.

Usage

SET PATH TO [ ListOfDirectories ] cCurrentPath = SET( "PATH" )
You can have a default path stored in the Registry. Just specify a path and bring up the Tools-Options dialog (or specify the path in the File Locations tab there). Choose Set as Default, and the specified path (along with anything else you've changed) is saved. When you start Visual FoxPro, that path is already set.

As with so many of the SET commands, you can omit the parameter to reset the path. However, it gets reset to empty, not to the stored default. Resetting to the saved path requires you to issue the SYS(3056) function, which resets all the settings stored in the Tools-Options dialog—that's a little severe. Bottom line: Be sure to save the current path before you start fiddling if it's important to you.

The list of directories is a little strange. It's a comma-delimited or semicolon-delimited list—in fact, you can mix the separators. But it's never checked for validity. You can SET PATH TO any sort of garbage at all and FoxPro never blinks.

To make things more complicated, you can use a macro (&) or indirect reference (parens) to set the path to the list of directories contained in a string. But you can't use EVAL()—you get an error message in VFP 5 and VFP 6. (In VFP 3, if you SET PATH TO EVAL(cList), then check SET("PATH"), you'll see that FoxPro took you literally and set the path to "EVAL(cList)"—not quite what you had in mind.)

When you use a macro or indirect reference, you can't put anything that needs to be evaluated in the list. For example, the following:

cList = "C:\WINDOWS,SYS(2004)" SET PATH TO (cList)
results in a path of:

C:\WINDOWS,SYS(2004)
Even using a macro instead of indirect reference has the same result. To get the desired effect, you have to make sure the function is evaluated before you get to the SET PATH line:

cList = "C:\WINDOWS,"+SYS(2004) SET PATH TO (cList)
Unless there's only one directory in the list, you can't include the function call right in the SET PATH line.

To our utter astonishment, SET PATH can handle directories with embedded spaces without having to surround them with quotes. We had no problem SETting PATH TO C:\Program Files (perhaps our least favorite directory ever). It kind of makes sense, since SET PATH doesn't see a space as a delimiter, but it sure is different than the way VFP handles embedded spaces elsewhere.

Example

SET PATH TO C:\WINDOWS, F:\VFP ? SET("PATH")   && Returns "C:\WINDOWS,F:\VFP" * Can use function call for one item SET PATH TO (SYS(2004) + "\DATA") * But the following DOESN'T work as you'd expect SET PATH TO (SYS(2004) + "DATA"), C:\WINDOWS * Do it this way instead cList = (SYS(2004) + "DATA")+", C:\WINDOWS" SET PATH TO (cList)

See Also

ChDir, FullPath(), Set Default, SYS(3056)


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net