Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
ADDBS()
, DEFAULTEXT()
, FORCEEXT()
, FORCEPATH()
, JUSTDRIVE()
, JUSTEXT()
, JUSTFNAME()
, JUSTPATH()
, JUSTSTEM()
These functions seem much older than their addition to the language in VFP 6 because they’ve existed in FoxTools.FLL (and DOS’s FPATH.PLB) for a long time. Now they’ve been integrated into the native language, reducing the need for FoxTools to be loaded. See the FoxTools section, in the File Functions subsection, for details on calling each of the functions.
If you’re still working with an older version of FoxPro, you won’t miss much by not having these functions. You can load FoxTools, or, if you have access to FoxPro 2.x, you can find many of these functions in code in the GenMenu and GenScrn programs. None of these functions is rocket science; most could be rewritten in an IIF()
statement or two.
A word of caution: Since most modern operating systems support long file names, including periods within the file name, you’ll want to be careful using these functions. They assume that any characters after the first period are part of the file extension.
? ADDBS("fred") && Returns "fred\"
? DEFAULTEXT("c:\test","txt") && "c:\test.txt"
? DEFAULTEXT("c:\test.doc","txt") && "c:\test.doc"
? DEFAULTEXT("c:\test.document","txt") && "c:\test.document"
? FORCEEXT("c:\test.document","txt") && "c:\test.txt"
? FORCEPATH("c:\test.document","c:\temp")
* returns "C:\Temp\test.document"
? FORCEPATH("c:\test.document","xxx") && "xxx\test.document
? JUSTDRIVE("c:\test.document") && "C:"
? DRIVETYPE(JUSTDRIVE("c:\test.document")) && 3 (see DRIVETYPE)
? JUSTEXT("c:\test.document") && "document"
? JUSTFNAME("c:\test.document") && "test.document"
? JUSTPATH("c:\test.document") && "c:\" - note slash
? JUSTPATH("c:\temp\test.document") && "c:\temp" - no slash
? JUSTPATH("c:\Program Files\test.document")
* "c:\Program Files"
? JUSTSTEM("c:\Program Files\test.document") && "test"