basic.default.files

Definition/BASIC Program, Releases: AP and R83

used by any file-access Pick/BASIC statement when a specific file variable is not specified.

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.

See Also

Command Name Type Description
basic.select Statement Creates internal active list.
basic.writevu Statement Writes one attribute, without unlocking.
basic.readv Statement Reads one attribute and assigns to value.
basic.delete.statement Statement Deletes item from file.
basic.write Statement Writes dynamic array to file.
basic.matread Statement Reads item into dimensioned array.
basic.read Statement Reads item into dimensioned or dynamic array.
basic.matwrite Statement Writes dimensioned array to file.
basic.matwriteu Statement see 'matwrite'.
basic.writev Statement Writes one attribute.
basic.release Statement Releases group/item lock(s).
basic.open Statement Opens file for input and output.
base Attribute Defining Item Displays first frame-id of file area.
basic.clearfile Statement Clears specified file.variable.
basic.file Statement Opens file and dimensions array.

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.