Function CurDir() Foundation

Determines or changes the current directory of a drive. The function is deprecated. Use the function CurDirectory() instead.

Syntax
CurDir( [<cDrive>] ) --> cCurrentDirectory
or
CurDir( <cDirectory> ) --> cPreviousDirectory
Parameters
<cDrive>
The optional argument <cDrive> is a letter specifying the drive whose current directory is returned. If the argument is missing, the current drive is used.
<cDirectory>
Instead of a drive letter a complete path including drive designation can be specified with <cDirectory> which is then set as the current directory for the drive.
Return

The return value of CurDir() is a character string containing the current directory of the drive specified with <cDrive> without leading or trailing backslash characters (\). If an error occurs or the current path is the root directory, CurDir() returns a null string ("").

When a directory is specified for the function it changes the current directory accordingly and returns the previous directory. If the directory specified with <cDirectory> does not exist a runtime error is raised.

Description

The environment function CurDir() determines the name of the current directory on a specific drive independent of the settings SET DEFAULT and SET PATH. Contrary to the DOS operating system, various Xbase++ applications can run under 32bit operating systems at the same time in different windows. When <cDrive> is not specified in this case, CurDir() returns the start directory of the Xbase++ program as the default value.

This function can also be used to change the current directory of a drive. To do this, a character string containing the desired path, including the drive designator, must be passed to the function. If the character string contains only one path, this path on the current drive becomes the current directory. To change to the root directory of a drive the drive letter followed by a colon and a backslash must be passed to CurDir() ( "D:\" ).

The current drive itself can be changed using CurDrive().

Examples
Determines the current directory

// The example shows various results of the function CurDir() 

PROCEDURE Main 

   * Read current directory 
   ? CurDir("C:")  // result: XPP\SOURCE 
   ? CurDir("C")   // result: XPP\SOURCE 
   ? CurDir("D:")  // result: Null string "" (root directory) 
   ? CurDir("A")   // result: Null string "" 
                   //           (Error: drive not ready) 

   * Change current directory 
   ? CurDir( "C:\XPP\APPS" ) 
                   // result: XPP\APPS 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.