MACROX
MACROX macroname macroarguments
The MACROX
command executes the macro macroname in the current variable environment, passing it the arguments specified by macroarguments. Any changes the macro does to the environment will persist after its execution. This includes any unwanted changes, so be careful (for a different behaviour, see below, or directly refer to the STx statements MACRO
, and SHELL
).
The macro source code macroname must be loaded (see the LOAD
command). The macroarguments passed to the macro are stored in the variable #ARGV
of the called macro. Because of the special command-line processing in STx, all string replacements are applied to and all special parsing information (e.g. quotation marks) are removed from macroarguments before it is assigned to #ARGV
. For more information on argument passing, and parsing, see Argument Passing. For a broader information on macro programming, see Script Programming in STx or Becoming an S_TOOLS-STx Guru (in 240.918 simple steps).
Note again that the MACROX
command executes your subroutine in the very execution environment of the caller, meaning that any side-effects your subroutine may have to your local variables will persist. This is often dangerous, and not normally considered a healthy style of programming, but, obviously, there are cases where it is what you want.
Nevertheless, normally you will prefer having your subroutine executed in a separate execution environment. This is done with the STx command MACRO
(note the missing character "X"). If you want to separate the subroutine even more thoroughly from your current environment, you may even have it executed by a separate instance of the STx shell (i.e. the STx command interpreter), by using the SHELL
command for executing the subroutine. In this case, your subroutine will find start its existence in a clean environment, without local variables being inherited from the caller.