Skip to content

Subtotal

See Also: BasicReport class, Print, Output

Purpose

To print the amount currently in the subtotal accumulator of an output window in a report image, and to zero the accumulator. This command is only used with legacy style reports that use screen images for output formatting, such as the BasicReport class; most DataFlex reports do not use this technique (or this command).

Syntax

subtotal
source [
    to destination
] [
    {
        option [, ..., option]
    }
]

Argument Explanation

  • source: Must be a window in a DataFlex image.
  • destination: Must be a window in a DataFlex image.
  • option: Must be a print option.

What It Does

Subtotal puts the value of the subtotal accumulator for source to destination and then sets the accumulator to zero.

DataFlex maintains a subtotal accumulator on every numeric window addressed by a print command. Whenever you print to a numeric type window, the value printed is added to the accumulator (in the precision of the window, not of the source value). Subtotal, typically in a section subtotal#, zeroes the accumulator and, optionally, puts the value of the accumulator to a window, again typically in Image subtotal# of a report program.

procedure_section subtotal2
subtotal subtotal3.4

In this example, the value of the accumulator for the fourth window in Image subtotal3 is printed to the first window in Image subtotal2 (if there is an Image subtotal2), relying on the autopage command in the procedure_section subtotal2 statement, and the accumulator is zeroed.

You may address windows with the subtotal command which are themselves filled by subtotal commands. This is the way to get subtotals for subtotal levels above the first one, and it is the way to get a grand total for a report.

You may access the value of any subtotal accumulator by appending a percent sign (%) to the window name of source. So long as you do not move or calc to the accumulator, this does not zero or otherwise affect the value of the accumulator.

move body.8% to cume

In this example, the subtotal accumulator for the eighth window in Image body is moved to variable cume.

Notes

  • Subtotal moves zero to source% to initialize it for the next subtotal.
  • You cannot address subtotal accumulators through windowindex.
  • Address windows which were themselves subtotalled to, with subtotal commands to get a subtotal for the next-higher subtotal-break level or a grand total.
  • If you print to a subtotalled window with any option on it other than those for the print command (capslock, fill=, float$, signrt, suppress), source% may contain an incorrect value.
  • Use of the subtotal command and subtotal accumulators is not limited to the BasicReport class, but it is limited to sources filled by the print command. It does not work with report classes not derived from BasicReport, such as WinReport and CrystalReport.