xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

DbTotal()

Creates a new database summarizing numeric fields by an expression.

Syntax

DbTotal( <cDatabase>  , ;
         <bExpression>, ;
        [<aFields>]   , ;
        [<bFor>]      , ;
        [<bWhile>]    , ;
        [<nNext>]     , ;
        [<nRecord>]   , ;
        [<lRest>]       ) --> lSuccess

Arguments

<cDatabase>
This is a character string holding the name of the database file to create. It can include path and file extension. When no path is given, the file is created in the current directory. The default file extension is DBF.
<bExpression>
This is a code block whose return value identifies groups of records to summarize. Each time the return value of <bExpression> changes, a new record is added to the target database and a new calculation begins. Records in a work area should be indexed or sorted by <bExpression>.
<aFields>
A one dimensional array holding the names of database fields to use in the calculation must be specified. Each element of the array holds a character string with the name of a numeric field
<bFor>
This is an optional code block which must return a logical value. The records are used in the calculation when <bFor> yields .T. (true), otherwise they are ignored.
<bWhile>
This is an optional code block which must return a logical value. DbTotal() returns immediately as soon as <bWhile> yields .F. (false).
<nNext>
An optional numeric parameter restricting the number of records to use in the calculation to <nNext>, beginning with the current record.
<nRecord>
Only a single record is processed when the record number <nRecord> is specified.
<lRest>
An optional logical value that defaults to .F. (false). Specifying .T. (true) causes DbTotal() to start calculating with the current record and continue until the end of file is reached.

Return

The function returns .T. (true) on success, and .F. (false) on failure.

Description

DbTotal() is the functional equivalent of the TOTAL command. Refer to TOTAL for a detailed description of calculating totals from groups of numeric fields and collecting the results in a new database file.

Info

See also:AVERAGE, DbEval(), DbUpdate(), SUM, TOTAL, UPDATE
Category: Database functions , xHarbour extensions
Source:rdd\dbtotal.prg
LIB:xhb.lib
DLL:xhbdll.dll


Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe