From BR Wiki
(Redirected from ELSE)
Jump to navigation Jump to search

The Else statement may be used within a multi-lined IF structure to provide instructions for cases where an IF relational expression evaluates to false.

Comments and Examples

It is important to understand the difference between an ELSE clause and an ELSE statement: whereas an ELSE clause appears on the same line as an IF statement, an ELSE statement appears on its own line.

An ELSE statement may be either multi-lined or single-lined. A multi-lined ELSE is initiated when the ELSE keyword appears on a line by itself (without the "statement" parameter). The only way to terminate a multi-lined IF structure that includes a multi-lined ELSE is with the END IF statement.

In the following example, a multi-lined ELSE statement is initiated in line 15. The multi-lined ELSE is considered to be contained within the multi-lined IF:

00005  IF X=2 THEN
00010   Y=1
00015  ELSE
00020   Y=0
00030   M=31
00040 END IF

When an ELSE statement is immediately followed by the "statement" parameter, it is a single-lined ELSE. Single-lined ELSE statements serve a dual purpose: they provide ELSE instruction and they terminate the multi-lined IF structure. The following example requires no END IF statement because it includes a single-lined ELSE instead:

00010  IF X<>2 THEN
00020   Y=2
00030  ELSE Y=1


ELSE <statement>


1.) Multi-lined ELSE: See above for ELSE instructions.

Technical Considerations

1.) Business Rules does not, in any situation, allow GOTO branching to a line that starts with the ELSE keyword. Every ELSE statement is preceded by a hidden GOTO that branches around the area controlled by the ELSE. If branching to an ELSE is attempted, Business Rules automatically begins executing with the statement immediately following the ELSE instructions (the line following a single-lined ELSE or END IF).
2.) See the IF and END IF statements for additional information and examples.