Overview


Conditional Branching

The conditional branching statements allow you evaluate the circumstances present in the program at a specific moment, and perform different functions based on those circumstances.

Unconditional Branching

The unconditional branching statement is used to jump over sections of a program, which under certain circumstances, you may want to omit. The unconditional jump is usually used to get out of a portion of the program to which you conditionally branched.

Example

For example, you may want to delete a line if its font is dashed, change its font to solid if it is currently phantom or centerline, and take no action if its font is solid. The following is a portion of a program which would accomplish this task.

RESP=&FONT(LN1)
JUMP/L30:,L20:,L10:,L10:,RESP
L10:&FONT(LN1)=&SOLID
JUMP/L30:
L20:DELETE/LN1
L30:
.
.
.

The variable RESP is assigned a numerical value equal to the current font of the object LN1; 1 equals solid, 2 equals dashed, 3 equals phantom, 4 equals centerline. The JUMP statement then uses the value of RESP to determine to which label (L10:, L20:, or L30:) it should jump.

There are four labels following the slash in the JUMP statement. If RESP is equal to 1, the JUMP statement jumps to the first label (L30:). If RESP is equal to 2, the JUMP statement jumps to the second label (L20:), and so on. Therefore if the line is already solid, the next several statements are jumped over because the program execution goes immediately to L30:. If LN1 is dashed, program execution jumps to the DELETE statement where LN1 is deleted. If the line is phantom or centerline, program execution jumps to where the line font is changed to solid.

The JUMP/L30:,L20:,L10:,L10:,RESP statement is conditional because it is based on current circumstances. The JUMP/L30: statement is unconditional because it causes a jump to L30: under any circumstance.