default file variables

default file variables


DEBUG Index Level DEL
Syntax
Category BASIC
Type Definition
Description a brief discussion on the use of default file.variables in FlashBASIC 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 FlashBASIC 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.
Options
See Also SELECT WRITEVU READV DELETE WRITE MATREAD READ MATWRITE MATWRITEU WRITEV RELEASE OPEN base CLEARFILE FILE
Example
Warnings Using the default file.variable form is not advised because it makes programs harder to maintain.
Compatibility D3 7.0 AP R83
DEBUG Index Level DEL