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


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .