26.12.2012 Views

ICAM Virtual Machine V19 - Kxcad.net

ICAM Virtual Machine V19 - Kxcad.net

ICAM Virtual Machine V19 - Kxcad.net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ICAM</strong> <strong>Virtual</strong> <strong>Machine</strong> ® <strong>Virtual</strong> <strong>Machine</strong> Reference, Model Customization<br />

The Macro Language, Text File I/O from a Macro<br />

Macro matching is always automatically turned back on when the current macro is exited.<br />

Startup, shutdown and event macros are always invoked even if macro matching is turned OFF.<br />

Outputting the Matched Record (OUTPUT)<br />

The OUTPUT command instructs the macro processor to execute the actions associated with the<br />

current event. The syntax of the OUTPUT command is simply:<br />

OUTPUT<br />

The OUTPUT command must be coded in Model Event macros only; do not code OUTPUT in a<br />

startup or shutdown macro. If the OUTPUT command is not encountered in an event macro, then<br />

the built-in processing for that event will not occur. This gives you the opportunity in an event<br />

macro to insert your own processing before, after, or even in place of the built-in processing.<br />

Note that the OUTPUT command is also used with CERUN and GENER User-Defined macros to<br />

indicate the point in the user-defined macro where the matched command should be processed.<br />

4.4.1.4 Text File I/O from a Macro<br />

The macro language provides the ability to read from and write to external text files. These files<br />

are connected to and disconnected from the macro processor using OPEN and CLOSE commands.<br />

Input and output to external files is done using the READ and WRITE commands.<br />

When a file is opened, it must be assigned a “unit” number. This is a number from 20 through 29<br />

that will then be used in subsequent READ, WRITE and CLOSE statements to identify the<br />

particular file opened. This enables multiple files to be simultaneously opened for processing.<br />

If an error occurs during text file I/O, the error return code will be stored in the $ERRNO macro<br />

system variable. Macros must test for I/O errors and act accordingly since a diagnostic will not<br />

be output to indicate an I/O failure.<br />

Opening a Text File (OPEN)<br />

The OPEN command opens a text file with a given name on a given unit. The file name is<br />

optional if the unit is pre-connected. If FRONT is specified, the unit is rewound. If REAR is<br />

specified, the unit is positioned at the end-of-file. FRONT is the default. The OPEN command<br />

has the following syntax:<br />

OPEN/ unit<br />

� FRONT<br />

,<br />

�<br />

�<br />

[ , filename ]<br />

� REAR �� Two special file names are predefined to permit input and output to the console; they are STDIN<br />

and STDOUT.<br />

Closing a Text File (CLOSE)<br />

The CLOSE command closes a text file. It has the following syntax:<br />

CLOSE/<br />

unit<br />

136 <strong>ICAM</strong> Technologies Corporation – Proprietary

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!