3.07 File Input and Output
Complete files can be loaded and saved using the LOAD and SAVE commands.
A text file can be either loaded into an array with each line of the file being an array element. Similarly a text file can be created from an array.
Any file can be loaded as a data stream into a single string variable and saved back in the same format.
The source for a load operation can also be DATA statements in the program source. These are always loaded into an array.
Loads a complete file or stream of data from the source and assigns the data to an array or to a single variable.
LOAD [source,] variable [AS STREAM]
- Possible values for source are:
- DATA label (To be implemented)
In order to be loaded into an array the input must be text separated by newline characters. This will always be the case for inline data. Each text line is loaded into a new array element.
For stream input, the data can be of any type as no check is made on the contents. The resulting variable will be a LynPlex string so care should be taken if the string is likely to contain binary or other non-text data.
Writes a complete array or a string variable to the target file.
SAVE [target,] variable
- Possible values for target are:
- FILE file