Branching and labels
Traditionally, the APL right arrow '
A label is a name which is followed by a colon. It is placed at the start of the line which it identifies it. When the function is running, it is treated as a local variable whose value is the number of the line on which it is placed. It can thus be used directly as the argument of the right arrow.
A special case arises if no argument is given to the right arrow (a 'naked branch'). This terminates execution of the current function and of all functions which called it, removes them from the state indicator, and returns to desk-calculator mode. If the APL interpreter is already in desk-calculator mode, this will have the effect of removing the top function and all thouse down to the next function marked with an asterisk in the
To branch back from line 10 to line 3:
To branch unconditionally to a line labelled
 →LAB2  ...  LAB2:TOTAL←QTY×PRICE
To branch to a line labelled
 →(LOOP=10)/LAB2  ...  LAB2:TOTAL←QTY×PRICE
To branch to one of several lines depending on the value of the variable
 →(CASE1 CASE2 CASE3)[INDEX]
To branch to one of several lines using a boolean vector to select which (execution will continue at the label corresponding to the first 1 in the vector. If there is none, a message will be displayed and the function will end):
 →SELECT/(CASE1 CASE2 CASE3) ⋄ 'No case applies' ⋄ →0
Copyright © 1996-2010 MicroAPL Ltd