File Operations


The following keywords allow you to open external files for reading/writing
and to manipulate them by putting/getting values from/to GDL scripts. This process necessarily involves using special Add-On extensions.
Text files can be handled by the section called “GDL Text I/O Add-On”. Add-Ons for other file types can be developed by third parties.

See also the section called “GDL Text I/O Add-On”.

OPEN

OPEN (filter, filename, parameter_string)

Opens a file as directed. Its return value is a positive integer that will identify the specific file, -2 if the add-on is missing, -1 if the file is missing.
If positive, this value, the channel number, will be the file’s reference number in succeeding instances.
To include the referenced file in the archive project,
use the FILE_DEPENDENCE command with the file name.

filter: string, the name of an existing extension.
filename: string, the name of the file.
parameter_string: 
string, it contains the specific separation characters of the operational extension and the mode of opening.
Its contents are interpreted by the extension.

INPUT

INPUT (channel, recordID, fieldID, variable1 [, variable2, ...])

The number of given parameters defines the number of values from the starting position read from the file identified by the channel value.
The parameter list must contain at least one value. This function puts the read values into the parameters as ordered.
These values can be of numeric or string type, independent of the parameter type defined for storage.

The return value is the number of the successfully read values. When encountering an end of file character, -1 is returned.

recordID, fieldID: the string or numeric type starting position of the reading, its contents are interpreted by the extension.

VARTYPE

VARTYPE (expression)

Returns the type of the expression:

  • 1 – numerical
  • 2 – string
  • 3 – group (as result of the ADDGROUP command and such)
  • 4 – dictionary

Useful when reading values in variables with the INPUT command, which can change between type 1 and 2 according to the current values.
The type of these variables is not checked during the compilation process.

OUTPUT

OUTPUT channel, recordID, fieldID, expression1 [, expression2, ...]

Writes as many values into the file identified by the channel value from the given position as there are defined expressions.
There has to be at least one expression. The type of values is the same as those of the expressions.

recordID, fieldID: the string or numeric type starting position of the writing; its contents are interpreted by the extension.

CLOSE

CLOSE channel

Closes the file identified by the channel value.