12-6-12

 

Program Command Reference

Syntax 4: If￿<expression>

}If Then <block>

Then

[<statement>] …

ElseIf￿<expression>

Then

}ElseIf Then <block>

[<statement>] …

Else

}Else <block>

[<statement>] …

IfEnd

Function 4

If the expression is true, the statement in the If Then block is executed. After that, execution advances to the next statement after IfEnd.

If the If command expression is false, the ElseIf command expression is tested. If it is true, the statement in the ElseIf Then block is executed. After that, execution advances to the next statement after IfEnd. If it is false, the Else block statement is executed. After that, execution advances to the next statement after IfEnd.

Description

With all four of the syntaxes described above, you can use a multi-statement command (:) in place of the carriage return to separate Then block statements.

The If~IfEnd command can be nested.

Example: Input a Input b If a < 0 Then

0 S a If b < 0 Then

0 S b IfEnd IfEnd

The If~IfEnd loop can be exited using the Break command or Return command.

It is always a bad idea to use the Goto command to exit an If~IfEnd loop. Not only is it poor programming, it can cause problems due to improper termination of internal processes used by If.

20050501