ASSERT

From HEWIKI
Jump to: navigation, search

ASSERT(<expression>, <message>)

Contents

Arguments

<expression> 
A boolean expression being tested for pass or fail.
<message> 
A string indicating the message that will be displayed if the expression was false


Description

This is a built-in function that can force a script error if a certain condition is not met. The ASSERT command specifies a condition to check, and a message to generate if the condition turns out to be false. When this occurs, script execution is halted with a Script Error. Otherwise, the script continues.

Please also see the ScriptError() function for another way of doing this.

Examples

i as integer
i = 3
assert (i==3,"there's a problem with i") // Does not cause a script error
assert ( i < 3 , "there's a problem with i" )  // Causes a HeroScript error
 
> SCRIPT ERROR: assert failed, "there's a problem with i", calltrace 27834789234, script DoStuff, line #27

See also

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox