While Loops - Agilent Technologies 3458A User Manual

Hide thumbs Also See for 3458A:
Table of Contents

Advertisement

WHILE Loops

command is shown below.
FOR counter = initial_value TO final_value [STEP step_size]
program segment
NEXT counter
The counter parameter is a variable name which acts as the loop counter. The
initial_value parameter and final_value parameter may be numbers, numeric
variables, or numeric expressions. The optional step_size parameter may be
a number or numeric expression which specifies the amount the loop counter
is incremented for each pass through the loop. A negative value for step_size
decrements the loop counter. The program segment is repeatedly executed
until the loop counter exceeds the final_value.
10 OUTPUT 722; "SUB DMM_CONF"
20 OUTPUT 722; "NRDGS 100"
30 OUTPUT 722; "TRIG SGL"
40 OUTPUT 722; "INTEGER I"
50 OUTPUT 722; "FOR I = 1 TO 100"
60 OUTPUT 722; " ENTER A[ I]"
70 OUTPUT 722; "NEXT I"
80 OUTPUT 722; "SUBEND"
90 !
100 OUTPUT 722; "CALL DMM_CONF"
110 END
The WHILE command defines a loop which is repeated as long as the
specified numeric expression is true. The syntax for the WHILE command
is shown below.
WHILE expression
program segment
ENDWHILE
The WHILE operation depends on the result of a test performed at the start
of the loop. If the test is true (not equal to zero), the program segment between
the WHILE and ENDWHILE statements is executed and a branch is made
back to the WHILE statement. If the test is false (equal to zero), program
execution continues with the statement following the ENDWHILE
statement.
10 OUTPUT 722; "SUB DMM_CONF"
20 OUTPUT 722; "INTEGER I"
30 OUTPUT 722; "LET I=1"
40 OUTPUT 722; "NRDGS 100"
50 OUTPUT 722; "TRIG SGL"
60 OUTPUT 722; "WHILE I <=100"
70 OUTPUT 722; " ENTER A[I]"
80 OUTPUT 722; " LET I=I+1"
90 OUTPUT 722; "ENDWHILE"
100 OUTPUT 722; "SUBEND"
110 !
120 OUTPUT 722; "CALL DMM_CONF"
Chapter 7 BASIC Language for the 3458A
279

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents