Programmer Guide/General Descriptions/Macro Environment: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 16: Line 16:
The variable <code>#MAC</code> identifies the currently active macro <code>macroname</code>, the subroutine <code>labelname</code> or the member function <code>classname</code>.
The variable <code>#MAC</code> identifies the currently active macro <code>macroname</code>, the subroutine <code>labelname</code> or the member function <code>classname</code>.


#new<code>#NEW = newitemname</code>
<code>#NEW</code> - newitemname


If a <code>NEW</code> command creates a new item successfully, the name of the new item is assigned to the variable <code>#NEW</code>. To save the (e.g. automatically generated) name, it must be assigned to another variable before the next <code>NEW</code> command is executed.
If a <code>NEW</code> command creates a new item successfully, the name of the new item is assigned to the variable <code>#NEW</code>. To save the (e.g. automatically generated) name, it must be assigned to another variable before the next <code>NEW</code> command is executed.

Revision as of 15:31, 14 December 2017

The following variables are reserved in the macro environment.

#ARGC - the number of arguments

If a macro is defined with the extended header format (see Macros and Classes), the number of arguments passed is assigned to this variable (otherwise the number of arguments can be found in the variable #read after READVAR #argv has been called). Note that #argc only contains the correct number of arguments if they are blank separated.

#ARGV - the argument string

When a macro, subroutine or member function is called, the variable #ARGV contains the argument string passed by the calling command. The command READVAR or (for macros only) the extended header format can be used to separate the arguments.

If a macro passes its environment to another macro (MACROX) or a subroutine (GOSUBX) the variables #ARGV, #ARGC and #MAC in its environment are changed!

#MAC - the macroname|labelname|classname

The variable #MAC identifies the currently active macro macroname, the subroutine labelname or the member function classname.

#NEW - newitemname

If a NEW command creates a new item successfully, the name of the new item is assigned to the variable #NEW. To save the (e.g. automatically generated) name, it must be assigned to another variable before the next NEW command is executed.

  1. qargYou may use #qarg in order to pass ARG-style arguments to another function without getting them distorted in any way. This sounds stupid, but consider what happens when calling a user-defined function, e.g. HUGO, with the statement "HUGO $#argv": if the ARG-style arguments you got contain whitespace, the function HUGO will end up with a different argument list than expected (and than the caller has passed to your function).

If, on the other hand, you use the statement "HUGO $#qargv", the callee, HUGO, will get EXACTLY the same argument(s) as the function calling HUGO has been passed.

  1. qargc#qargc contains the number of ARG-style arguments passed to the current. See #qarg for details.
  1. read#READ = numberofassignedvariables

The variable #READ is set to the number of assigned target-variables by any type of READ command.

  1. shell#SHELL = newshellid

When the command SHELL is used to start a new shell, the id of the started shell is stored in the variable #SHELL of the caller's environment (see also variable SHELL).

  1. this#THIS = instanceItemName

When a member function is called, the variable #THIS is set to the name of the instance item.

Navigation menu

Personal tools