You are here: Automating Analyzer > Macro Substitution

Macro Substitution

Macro substitution is the process of substituting the contents of a variable into a command in place of field names or constants. Variables created with the Accept, Assign or Dialog commands can be used for macro substitution.

A macro substitution is identified by a variable enclosed in percent signs (%).

When Analyzer encounters a macro in a command, it substitutes the macro variable’s value in the command. This is particularly useful when variables cannot be directly used, as with parameter keywords, field and file names.

Macros may contain any text, multiple words or symbols, whole expressions or commands or parts of names. You can even place macros inside a quoted string.

Macros are most often used in conjunction with the Accept, Assign or Dialog commands. In the following example, respond to the Accept prompt by entering the file name.

ACCEPT "Enter the filename:" TO INPUT_NAME

OPEN %INPUT_NAME%

The percent (%) sign causes the Open command to ignore the variable name and substitute the contents of the variable as the specified table name.

Using Macros in Procedures