Print current field and row valuesΒΆ
average() |
Return current average value of a field |
max() |
Return current maximum value of a field |
min() |
Return current minimum value of a field |
total() |
Return current total value of a field |
count() |
Return current total number of rows |
SYNTAX
Return the current number of rows procesed on the current report.
Return the current average, maximum, minimum or total value for the field specified.
The field_id may be a file field (from any file declared in the program) or may be a temporary field. If these functions are applied to an alphanumeric field, the text is assumed to be a number.
The function values are updated at the end of each cycle, using the value in field_id at that time. If used in an !on ending section, they return values for that section only. They are therefore particularly useful for printing subtotals and other block analysis figures. Otherwise they return values for the whole of the report so far.
Note that since the functions are updated at the end of a cycle, they do not include the record currently being processed if they are called during the main report logic.
When these functions are used as print items, they use the same format as the field to which they were applied. It is therefore advisable to specify a suitable format in the print command. See the examples below, where different formats are specified for the total and average of an i2 type field.
The count() function always returns an integer type.
The min(), max() and total() functions return an n8.0 type if the field is integer. Otherwise, the return type is the field type, but of the larger size: an r4 field returns an r8 type, an n4 an n8.
The average() function always returns an r8 type, since the value may contain decimal places even if the field is an integer.
EXAMPLE
!auto Product,,i2 = st_field1 * st_field2
print " Total = "; total(auto.Product): "##,###,##0"
print "Average = "; average(auto.Product): "####0.00"
RELATED TOPICS |