Macro Processing and Command Syntax

"Macro processing" involves the replacement of macro names with their current values to create the precise code that is executed from a Program object or with the shell command.

Macro values are not evaluated unless and until they are actually used. For example, a modify attribute trigger will not cause an attribute range program to be executed unless the macro ${ATTRCHOICES} is explicitly used by the program.

Macros can affect the surrounding text if the required characters have additional uses in programming, such as "$" or "\". To include a literal "${" in your text, you must turn off the macro processing substitution on a case-by-case basis by using the escape character "\".

For example, if USER=guest then:

output "The value of \${USER} is ${USER}"

results in the output:

The value of ${USER} is guest

You may want the "\$" in the text to be macro processed. This can be accomplished by using a pair of backslashes. For example, if MATRIXHOME=tools\matrix-10.7\ then:

output "The file can be found in \\${MATRIXHOME}"

results in the output:

The file can be found in \tools\matrix-10.7\

So, to restate, macro processing of a backslash (\):


  • followed by a "$", results in a literal $
  • followed by another backslash, results in a single backslash
  • in all other cases is treated literally

The consequence of this means that any backslashes that need to appear in pairs (like the beginning of a UNC path) will require escaping twice by using four backslashes. For example, one might use:

shell "\\\\ourserver\Matrix107\bin\winnt\mql.exe -v";

Note that macro processing is done in a single pass. Therefore, the values substituted in for macro names are not subject to macro processing. For example, if: MATRIXHOME=\\matrix107, then one could use:

shell "${MATRIXHOME}\bin\winnt\mql.exe -v";

Also note that the Tcl language also recognizes the backslash (among other characters) as an escape character. This means any Tcl code in a Program may require additional escaping. Refer to Tcl documentation for information on escaping in Tcl.

Also, the escape keyword can be used as the first word in any where clause to cause EENOVIA Live Collaboration to allow backslash (\) to be treated as an escape character; that is, to remove all special meaning from the character after the backslash.

Refer to the "Working with Workspace Objects" chapter in the MQL Guide, for more information and examples with the escape character.

When a program file name specified in an add or modify command includes the _mxJPO suffix, such as test_mxJPO.java, the system behaves the same as it does with the insert command -- that is, it does the macro processing and then inserts the code. For program files that do not include the _mxJPO suffix as part of the filename, the system does no macro processing on the code. Therefore, it is recommended that the _mxJPO suffix is routinely used.