Creating Downloadable Programs

Branching, Looping, and Interrupting

To use a looping construct

￿Use the REPEAT/UNTIL command

In this example, repetition is controlled with a user-de￿ned variable, N, which incrementally increases each time the loop is repeated. The example stores the amplitudes of the three largest signals in the ￿rst three elements of a trace array. In addition, N doubles as a pointer that speci￿es where data is stored in the trace array.

10

CLEAR 723

 

 

Initialize OS A.

 

 

20

OUTPUT

723;"IP;"

 

 

 

 

 

 

30

OUTPUT

723;"STARTWL 750NM;STOPWL

1450NM;"

Activate single-sweep mode

and

40

OUTPUT

723;"SNGLS;TS;"

 

sweep.

 

 

 

50

OUTPUT

723;"DISPOSE ALL;"

 

Clear internal memory. (Op-

 

 

 

 

 

tionalsee \Memory" section

 

 

 

 

 

in this chapter .)

 

 

60

OUTPUT 723;"TRDEF TR_AMP,10;"

 

De￿ne 10-element trace , TR

 

AMP.

 

 

70

OUTPUT

723;"VARDEF N,0;"

 

De￿ne variable , N, equal to 0.

80

OUTPUT

723;"MKPK

HI;"

 

Place marker on highest peak.

90

OUTPUT

723;"REPEAT;"

 

Begin

repeat loop.

 

 

100

OUTPUT

723;"ADD

N,N,1;"

 

Add 1 to N.

 

 

110

OUTPUT

723;"MKPK

NH;"

 

Move marker to next highest

 

 

 

 

 

peak.

 

 

 

120 OUTPUT

723;"MOV

TR_AMP[N],MEASU

MKA;"

Store

amplitude in nth

ele-

 

 

 

 

 

ment of trace .

 

 

130

OUTPUT

723;"UNTIL N,EQ,3;"

 

Mark end of repeat loop. Loop-

 

 

 

 

 

ing ends when N equals 3.

 

 

To abort loops and user-de￿ned functions

￿Use the ABORT command to continue at the next commands after the function.

￿Use the RETURN command to continue from the point at which the current function was called.

6-11