[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.3.1.8 Run Macro ($x)

To invoke a macro defined by the Define Macro command, you simply use $macro-id. Cogsys saves the current input position on the macro stack. The macro-body for the macro is executed until an END_OF_MACRO character is read, then processing is resumed from the saved location.

Starting with Cogsys 3.0.9, macros can take arguments. See Define Macro, for details on defining macros and arguments. To call a macro with arguments, simply enclose the arguments in square brackets immediately after the call.

The END_OF_MACRO character is appended automatically by the Macro Definition command and users should not normally be concerned about it. However, if your testlist is giving an unexpected `MACSTACK_UNDERFLOW' errors, look for accidental insertions of the END_OF_MACRO character.

Beause the default macro definition is simply the END_OF_MACRO character, calling a macro before it is defined does nothing.

Name:
Run Macro
Class:
Control
Code:
$x
Syntax:
$macro-id
$macro-id[arg1...]
System:
Cogsys runs the macro-body defined for this macro-id
Requires:
To be useful, the macro should be defined with the Define Macro command first.

Test Files:
`MCRN_T01.IN'
tests basic operation

Example:

input
 
$$aPress <return> to continue: #R$$
...
$a

cogsys
Defines the macro a. At the $a macro call, Cogsys prints `Press <return> to continue:' and waits for keypress.



This document was generated by Usman Muzaffar on June, 28 2000 using texi2html