How Thoroughbred Basic locates a file
This section describes how Thoroughbred Basic release level 8.1 or a later release locates a file.
Directives that cause Thoroughbred Basic to locate a file
Section titled “Directives that cause Thoroughbred Basic to locate a file”Directives that create files also cause Thoroughbred Basic to try and locate a file with the same name.
Some directives that create files: DIRECT, FILE, INDEXED, INITFILE, MSORT, PROGRAM, PSAVE new program, RENAME, SAVE new program, SERIAL, SORT, TEXT, TISAM.
Some directives that locate files: ADD, ADDR, CALL, ENCRYPT, ERASE, LOAD, OPEN, PSAVE existing program, RUN, SAVE existing program, START with program.
Where Thoroughbred Basic locates the file
Section titled “Where Thoroughbred Basic locates the file”Thoroughbred Basic locates or creates a file by using the directory name plus the file name.
Thoroughbred Basic determines the directory name based on whether the disk is defined as a logical disk directory, a subdirectory, or a hierarchical directory. Disks are specified in initial program load (IPL) files, which contain definitions that are loaded into memory when a user starts Thoroughbred Basic.
Logical Disk Directories: The directory name is specified in the disk DEV statement of the IPL file.
Subdirectories (Special Performance Feature): A special procedure is used to determine the directory name, using the directory name in the IPL file, its subdirectories, and the file name.
Hierarchical Directories: A special procedure is used to determine the directory name, using the current directory, the PREFIX variable, and/or the file name.
For more information on directories and IPL files, please refer to the chapter on System Files in the Thoroughbred Basic Customization and Tuning Guide.
Steps Thoroughbred Basic uses to locate a file
Disks are searched in the order in which they appear in the IPL file. If the disk is disabled, it is skipped. If the search encounters a disk defined as having hierarchical directories or subdirectories, a special procedure is used to search for the file.
If the disk directory is defined as a logical disk directory, Thoroughbred Basic attempts to locate or create the file using the directory name specified in the disk DEV statement of the IPL file and the file name specified in the program.
If the disk directory is defined as a hierarchical directory, Thoroughbred Basic attempts to locate the file:
-
By Full-path File Name: If the file name begins with a slash, Thoroughbred Basic assumes that the file name contains a full directory path (full-path file name), and the full-path file name, exactly as specified, is used to create or locate the file. If the file cannot be located on this disk, no further methods are used to create or locate the file on this disk.
-
By Current Directory: If the file name does not begin with a slash, the current directory is used to create or locate the file. If the file is not located, the next step is taken.
-
By PREFIX: If the file cannot be located in the current directory, then the alternate path names in sequential order (left to right) as found in the value of the PREFIX system variable are used to locate the file.
Note: The PREFIX system variable is never used to create a file.
If the disk directory is defined as having subdirectories, Thoroughbred Basic attempts to locate the file:
- In a Subdirectory Whose Name Matches the First Characters of the File Name: The first characters of the file name (full-path, partial-path, or no-path) are treated as a prefix that specifies the subdirectory. A subdirectory name can be from 2 through 9 characters long. If the file is not located or the subdirectory does not exist, the next step is taken.
- In the USR Subdirectory If It Exists: The USR subdirectory is used if the first characters of the file name did not match a subdirectory name. If the file is not found or the USR subdirectory does not exist, the next step is taken.
For more information on subdirectories, hierarchical directories, and IPL files, please refer to the Thoroughbred Basic Customization and Tuning Guide.
From the Thoroughbred Basic Developer Guide, version 8.9.1. Open this page in the PDF