Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
It is good programming practice to close files when finished using them.<br />
Writing to a Text File (WRITE)<br />
<strong>Virtual</strong> <strong>Machine</strong> Reference, Model Customization<br />
The Macro Language, Text File I/O from a Macro<br />
The WRITE command writes a string into a text file. The syntax of the WRITE command is:<br />
0:<br />
n<br />
WRITE/ unit ', format ' ,<br />
� value �<br />
See the “Output String Format Specifications” below for a description of how the string to be<br />
written is constructed using the format argument.<br />
Normally, a file must be opened before a write operation is attempted. This is true for units 20<br />
through 29. All other units may be written to but may not be opened or read. It is important to<br />
exercise caution when writing to units outside of the safe range (20 to 29). This is especially<br />
important when considering the database files. These files are binary format and an inadvertent<br />
write could corrupt your database. All I/O should be restricted to units 20 through 29.<br />
Reading from a Text File (READ)<br />
The READ command can be used to read a line from a text file into one or more macro variables.<br />
The text file must be open when the READ is executed. The syntax of the READ from text<br />
file command is:<br />
INCR<br />
READ/ unit<br />
�<br />
,<br />
�<br />
1:<br />
n<br />
� DECR �<br />
', format ' ,<br />
� �<br />
� variable �<br />
If INCR is specified, the next line is read. This is the default. A READ using INCR should only<br />
be performed if “$FEOF(unit)” returns false. If DECR is specified, the last line is read again. If<br />
no lines have been read yet, the first line is read.<br />
See the “Input String Format Specifications” on page 142 for a description of how the variables<br />
in the input list are assigned values from the input unit text using the format string.<br />
Reading from a String Value (READ)<br />
The READ command can also be used to do an “internal read” from a string value. The syntax of<br />
the internal READ command is:<br />
1 : n<br />
� �<br />
READ/ strvar ', format ' , variable<br />
See the “Input String Format Specifications” on page 142 for a description of how the variables<br />
in the input list are assigned values from the input string variable strvar using the format string.<br />
<strong>ICAM</strong> Technologies Corporation – Proprietary 137