Welcome | spec | C-PLOT | Support | Users | Contact
 
Contents -> REFERENCE MANUAL -> Built-In Functions and Commands -> Commands For Macros -> Macro Arguments
spec Manual


2.4.4.3. - Macro Arguments



Within ordinary macros (not macro functions), the symbols $1, $2, ..., are replaced by the arguments with which the macro is invoked. Arguments are defined as strings of characters separated by spaces. Also, quotes can be used to include more than one space-separated string in a single argument. Use \" or \' to pass literal quotes. Arguments can be continued over more than one line by putting a backslash at the end of the line.

Within a macro the following substitutions are also made:
$0 is replaced with the macro name,
$* is replaced with all the arguments,
$# is replaced with the number of arguments,
$$ is a literal $.


When a macro defined without arguments is invoked, only the macro name is replaced with the definition. On the other hand, when a macro defined with arguments is invoked, all characters on the input line up to a ;, a { or the end of the line are eaten up, whether or not the macro uses them as arguments.

When numbered arguments are referred to in the macro definition, but are missing when the macro is invoked, they are replaced with zeros. If $* is used in the definition and there are no arguments, no characters are substituted.

As of spec release 3.03.10, there is no limit on the length of macro definitions. Macros can have a maximum of 25 arguments. The total combined size of all macro definitions is currently limited to 491,520 characters.

Beware of unwanted side affects when referencing the same argument more than once. For example, if i++ is an argument referenced more than once in a macro definition, the result is probably not what was desired.


  Top
  Prev | Next