Conditional Statements in Subprograms
The 3458AA provides three BASIC language statements for conditional branching
and looping. Use these statements only within 3458AA subprograms. Conditional
branching and looping statements provide for repetitive tests, initializing arrays,
etc.
The three conditional statements are: FOR...NEXT, WHILE...ENDWHILE, and
IF...THEN. These statements are similar to those used in an enhanced BASIC
language. The only exception is that 3458AA subprograms do not have line
numbers or GOTO statements for branching. Looping and conditional branching
statements may be nested seven deep.
FOR...NEXT Loops
The FOR...NEXT command defines a loop which is repeated until a loop counter
passes a specified value. The syntax statement for the FOR...NEXT 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 !
Keysight 3458A User's Guide
BASIC Language for the 3458A
7
405