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

4-: 123
Examples
10 Nums_read=0
20 REPEAT !Begin loop
30 READ Number
40 Nums_read=Nums_read+1
50 UNTIL Number !End loop when Number<>0
60 PRINT Nums_read," numbers read"
99 END
REPEAT constructs can be nested.
100 REPEAT !Begin outer loop
110 READ Number1
120 REPEAT !Begin inner loop
130 READ Number2
140 UNTIL Number1-Number2 !End inner loop
150 UNTIL Number1+Number2 !End outer loop
160 PRINT Number1,Number2
999 END
Entering a REPEAT loop in the middle of the loop is considered to be a
bad programming practice, and is not recommended. However, calling a
local subroutine using GOSUB or calling an external subroutine using CALL
from within a REPEAT construct can be useful.
100 REPEAT !Begin loop
110 READ N1,N2
120 IF (N1 MOD 2) THEN GOSUB 200 !If N1 is odd, exit the loop
125 PRINT N1
130 UNTIL N2 !End loop
140 STOP
200 N1=2*N1
210 RETURN !Return to inside of loop
999 END
REPORT EXIT
The REPORT EXIT statement defines a Report Writer section that executes
when the STOP REPORT statement executes in a program. This condition
typically indicates than an error has been detected and that the report
must be stopped abnormally. The REPORT EXIT section allows the program
to produce a meaningful message and finish the report gracefully. If no
WITH or USING clause is present, the statement produces no output.
Syntax
[ [LINES]]
REPORT EXIT
boolean_expr
[WITH
num_lines
[LINE ]]
[USING
image
[;
output_list
]]
Parameters
boolean_expr
If this expression is zero (FALSE), the REPORT EXIT
section does not execute. For nonzero values (TRUE),
the REPORT EXIT statement and section will execute.
This provides you with more control over early report
termination.
num_lines
The maximum number of lines expected to be needed by the
section statement. This number reflects ALL output done
by the section.
image
An image string or a line reference to an IMAGE line.
output-list
A list of output items, identical to the list used by
the PRINT USING statement.