DISP [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation
HP Business BASIC/XL Reference Manual
DISP
The DISP statement outputs several values. It can use output functions
to output control characters. The DISP statement is similar to the PRINT
statement. The only difference between the DISP and PRINT statements is
that the DISP statement uses the standard list device, and the PRINT
statement uses the output device specified by the most recently executed
SEND OUTPUT TO statement. If the most recently executed SEND OUTPUT TO
statement specifies the standard list device, or if the program does not
contain a SEND OUTPUT TO statement, then the PRINT statement is
equivalent to the DISP statement.
Syntax
[,]
DISP [output_item_list] [;]
Parameters
[{[,]...} ]
output_item_ list [,]...output_item [{; } output_item]...
output_item One of the following:
num_expr
str_expr
array_name(*) Array reference. See "Array
References in Display List"
for more information.
{PAGE }
{{CTL} }
output_function {{LIN} }
{{SPA} (num_expr)}
{{TAB} }
See "Output Functions in
Display List" for more
information.
FOR_clause (FOR num_var=num_expr1 TO
num_expr2 [STEP num_expr3],
d_list)
See the section that follows,
"FOR Clause in Display List",
for more information.
, A separator. This prints each new item in a separate
output field.
; A separator. This prints each new item right next to
the previous item.
Examples
100 DISP
110 DISP,
120 DISP;
130 DISP X,X+Y;A$,LWC$(A$+B$);P(*),Q$(*);PAGE,TAB(10+X),
140 DISP Z(*), (FOR I=1 TO 10, Z(I); 2*Z(I); I*Z(I)), D$;
150 DISP A,,B
The DISP statement evaluates the expressions in the display list from
left to right and displays their values on the standard list device. It
displays numeric values in the current numeric output format (see
"Numeric Format Statements").
A DISP statement without a display list prints a carriage return and a
line feed (a CRLF) on the output file or device.
FOR Clause in Display List
The display list of a DISP statement can contain a FOR clause. The FOR
clause is similar to the FOR NEXT construct.
Syntax
(FOR num_var=num_expr1 TO num_expr2 [STEP num_expr3], output_item_list)
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 that num_var is compared to before the DISP or
PRINT statement prints a value. If num_var >
num_expr2, the loop is not executed.
num_expr3 Amount that num_var increases by if num_expr2 is
positive or decreases if num_expr2 is negative at end
of the loop. The default value is 1 if the step
option is not specified.
output_item_ list Same as d_list in DISP or PRINT statement syntax.
Examples
The following example shows the use of a FOR clause in the display list.
20 DISP "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 DISP (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) |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| 2 | 1 | 1 | B(2,1,1) |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| 2 | 1 | 2 | B(2,1,2) |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| 2 | 2 | 1 | B(2,2,1) |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| 2 | 2 | 2 | B(2,2,2) |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| 3 | 1 | 1 | B(3,1,1) |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| 3 | 1 | 2 | B(3,1,2) |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| 3 | 2 | 1 | B(3,2,1) |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| 3 | 2 | 2 | B(3,2,2) |
| | | | |
--------------------------------------------------------------------------------------------------
MPE/iX 5.0 Documentation