Return to Statement


Conditional Branching Example 2

This example demonstrates the use of the JUMP statement to branch to two different delete operations.

$$
$$ Declarations
$$
ENTITY/P(2),L(2)
P(1)=POINT/0,0
P(2)=POINT/1,1
L(1)=LINE/P
L(2)=LINE/2,2,3,3
L10:CHOOSE/'SELECT DELETE','POINTS','LINES',DEFLT,1,RESP
JUMP/L10:,L99:,,,,L20:,RESP
DELETE/P
JUMP/L99:
L20:DELETE/L
L99:HALT

If the user selects points from the CHOOSE statement, the JUMP statement "drops through" since there is no label in the fifth field. Once the DELETE statement has executed, the unconditional JUMP branches over the DELETE line statement to the end of the program.

If the user selects lines from the CHOOSE statement, the JUMP statement goes to the label L20: where the DELETE lines statement is executed. Once the lines are deleted no JUMP is required since the end of the program in the next statement.