Programmer Guide/General Descriptions/Macro Environment: Difference between revisions
m (1 revision: Initial import) |
|
(No difference)
|
Revision as of 15:27, 14 December 2017
Macro, Subroutine and Member Function Environment (first character = #)
The following variables are reserved in the macro environment.
- argc
#ARGC = numberofarguments
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
#ARGV = argumentstring
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#MAC = macroname|labelname|classname
The variable #MAC
identifies the currently active macro macroname
, the subroutine labelname
or the member function classname
.
- new
#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.
- 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 functionHUGO
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.
- qargc
#qargc
contains the number of ARG-style arguments passed to the current. See#qarg
for details.
- read
#READ = numberofassignedvariables
The variable #READ
is set to the number of assigned target-variables by any type of READ
command.
- 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
).
- this
#THIS = instanceItemName
When a member function is called, the variable #THIS
is set to the name of the instance item.