FullPath(), Sys(2014)
These two functions let you retrieve file paths. FULLPATH() gives you the complete path to a file while SYS(2014) lets you find a relative path between a file and a directory. Both return spurious information about nonexistent files, so you have to check up on them.
Usage |
cAbsolutePath = FULLPATH( cFileName [, nUseDOSPath | cBaseFile ] ) cRelativePath = SYS( 2014, cFileName [, cBasePath ] ) |
Parameter |
Value |
Meaning |
cFileName |
Character |
The name of the file whose path you want. |
nUseDOSPath |
Numeric |
Look all along the DOS path to find cFileName. |
Omitted |
If cBaseFile is also omitted, look all along the FoxPro path to find cFileName. |
|
cBaseFile |
Character |
Use the location of cBaseFile as the location from which to do relative addressing. |
Omitted |
If nUseDOSPath is also omitted, look all along the FoxPro path to find cFileName. |
|
cBasePath |
Character |
Find the minimum path to cFileName from cBasePath. |
Omitted |
Find the minimum path to cFileName from the default directory. |
Under Win32s, FoxPro gets horribly confused if you omit the third parameter to SYS(2014) and specify an absolute path on the current drive for the file. The path returned includes far too many references to the parent directory. You could climb all the way to the root and then some. Of course, this is a problem only for VFP 3 running under Windows 3.1, since VFP 5 and later don't run in Win32s. |
Both these functions will mislead you if you specify a file that doesn't exist. They return a path to the specified filename and don't bother to tell you it's not really there. With FULLPATH(), you're safe as long as the file exists somewhere on the path (either FoxPro or DOS, depending on the second parameter). SYS(2014) gives back really weird paths, but they amount to pointing to the nonexistent file in the current directory. The bottom line is that you can't count on either of these to make sure the file is there. Check with FILE() before you try to use it. |
Example |
* Assume Visual FoxPro is installed in F:\VFP CD F:\VFP\SAMPLES SET PATH TO TASTRADE, TASTRADE\DATA * Search on FoxPro path ? FULLPATH("TasTrade.DBC") * Returns "F:\VFP\SAMPLES\TASTRADE\DATA\TASTRADE.DBC" * Search DOS path ? FULLPATH("Win.ini",1)&& Returns "C:\WINDOWS\WIN.INI" * You can use FULLPATH() to find the location of a table * in a DBC (which ADBOBJECTS() doesn't give you) OPEN DATA TasTrade ? FULLPATH(DBGETPROP("customer","table","path"),DBC()) * Returns "F:\VFP\SAMPLES\TASTRADE\DATA\CUSTOMER.DBF" SET PATH TO * Use SYS(2014) for relative paths CD F:\VFP\SAMPLES\TASTRADE ? SYS(2014,"\VFP\VFP.EXE",CURDIR()) && Returns "..\..\VFP.EXE" ? SYS(2014,"F:\VFP\TOOLS\FOXTOOLS.CHM", ; "F:\VFP\GALLERY\FAVORITES.DBF") * Returns "..\TOOLS\FOXTOOLS.CHM" * Now here's the absurd case demonstrating the bug in Win32s. * This example gives these results only in VFP 3 under Win3.1 ? SYS(2014,"\VFP\SAMPLES\CONTROLS\CANCEL.BMP") * Returns "..\..\..\..\CONTROLS\CANCEL.BMP" |
See Also |