Click or drag to resize

DbTotal Function

Summarize records by key value to a database file.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax
 FUNCTION DbTotal(
	 cTargetFile AS USUAL,
	 cbKey AS USUAL,
	 acFields AS USUAL,
	 cbForCondition AS USUAL,
	 cbWhileCondition AS USUAL,
	 nNext AS USUAL,
	 nRecord AS USUAL,
	 lRest AS USUAL,
	 xDriver AS USUAL
) AS LOGIC
View Source

Parameters

cTargetFile
Type: Usual
The name of the target database file to write the totaled records, including an optional drive, directory, and extension.  See SetDefault() and SetPath() for file searching and creation rules.  The default extension for database files is determined by the RDD .
If <cTargetFile> does not exist, it is created.  If it exists, this function attempts to open the file in exclusive mode and, if successful, the file is overwritten without warning or error.  If access is denied because, for example, another process is using the file, NetErr() is set to TRUE.  
cbKey
Type: Usual
A key expression specified as a code block.
acFields
Type: Usual
The fields to be totaled specified as an array of strings.
cbForCondition
Type: Usual
A code block that defines a condition that each record within the scope must meet in order to be processed.
cbWhileCondition
Type: Usual
A code block that defines another condition that each record must meet in order to be processed.   As soon as a record is encountered that causes the condition to fail, the operation terminates.
If no scope is specified, <cbWhileCondition> changes the default scope to <lRest>.
You define the scope using one of these three, mutually exclusive arguments.  The default is all records.
nNext
Type: Usual
The number of records to append, starting at the current record.
nRecord
Type: Usual
The number of the record to append.
lRest
Type: Usual
TRUE processes only records from the current record to end-of-file.  FALSE processes all records.
xDriver
Type: Usual

Return Value

Type: Boolean
TRUE if successful; otherwise, FALSE.
Remarks
Tip Tip
The <nNext>, <nRecord>, and <lRest> arguments are mutually exclusive. You should not pass all three of them. And if you pass the <cbWhile> argument then this also controls the scope behavior.
DBTotal() is the functional equivalent of the TOTAL command.
Examples
The following example produces totals for the Salary and Age fields:.
X#
DBTotal("totals", {||Last}, {"salary", ;
                                "age"})
See Also