Syntax

If test Then statements End Else statements End

Parameters

The multi-line If statement has the following parameters.

ParameterDescription
testAn expression that equates to a Boolean value ¾ true or false. False is 0 or null. True is any other value.
statementsAny valid BASIC+ statement. May include branching instructions, such as GoTo or GoSub.
Then or ElseWhen Then or Else is the last keyword on a line, BASIC+ assumes that multiple lines follow. The Else clause is optional. One or more statements may appear in the Then or Else clauses. They may be written on the same line, if separated by semicolons.
EndUse End to terminate the multi-lined Then statements and the multi-lined Else statements. Should you fail to include the End statement to indicate the end of the Then or Else logic, the program will not compile, or, it will use the next available End statement as the termination of your Then or Else logic, rendering unpredictable results.

Other Forms of Multi-line If statements

Syntax

If test Then statements End

- OR -

If test Then statement Else statements End

- OR -

If test Then statements End Else statement

- OR -

If test Else statements End

Example

*Using multiple-line If statements
/* If the value of INV_COUNT is more than 144, the program will transfer to subroutine GROSS. 
If the value of INV_COUNT is less than or equal to 144, 
the program transfers to subroutine NOTGROSS for reordering. */
If inv_count GT 144 Then
  GoSub GROSS
End Else
  GoSub NOTGROSS
End