Declaring statements to be executed on ending field value(s)

!on ending

Declare statements to be executed on ending field value(s)


SYNTAX

!on ending field_id [and|or field_id] {
 statements
}

Declare a block of statements to be executed if the controlling expression will change value at the start of the next cycle. The statements are executed after the main code section on the ending set of records.

Each field_id must be a field from the driving file, an automatically read cross reference file, or an automatic temp. These are declared by !drive, !xfile and !auto, respectively. If more than one controlling field is specified, the fields must be linked by the same operator - and or or. These two operators cannot be mixed in a single !on ending expression.

In order to check the controlling expression, the runtime interpreter selects the next record from the driving file, reads all automatic cross-reference files and recalculates all automatic temporary fields. If the controlling expression has changed value, the previous records from the driving file and cross-reference files are reinstated, all automatic temporary fields are returned to their previous values, and the !on ending statements are executed. Note however that any temporary data which is modified by !on ending statements is carried forward.

Any number of !on ending declarations are permitted. They are processed in the order in which they are defined.

Functions such as total, min, max, average and count, if called in an !on ending section, (including those in subroutines and functions called from an !on ending section), return values for that section only. They are therefore particularly useful for printing subtotals and other block analysis figures.


NOTES

  • Subscripts cannot be specified for a field_id in an !on ending declaration. Therefore, if field_id is subscripted, the first element (in every dimension) is the element checked.


EXAMPLE

!on ending Time.cat and Time.code {
     EndSection()
}

RELATED TOPICS

Reports

!on starting