Computes the results of one or more expressions for a set of records.
COMPUTE [num] [setspec] EVALUATE clause [-> clause]
num | Can be an integer constant (15, 200); a variable, form field, or parameter that evaluates to an integer; the word ALL. If num is omitted, or less than 0, it defaults to ALL. |
setspec | The set specification (made up of application documents, EntitySets, relationships, forms, or result sets), designating the records to be changed. If omitted, the current set (if available) is used. Application documents named in the set specification cannot be updated. |
COMPUTE evaluates one or more expressions for a set of records without having to first LIST the data or create a result set of the desired records.
To compute all Employees where LName=Smith \, enter the following:
evaluate \
(let TotSal = $total(Salary)) \
(let MaxSal = $max(Salary)) \
(let MinSal = $min(Salary)) \
(let NoOfEmps = $count(LName)) \
(let AvgSal = $average (Salary))
output TotSal MaxSal MinSal NoOfEmps AvgSal
Processes the EVALUATE clause for every employee whose last name is "Smith". The OUTPUT command displays the results.
form open dInvoice
form display input
compute fInvItems \
evaluate (let fInvBott.InvTot = $total(fInvItems.Amt))
form display fInvBott.InvTot
Calls up a display and calculates a total after all items have been added.