next up previous contents index
Next: Math Functions Up: The Scripting Language Previous: goto, label   Contents   Index


``Preprocessor'' Directives

The script parser interprets C-like ``preprocessor'' keywords. Unlike C, there is only a single pass through the text, so ``preprocessor'' is a misnomer. The keywords start with the comment `#' character.

There is one predefined macro. For any script which is read from a file (not counting the technology file) the token THIS_SCRIPT is effectively defined (as with #define, see below) to be the name of the script (for scripts launched from the User Menu) or a path to the file. Thus, in the script, the token THIS_SCRIPT is replaced by the file or script name. For example, to print the script name in the console window, one could add a line

Print("The name of this script is THIS_SCRIPT")

$\textstyle \parbox{4in}{\raggedright
{\tt \char93 define} {\it token}\\
{\tt ...
... arg\/}, {\it arg\/}1, ..., {\it arg\/}n)
[{\it text\_containing\_args}]}\\
}$
The macro name token may use alpha-numeric characters and underscores, and must start with an alpha or underscore character. The name is optionally immediately followed by an argument list in parentheses. The arguments are arbitrary alphanumeric plus underscore tokens that start with an alpha or underscore and are separated by commas. This is the same syntax used in the C language preprocessor for #define lines. The remainder of the line is the substitution string.

Throughout the script, each line is macro expanded. The actual arguments replace the formal arguments (if any) in the substitution text, which replaces the macro reference. The macro is recognized as a text token, i.e., it must be surrounded by punctuation or white space.

#ifdef token
If token has been defined, execution resumes at the following line. Otherwise, execution resumes at the line following the next #else or #endif.

#ifndef token
If token has not been defined, execution resumes at the following line. Otherwise, execution resumes at the line following the next #else or #endif.

#else
Used in conjunction with #ifdef and #ifndef.

#endif
Used to terminate an #ifdef, #ifndef, or #else block, or a #macro block.

#macro
The #macro directive, which has no counterpart in C, is assumed to be followed by macro statements in the format used in the .xicmacros file, followed by #end or #endif. If the #macro sequence appears in a script file, the macro is defined at that point.


next up previous contents index
Next: Math Functions Up: The Scripting Language Previous: goto, label   Contents   Index
Stephen R. Whiteley 2006-10-23