When a program runs under the UNIX or the Windows NT operating system there is a directory where the program is started. This directory is not necessarily the directory where the executable code is or where the basic program is. Sloppy saying: this is the directory where the user prompt was when the user typed in the command line starting the program. This is called the current working directory.
Whenever a file name is specified it can either be an absolute file name or a relative file name. Relative file names are always relative to the current working directory. For example the current working directory is `/home/pvc/scriba/example' and the file name is `hello.bas' then the operating system know that the actual file we refer to is `/home/pvc/scriba/example/hello.bas'. If we refer to the file `../source/getopt.c' then the operating system considers the file `/home/pvc/scriba/source/getopt.c'. This is because the `..' directory means : one directory above. This is the same in Windows NT as well as in any UNIX variant. (OpenVMS is a bit different.)
Using relative file names is easier than using the full path to each and any file name. ScriptBasic provides a command and a function to handle the working directory. The function curdir has no arguments and returns a string containing the current working directory path. The command chdir changes the current working directory according to its argument. For example:
As argument to chdir you can define any existing directory name as absolute path or relative to the current working directory. If the directory does not exist or there is some other condition that prevents the change of the current directory an error occurs.
Note that this command is disabled in the Eszter SB Application Engine variation of the interpreter and should be disabled in all multi-thread versions. The reason is that the current working directory is set for all interpreters running in the same process using this command and may generate failures in other scripts.