HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)

4-: 111
Parameters
num_var
A numeric variable assigned the sequence of values:
num_expr1
,
num_expr1
+num_expr3,
num_expr1
+(2*
num_expr3
),
etc. The DISP or PRINT statement prints the values of
the elements of
d_list
for each value that is less than
num_expr2
if
num_expr3
is positive or greater than
num_expr2
(if
num_expr3
is negative).
num_expr1
First value assigned to
num_var
.
num_expr2
Value to which
num_var
is compared before the DISP or
PRINT statement prints a value. If
num_expr3
is
positive and
num_var
>
num_expr2
, the loop execution is
terminated. If
num_expr3
is negative and
num_var
<
num_expr2
, the loop execution is terminated.
num_expr3
Amount by which
num_var
increases at the end of the
loop. The default value is 1 if the step option is not
specified.
output_item_
Same as
d_list
in DISP or PRINT statement syntax.
list
Examples
PRINT "Values for A are: ",(FOR I=1 TO 4, A(I);),,,"X Value: ",X
If each variable is assigned the following values prior to execution of
line 20:
A(1) = 10
A(2) = 20
A(3) = 30
A(4) = 40
X = 50
The output generated by line 20 is:
Values for A are: 10 20 30 40
X Value: 50
Display list FOR clauses can be nested.
20 PRINT (FOR I=1 TO 3, (FOR J=1 TO 2, (FOR K=1 TO 2, B(I,J,K))))
For each combination of values of I, J, and K, the following table shows
the variable value that the above statement prints.
---------------------------------------------------------------------------------------------
|||| |
| Value of I | Value of J | Value of K | Variable Printed |
|||| |
---------------------------------------------------------------------------------------------
|||| |
| 1 | 1 | 1 | B(1,1,1) |
|||| |
---------------------------------------------------------------------------------------------
|||| |
| 1 | 1 | 2 | B(1,1,2) |
|||| |
---------------------------------------------------------------------------------------------
|||| |
| 1 | 2 | 1 | B(1,2,1) |
|||| |
---------------------------------------------------------------------------------------------
|||| |
| 1 | 2 | 2 | B(1,2,2) |
|||| |
---------------------------------------------------------------------------------------------