abort: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 31: | Line 31: | ||
</source> | </source> | ||
The following | The following line can be used to protect macros that only the GM should run | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[h: abort(isGM())] | [h: abort(isGM())] | ||
</source> | </source> | ||
The following | The following line can be used to silently end a macro that can only be run from a [[Trusted Macro]] | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[h: abort(isTrusted())] | [h: abort(isTrusted())] |
Revision as of 08:42, 25 March 2009
abort() Function
• Introduced in version 1.3b42
The
abort()
function is used to conditionally abort the execution of a macro. If the argument to abort()
is 0 then the execution of the macro stops and all macro output is discarded. If the argument to abort()
is non zero then the macro continues.
Note that only the output of the macro is discarded when the macro is aborted any changes made to macros will not be undone.
Common uses for this function are
- Ending a macro if the cancel button is clicked on an input dialog created using the input() function.
- Discarding all output generated by the macro, in effect making a "silent" macro.
- Silently bailing out of a macro if a certain condition is not met.
Usage
abort(num)
Examples
The following example will create a dialog box for the user to enter a value for the variable named blah, if the user clicks on cancel then res will be 0 so the abort() function will cause the macro to terminate, otherwise res will not be 0 so the macro will continue.
[h: res = input("blah")] [h: abort(res)]
The following example discards any output in the macro.
Hah! you will never see this! [abort(0)]
The following line can be used to protect macros that only the GM should run
[h: abort(isGM())]
The following line can be used to silently end a macro that can only be run from a Trusted Macro
[h: abort(isTrusted())]
See Also
Version Changes
- 1.3b49 - No message is displayed if called from a macroLink.