Branching, Looping, and Interrupting

Use the IF/THEN/ELSE, REPEAT/UNTIL, ABORT, and RETURN commands to add decision-making, looping, or interrupt capability to user-de￿ned functions.

The ABORT command stops the execution of all user-de￿ned functions and interrupts the operation of repeat loops. If ABORT is encountered in a function that has been executed by pressing a key, the function is interrupted and front-panel control is returned.

If the function is activated by a computer program, ABORT resumes program operation at the ￿rst OSA command following the function. When, in addition, the function is nested within one or more user-de￿ned functions, ABORT resumes program operation at the ￿rst OSA command following all of the user-de￿ned functions.

The RETURN command stops the operation of the currently executing user-de￿ned function, and returns to the point where the function was originally encountered.

The following example contains a user-de￿ned function, PROGRAM 1, nested within another function, PROGRAM 2, which itself is nested within another function PROGRAM 3. Since none of the functions contain ABORT, executing PROGRAM 3 executes all three sequentially.

5

CLEAR

723

Initialize OSA.

10

OUTPUT

723;"IP;"

 

20

OUTPUT 723;"TRDSP TRA,OFF;"

 

30OUTPUT 723;"ANNOT OFF;GRAT OFF;"

40OUTPUT 723;"VARDEF YY,0;"

60

OUTPUT

723;"FUNCDEF PROGRAM_1,^";

De￿ne PROGRAM

1.

 

 

70

OUTPUT

723;"REPEAT;";

 

 

 

80OUTPUT 723;"ADD YY,YY,100;";

90OUTPUT 723;"PU;PA 100,YY;PD;";

100OUTPUT 723;"DSPLY YY,4,0;";

110OUTPUT 723;"IF YY,EQ,300;THEN;ENDIF;";

120OUTPUT 723;"UNTIL YY,EQ,400;";

130OUTPUT 723;"^;"

140!

150!

160 OUTPUT 723;"FUNCDEF PROGRAM_2,";

De￿ne PROGRAM

 

2.

 

6-9