|Command||basic.default.files Definition/BASIC Program
Applicable release versions: AP, R83
|Category||BASIC Program (486)|
|Description||a brief discussion on the use of default file.variables in Pick/BASIC programs.
The following group of statements makes use of a feature known as default file.variables: "clearfile", "delete", "matread", "matreadu", "open", "read", "readu", "readv", "readvu", "release", "select", "write", "writev", "writevu", "matwrite" and "matwriteu".
Most experts agree that this feature should be avoided, but here is a quick discussion of how they work.
When a file is opened with an "open" statement, it is usually assigned to a file.variable for referencing the file later in the program with any of the above statements. This takes the general form:
open "customers" to customer.file else ...
The operative word here is "to". It assigns the actual location (represented internally as a base, modulo and separation) to the variable called "customer.file", in this case. Later in the program, when an item is read from the file, the file.variable appears in the appropriate form of a "read" statement, as in the form:
read customer.item from customer.file else ..
Here, the operative word is "from". With "default" file.variables, nothing is explicitly assigned during the "open" statement, as in the form:
open "customers" else ..
Hence, any subsequent attempt to read from or write to the file does not require the file.variable reference, as illustrated in the form:
read customer.item else ...
There may be only one default file.variable in a Pick/BASIC program. Any subsequent file needed for input or output must have an explicitly assigned file.variable during the "open" statement, or it takes the place of the default file.