SET DIR
Set Current Directory
This directive changes the current directory for this task.
Syntax
Section titled “Syntax”SET DIR string-value [,ERR=line-ref|,ERC=error-code]string-value- is any string that represents a valid directory path name.
line-ref- is the program line number or label to branch to if this directive produces an error.
error-code- is a programmer-defined error code. Valid values are positive or negative whole numbers.
Remarks
Section titled “Remarks”This directive is generally available starting with release level 8.1.
The current directory defaults to the directory from which Thoroughbred Basic was executed.
A hierarchical directory must be set in the IPL file for Thoroughbred Basic to create or locate a file using the current directory.
The SET DIR directive changes the current directory in the same way as the cd command found in UNIX and Microsoft Windows. If the pathname begins with a slash (Microsoft Windows: a backslash), Thoroughbred Basic assumes that the path begins with the root directory. If the path does not begin with a slash (Microsoft Windows: a backslash), Thoroughbred Basic assumes that the path begins with the current directory. You can use 2 periods (..) as a synonym for the parent directory and 1 period (.) as a synonym for the current directory.
A trailing slash (Microsoft Windows: a trailing backslash) on the directory path is accepted but not required.
The maximum length for a path name is 64-characters. If the path name resulting from SET DIR exceeds 64 characters, an ERR=12 results.
If you change to an invalid or nonexistent directory, an ERR=12 results, and the current directory is not changed.
To avoid redundancy, the full path of the current directory should not match the full path of any PREFIX directory.
The DIR system variable returns the full path name of the current directory specified by the last SET DIR directive.
The SYSTEM directive temporarily exits to the current directory, regardless of whether a hierarchical directory is set in the IPL file.
Examples
Section titled “Examples”SET DIR "/usr/lib/DATA/BACKUP"changes the current directory to /usr/lib/DATA/BACKUP.
SET DIR ".."If the current directory is /usr/lib/DATA/BACKUP, changes it to the parent directory /usr/lib/DATA.
SET DIR X$If X$ = “PROG”, changes the current directory to the subdirectory PROG; if PROG does not exist, an ERR=12 results.
See also
Section titled “See also”SET PREFIX directive
DIR and PREFIX system variables
From the Thoroughbred Basic Language Reference, Volume III: R–Z, version 8.9.1. Open this page in the PDF