Enform Plus Reference Manual

Enform Plus Language Elements
Enform Plus Reference Manual422684-001
3-14
User Aggregates
A user aggregate cannot be referenced in the end expression of the declaration of
another user aggregate.
A user aggregate declared with an end expression cannot be used as a qualification
aggregate over a by-item.
The syntax of a user-defined aggregate is shown with the DECLARE Statement
on
page 4-9. The syntax is also shown here to clarify this description.
user-aggregate-name
is a unique name you give your aggregate. The name must follow the naming rules
described under Rules for Naming User-Defined Elements
on page 3-6. This name
is also used to obtain the current value of the aggregate in step-expression
and end-expression.
formal-argument
is a unique name used to represent the actual field name or expression in the
aggregate definition.
step-expression
is an arithmetic expression to be computed for each value contributing to the
aggregate. Normally, step-expression includes a reference to the user-
aggregate-name so that a value is accumulated over the contributing values.
end-expression
is an arithmetic expression to be computed after all qualifying values for the
aggregate are processed. end-expression can contain a predefined aggregate
name. If end-expression is omitted and initialize-constant is present,
an extra comma must precede initialize-constant.
initialize-constant
is a numeric literal that is the starting value of the aggregate. Zero is the default.
When end-expression is omitted and initialize-constant is present,
an extra comma must precede initialize-constant.
Parentheses must appear exactly as shown in this syntax.
Consider the following user aggregate:
DECLARE grossavg (x) = (grossavg + 1.10 * x, grossavg/COUNT
(x));
The user-aggregate name is grossavg. The formal-argument is x. The step-
expression is (grossavg + .10 * x). The end-expression is
grossavg/COUNT (x).
user-aggregate-name ( formal-argument ) = ( step-expression
[ , [ end-expression ] [ , initialize-constant ] ] )