CONDITIONAL SUBROUTINES REFERENCE

CONDITIONAL SUBROUTINES REFERENCE

Subroutines can be conditionally executed using the if/endif or the if/else/elseif/endif keyword constructs.

IF/ENDIF

The if/endif conditional will execute a block of code following theif keyword only when the if argument evaluates to true.

If/endif example:

o100 sub

(notice that the if-endif block uses a different number)

o110 if [#2 GT 5]

(some code here)

o110 endif

(some more code here)

o100 endsub

IF/ELSEIF/ELSE/ENDIF

The if/elseif/else/endif conditional will execute the block of code following the if keyword when its argument evaluates to true. If the argument evaluates to false, then the code following each elseif is executed as long as the associated elseif argument evaluates to true. If no elseif keywords are present, or if all elseif arguments evaluate to false, than the code following the else keyword is executed.

If/elseif/endif example:

o102 if [#2 GT 5] (if parameter #2 is greater than 5 set F100)

F100

o102 elseif [#2 LT 2] (else if parameter #2 is less than 2 set F200)

F200

o102 else (else if parameter #2 is 2 through 5 set F150)

F150

o102 endif

CONDITIONAL SUBROUTINES REFERENCE