Function DbTotal() Foundation
Totals data from numeric fields of a work area into a second file.
DbTotal( <cFilename>, ;
<bIndexKey>, ;
[<aFieldnames>], ;
[<bForCondition>], ;
[<bWhileCondition>], ;
[<nCount>], ;
[<xRecordID>], ;
[<lRest>] ) --> NIL
The return value of DbTotal() is always NIL.
The function DBTotal() totals all fields of a work area which are specified in the array <aFieldnames> and writes the results into fields with the same names in the file <cFilename>. This target file cannot be open. It is created with the same structure as the source file in the work area. If the target file already exists, it is overwritten without warning.
The file in the work area must be sorted or indexed by the index key <bIndexKey>. Each time the value of the index key changes, a new record is copied into the target file and the summation is done into the new record. The lengths of the numeric fields must be long enough to store the result. Otherwise a runtime error occurs caused by numeric overflow.
If no field is specified in the array <aFieldnames>, a record is copied into the target file each time the value of the index key changes. This effectively deletes multiple values of the index key in the target file.
The scope for the summation can be limited by conditions or by specifying the number of records. If SET DELETED is turned ON, data records marked for deletion are not included. If a filter is active, records not matching the filter condition are also not included. When SET DELETED is turned OFF, a deletion mark is carried over to the target file only when the first record matching the index key is marked as deleted. For subsequent records having the same index key the deletion is ignored.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.