You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Detecting Data Type Mismatching<br />
<strong>Virtual</strong> <strong>Machine</strong> Reference, Model Customization<br />
The Macro Language, Fundamentals of the Macro Language<br />
The compiler tries to ensure data type agreement between the argument expressions and the<br />
operators, functions or macro commands that operate on them. Each line is checked independently<br />
of any other line. Since variables can have any data type, the amount of type checking done is<br />
limited. For example, the following line of code would cause a macro compiler error in QUEST:<br />
%L02='abc'+4<br />
The following two lines would not cause a compiler error, even though they are equivalent to the<br />
line above. These lines however would cause a processing error at run-time when the VM macro<br />
is executed.<br />
%L03='abc'<br />
%L02=%L03+4<br />
Explicit Type Declaration (DECLAR)<br />
The DECLAR command can be used to explicitly define a user variable as being GLOBAL or<br />
LOCAL, and can optionally restrict the type of information held by the variable. All variables<br />
defined using DECLAR are automatically initialized. The basic syntax is as follows:<br />
, LOGICAL<br />
KEYWORD<br />
RECORD<br />
REAL<br />
� STRING �<br />
� �<br />
DECLAR /<br />
�GLOBAL<br />
� � �<br />
�� LOCAL �� � �<br />
�<br />
�<br />
�<br />
�<br />
1:<br />
n<br />
�, variable _name<br />
�<br />
If GLOBAL is specified, then the variable being declared is global to all macros. If LOCAL is<br />
specified (the default) then the variable is local to the macro in which it is declared. Global<br />
variables should all be defined in the model startup macro. Local variables of course must be<br />
defined in the macro where they are being used.<br />
By default, a variable can hold any type of information, and the type can change at any time<br />
without restriction. If a variable is declared with a specific type, then an error will be issued at<br />
run-time if data of the wrong type is loaded into the variable.<br />
One or more variable names can be defined in a single DECLAR command. In addition, variables<br />
can be defined as arrays by specifying the number of array elements within parentheses ( )<br />
immediately following the variable name. The RESERV command (described a little further<br />
below) can also be used to define arrays in a more traditional way for those familiar with APT<br />
programming.<br />
Variables are assigned a default value when they are declared. These defaults are: blank string<br />
for STRING, zero for REAL, .FALSE. for LOGICAL, #0 for KEYWORD, #0:0 for RECORD,<br />
and $NULL for an untyped variable. An undeclared variable is assigned a default value of zero if<br />
it is referenced before it is assigned a value.<br />
<strong>ICAM</strong> Technologies Corporation – Proprietary 127