Programmer Guide/Command Reference/MACRO: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 2: Line 2:
  MACRO <var>macroname macroarguments</var>
  MACRO <var>macroname macroarguments</var>


The <code>MACRO</code> command executes the macro specified by <var>macroname</var>, passing to it the arguments specified by <var>macroarguments</var>. The macro will be started in its own variable environment, meaning that any changes the macro does to the environment will be lost after its execution.
The <code>MACRO</code> command executes the macro (i.e., the subroutine) specified by <var>macroname</var>, passing to it the arguments specified by <var>macroarguments</var>. The macro will be started in its own variable environment, meaning that any changes the macro does to the environment will be lost after its execution.


The macro source code <var>macroname</var> must be loaded (see the <code>[[User Guide/Workspace/Pre-configured profiles|LOAD]]</code> command). The <var>macroarguments</var> passed to the macro are stored in the variable <code>#ARGV</code> 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 <var>macroarguments</var> before it is assigned to <code>#ARGV</code>. For more information on argument passing, and parsing, see [[Programmer_Guide/Concepts/Argument_Passing|Argument Passing]]. For a broader information on macro programming, see [[XXX|Script Programming in {{STX}}]].
The macro source code <var>macroname</var> must be loaded (see the <code>[[User Guide/Workspace/Pre-configured profiles|LOAD]]</code> command). The <var>macroarguments</var> passed to the macro are stored in the variable <code>#ARGV</code> 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 <var>macroarguments</var> before it is assigned to <code>#ARGV</code>. For more information on argument passing, and parsing, see [[Programmer_Guide/Concepts/Argument_Passing|Argument Passing]]. For a broader information on macro programming, see [[XXX|Script Programming in {{STX}}]].
If you want to execute a subroutine in the variable environment of the caller (which is dangerous), you will enjoy the <code>[[Programmer_Guide/Command_Reference/MACROX|MACROX]]</code> command. If, on the other hand, 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 <code>[[Programmer_Guide/Command_Reference/SHELL|SHELL]]</code> command for executing the subroutine.

Revision as of 18:29, 5 April 2011

MACRO macroname macroarguments

The MACRO command executes the macro (i.e., the subroutine) specified by macroname, passing to it the arguments specified by macroarguments. The macro will be started in its own variable environment, meaning that any changes the macro does to the environment will be lost after its execution.

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.

If you want to execute a subroutine in the variable environment of the caller (which is dangerous), you will enjoy the MACROX command. If, on the other hand, 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.

Navigation menu

Personal tools