_ALIGNMENT

CurDir(), Sys(2003), Sys(5)

Where am I? That's the question these three functions answer. CURDIR() and SYS(2003) give you the default directory, while SYS(5) provides the default drive. CURDIR() also can tell you the current directory on other drives.

Usage

cCurrentDirectory = CURDIR( [ cDriveDesignator ] ) cCurrentDirectory = SYS( 2003 )
Without CURDIR()'s optional parameter, the two functions return exactly the same thing. Except that CURDIR() includes the final "\" while SYS(2003) omits it. Go figure.

Pass a drive designator (like "C:") to CURDIR() to find out the current directory on that drive.

This isn't really a bug with CURDIR(), but it's worth pointing out here. When you use CD or SET DEFAULT to change drives, it resets the current directory on the drive you were in to the root. So CURDIR("another drive") always returns "\". How useful.


We used to use CURDIR() all the time to figure out where we were. We still do, in applications, but interactively, CD all by itself is six fewer characters to type. Actually, it's seven fewer because you have to put a "?" in front of CURDIR() to get results. We never use SYS(2003) since we can never remember which SYS() function it is.

Usage

cCurrentDrive = SYS(5)
SYS(5) (and the equivalent SET("DEFAULT")) gives you the current drive designator. Put it together with CURDIR() to find out exactly where you are right now.

Example

CD F:\VFP\SAMPLES * Where are we? ? CURDIR()        && Returns "\VFP\SAMPLES\" ? SYS(2003)       && Returns "\VFP\SAMPLES" ? SYS(5)           && Returns "F:" CD H:\HACKER ? SYS(5) + CURDIR() && Returns "H:\HACKER\" ? CURDIR("F:")   && Should return "\VFP\SAMPLES\", but returns                  && "\" because changing to H: changed the                  && default on F:

See Also

ChDir, FullPath(), Home(), Set Default, Set Path


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