assert: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Updated with recent version changes.)
Line 1: Line 1:
{{stub|Examples of usage.}}
{{MacroFunction
{{MacroFunction
|name=assert
|name=assert
|version=1.3b49
|version=1.3b49
|description=
|description=
Halts execution and prints a custom error message if a condition is zero.  Note that the error message will be displayed in chat even if the command itself is in a [H: ] block.
Halts execution and prints a custom error message if a condition is {{false}}.  Note that the error message will be displayed in chat even if the command itself is in a [H: ] block.


|usage=
|usage=
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: assert(condition, message)]
assert(condition, message)
</source>
</source>
<source lang="mtmacro" line>
assert(condition, message, prefix)
</source>
'''Parameters'''
{{param|condition|The test condition that must evaluate to {{true}} for the macro to continue.}}
{{param|message|The custom error message that is presented if the macro is halted due to the {{false}} condition.}}
{{param|prefix|Determines if the error message should have the message prefix {{code|"Macro defined error: "}}. Defaults to {{true}}, set to {{false}} if you do not wish your custom error message to have the message prefix.}}
|also=
{{func|abort}}
|changes=
{{change|1.3b51|Added {{code|prefix}} parameter option.}}
}}
}}
[[Category:Miscellaneous Function]]
[[Category:Miscellaneous Function]]

Revision as of 05:19, 31 March 2009

 This article is a stub, you can help the RPTools Wiki project by contributing content to expand this article.
 This article needs: Examples of usage.

assert() Function

Introduced in version 1.3b49
Halts execution and prints a custom error message if a condition is false(0). Note that the error message will be displayed in chat even if the command itself is in a [H: ] block.

Usage

assert(condition, message)
assert(condition, message, prefix)

Parameters

  • condition - The test condition that must evaluate to true(1) for the macro to continue.
  • message - The custom error message that is presented if the macro is halted due to the false(0) condition.
  • prefix - Determines if the error message should have the message prefix "Macro defined error: ". Defaults to true(1), set to false(0) if you do not wish your custom error message to have the message prefix.


See Also

Version Changes

  • 1.3b51 - Added prefix parameter option.