DIRECT
Define Single-Keyed Access File
This directive is used to create a new, single-keyed data file in a logical disk directory.
Syntax
Section titled “Syntax”DIRECT file-name, key-size, num-records, record-size, disk-num, sector-num [,ERR=line-ref|,ERC=error-code]file-name- is any string of 8 characters or fewer used to name this file.
key-size- is an integer in the range of 1 to 144 indicating the size, in bytes, of this file's key.
num-records- is an integer in the range of 0 to 16,777,215 indicating the maximum number of records to be contained in this file.
record-size- is an integer in the range of 4 to 32767 indicating the number of bytes in each record in this file.
disk-num- specifies the logical disk directory that contains this file. Valid values are 0 through 35.
sector-num- is required but is normally the number 0 (zero) since each operating system allocates where the file is stored. A value of -9 (minus 9) will create the file Encrypted. If Encrypted the first 3 bytes of the file’s FID will be “ENC”.
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”If any integer range is exceeded, an ERR=41 results.
If a file-name of more than eight characters (operating system-specific) is specified, an ERR=10 results.
All valid values for sector-num are treated as 0, but syntax requires sector-num to be specified.
File-name must be unique in the execution environment. An attempt to define a file having the same name as another file that is already defined on an available logical disk directory results in an ERR=12.
The file-name can contain any ASCII characters, unprintable as well as printable. Avoid using characters which have special meaning in different operating system environments, for example, “ * “ in UNIX and Microsoft Windows, “ / “ in UNIX, “ # “ and “ \ “ in Microsoft Windows, and so on.
To avoid confusion do not use device or task names as file-names. For example, do not use T0 - T9, TA - TZ, Ta - Tz, D0 - Dz, LP, P0 - Pz, G0 - Gz, C0 - Cz. In general, most device and task names use two-character names. The simplest approach is to not use two-character file-names.
Starting with release level 8.3.1, you can define num-records as 0. This dynamic file type has no EOF (end of file) restrictions, so the necessity for file expansion is removed. The file can contain more than 2 billion records and 140 trillion characters. The minimum record size for this type of DIRECT file is 6 characters.
Examples
Section titled “Examples”DIRECT "SEAL", 10, 57, 26, 2, 0creates a DIRECT file named “SEAL” with the following parameters: key length is 10 bytes, 57 records with a length of 26 bytes each, and a location on logical disk 2 starting at a sector allocated by the operating system.
DIRECT A$, A, B, C, D, E, ERR=7999If A$=“SEAL”, A=10, B=57, C=26, D=2, and E=0 has the same effect as the first example and branches to statement 7999 if this directive produced an error.
See also
Section titled “See also”ADDSORT, ERASE, FILE, INDEXED, INITFILE, MSORT, REMSORT, SERIAL, SORT, TEXT, and TISAM directives
From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF