──DIRECTORY(──┬──────────────┬─)─────────
└─newdirectory─┘
DIRECTORY returns the current directory, first changing it to newdirectory if an argument is supplied and the named directory exists.
The return string includes a drive letter prefix as the first two characters of the directory name. Specifying a drive letter prefix as part of newdirectory causes the specified drive to become the current drive. If a drive letter is not specified, then the current drive remains unchanged.
For example, the following program fragment saves the current directory and switches to a new directory; it performs an operation there, and then returns to the former directory.
/* get current directory */
curdir = directory()
/* go play a game */
newdir = directory("d:/usr/games")
if newdir = "d:/usr/games" then
do
fortune /* tell a fortune */
/* return to former directory */
call directory curdir
end
else
say 'Can't find /usr/games'