Programmer Guide/Programming a Toolbox/Toolbox function implementation: Difference between revisions
No edit summary |
|||
Line 5: | Line 5: | ||
<pre> | <pre> | ||
[MACRO tools]readvar #argv #function #argv / | [MACRO tools] | ||
cmdFunction1:$@TBPARSE '$#argv' // Parses the arguments depending on the context. This must be the first command$@TBLOADSETUP // Loads the settings (if any are defined)/*... the function code ...*/$@TBSAVESETUP // Save the settings (if any were changed)exit 1 int $#changed // #changed must be set to 1 if any data was changed (otherwise 0) | readvar #argv #function #argv /D | ||
goto cmd$#function noCmd | |||
noCmd: exit | |||
cmdFunction1: | |||
$@TBPARSE '$#argv' // Parses the arguments depending on the context. This must be the first command | |||
$@TBLOADSETUP // Loads the settings (if any are defined) | |||
/*... the function code ...*/ | |||
$@TBSAVESETUP // Save the settings (if any were changed) | |||
exit 1 int $#changed // #changed must be set to 1 if any data was changed (otherwise 0) | |||
</pre> | </pre> | ||
The function <code>@TBPARSE</code> must be the first command in the macro function. <code>@TBPARSE</code> and <code>@TBLOADSETUP</code> convert the calling arguments and the settings into local variables. | The function <code>@TBPARSE</code> must be the first command in the macro function. <code>@TBPARSE</code> and <code>@TBLOADSETUP</code> convert the calling arguments and the settings into local variables. |
Latest revision as of 13:49, 27 June 2019
The Toolbox function implementation takes place in a macro:
[MACRO tools] readvar #argv #function #argv /D goto cmd$#function noCmd noCmd: exit cmdFunction1: $@TBPARSE '$#argv' // Parses the arguments depending on the context. This must be the first command $@TBLOADSETUP // Loads the settings (if any are defined) /*... the function code ...*/ $@TBSAVESETUP // Save the settings (if any were changed) exit 1 int $#changed // #changed must be set to 1 if any data was changed (otherwise 0)
The function @TBPARSE
must be the first command in the macro function. @TBPARSE
and @TBLOADSETUP
convert the calling arguments and the settings into local variables.
@TBPARSE
The Toolbox function @TBPARSE
creates the following local variables:
#keyword
|
The name of the calling context. |
#function
|
The name of the function which was called. |
If a failure occurs when parsing, the Toolbox function is exited.
@TBLOADSETUP
The Toolbox function @TBLOADSETUP
creates local variables for all setup variable definitions in the function definition. Every varname = varvalue
entry is converted into a local variable #varname
with the value varvalue
. Setup variables can be saved using the Toolbox function @TBSAVESETUP
. The setup variables are stored in the STx INI file.
@TBSAVESETUP
The Toolbox function @TBSAVESETUP
saves all modified setup variables in the current STx INI file.