End If

From Br Wiki
Jump to: navigation, search

The END IF (EN IF) Statement can be used to end a multi-line IF structure.

Comments and Examples

A multiple-line IF structure is initiated when the IF statement ends with an open-ended THEN or ELSE clause. (The term "open-ended" denotes a keyword that is not followed by an instruction until the next line.)

There are two ways to terminate a multiple-line IF:

a.) with a single-lined ELSE statement
b.) with an END IF statement.

The following example shows a multi-lined IF which is initiated with an open-ended THEN clause and which is terminated with a single-lined ELSE statement:

00010 IF X=2 THEN !:Initiates the multiple-line IF
00020 Y=1!: THEN instructions begin
00030 FOR Z=1 TO 10
00040 X$(Z)=""
00041 50  NEXT Z
00060 ELSE Y=0 !: Terminates the multiple-line IF

The following example shows a multi-lined IF which is initiated with an open-ended ELSE clause and which is terminated with an END IF statement:

00010 IF X=2 THEN Y=1 ELSE !:! Initiates the multi-line IF
00020  Y=0
00030  FOR Z=1 TO 10
00040   X$(Z)=""
00050 NEXT Z !:!ELSE instructions end
00060 END IF !:! Multi-line IF terminated

Syntax

END IF

Endif.png

Technical Considerations

1.) IF nesting is allowed in multi-lined IF structures only. Nested multi-lined IFs are terminated in reverse order. 2.)Required to terminate a multi-line IF structure.