IF

From HEWIKI
Jump to: navigation, search

IF (expression) 
  {statements}
[ELSE IF
  {statements}]
[ELSE IF
  {statements}]
[ELSE | {statements}]
.

Description

The IF command forms the beginning of a program structure which is terminated by a period (.) on a line by itself. If the evaluation of the first (and possibly only) <expression> results in a non-zero value, then program execution continues with the next line, otherwise the (expression) for an optional ELSE or ELSE IF is evaluated. There may only be one ELSE clause per IF structure, though there may be unlimited ELSE IF clauses.

The IF command can have embedded functions which return a boolean value. If the value returned is TRUE, then the IF clause executes.

A note on efficiency: In some situations, the evaluation of the expressions may be "short-circuited", meaning that the Hero's Journey engine will only check as many as is necessary and then skip the rest. Please see the section on Expressions for more information.

Other logic switching commands include WHEN IS and WHERE IS.

Example Usage

IF (v1 = 2) 
  v2=3
ELSE
  v2=4
.

IF (i = 1) 
 ...
ELSE IF (i < 0) 
 ...
ELSE IF (i = 2) 
 ...
ELSE
 ...
.

if (c.mainScript hasMethod attack) 
   // do stuff
.
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox