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

4- 8
the statement. If the break condition is true, all summary levels from
the BREAK level and up are triggered. This causes TRAILER and HEADER
sections to be printed.
The BREAK WHEN statement can occur anywhere in the report description.
There can only be one BREAK statement per summary level, either BREAK IF
or BREAK WHEN. There is no BREAK statement for the report level.
Syntax
BREAK
break_level
WHEN
control_expr
[CHANGES]
BREAK
break_level
WHEN
num_ctl_expr
[CHANGES] BY
num_by_expr
Parameters
break_level
The summary level triggered if the break condition is
satisfied. This value must be in the range [0, 9]; a
level of zero causes the statement to be ignored.
control_expr
A numeric or string expression. When BREAK WHEN is
num_ctl_expr
evaluated, the value of this expression is recorded.
Then this value is compared at the next DETAIL LINE to
see if any change has occurred. A break occurs occur if
a change takes place.
num_by_expr
A numeric expression indicating how much the control
expression must change before a break occurs. See below
for exact details about how this works. The control
expression must be numeric to use a BY clause.
Examples
100 BREAK 1 WHEN Salesman$ CHANGES
100 BREAK 3 WHEN Region CHANGES
100 BREAK N WHEN Product CHANGES BY Base_product_num
The BEGIN REPORT statement sets all BREAK WHEN statements to busy, unless
the
break_level
is zero. When the report ends, the lines are no longer
busy. The level expression is evaluated only during BEGIN REPORT. In
addition, the BY clause value is evaluated only during BEGIN REPORT. The
control expression is evaluated during DETAIL LINE, TRIGGER BREAK, and
BEGIN REPORT.
The DETAIL LINE statement checks all BREAK statements when its
total-flag
is nonzero. The BREAK statements are evaluated in summary level order,
from one to nine. The control expression of the BREAK WHEN statement is
evaluated at this time. Conditions for satisfying a break are given
below. The LASTBREAK function is set as soon as a break condition is
found. DETAIL LINE remembers the lowest level broken and triggers the
TRAILER and HEADER sections from that level through nine. First, the
TRAILERS are triggered from the highest existing level descending to the
lowest level broken. Next, the HEADERS are triggered from the lowest
level broken up to the highest existing level.
When BEGIN REPORT executes, the level expressions for all BREAK
statements are evaluated first. A second pass is made for BREAK WHEN
statements. During this pass, the control expression is evaluated and
the result put into OLDCV (or OLDCV$) for the break level. Then, if
present, the BY clause is evaluated and its value recorded. This value
is used when a break occurs at the current level.
The TRIGGER BREAK statement also evaluates the BREAK WHEN control
expressions for all broken levels. This is to update the OLDCV and
OLDCV$ values for all broken levels. These evaluations are done before
the actual break occurs.
All OLDCV values are updated when a break occurs. The values are updated
between the printing of the TRAILER sections and the HEADER sections.
Satisfying a BREAK WHEN Condition
There are two forms of the BREAK WHEN statement; both have a
control