RE:primeros pasos en XBASE++
SUM <nExpression,...> TO <VarName,...> ;
[FOR <lForCondition>] ;
[WHILE <lWhileCondition>] ;
[NEXT <nCount>] ;
<nExpression,...> is a comma-separated list of numeric expressions which are summed for each record.
<VarName,...> is a comma separated list of variables to contain the sum of each numeric expression from the list <nExpression,...> . The variable list <VarName,...> must be exactly as long as the expression list <nExpression,...> .
<lForCondition> is an optional logical expression which sets a condition. Only records for which <lForCondition> returns the value .T. (true) are included in the summation.
<lWhileCondition> is an optional logical expression which sets a condition. The summation is terminated as soon as the expression returns the value .F. (false).
<nCount> optionally specifies the number of records used in calculating the sum, starting with the current record.
The option REST specifies whether the sum is to be calculated only for the records from the current to the last record. If a condition is specified, the option ALL is used as the default value.
The option ALL includes all records in calculating the sums. If a condition is specified, the condition is tested for all records.
The command SUM calculates the sum of one or more numeric expressions from the values of the records in the current work area. The range for the summation can be limited by specifying a condition or the number of records. The sum of each numeric expression in <nExpression,...> is assigned to a variable in <VarName,...> .
// In the example, the daily sales for the month of
// June are totaled.
Use Invoice NEW
SUM Payment TO nIncomeJune FOR Month(InvDate) == 6
? "Sales in June:", nIncomeJune