RDD

DbCount()

Count records selected by a scope

Syntax

Signature
DbCount( [bFor], [bWhile], [nNext], [nRecord], [lRest] ) --> nCount

Arguments

bFor

, bWhile, nNext, nRecord, lRest Optional record-scope controls.

Return value

The number of records selected by the scope.

Description

DbCount() counts records in the current work area. A FOR or WHILE block and the numeric scope arguments restrict which records are counted.

Notes

The record pointer is restored after the operation.

Example

DbCount.prg
PROCEDURE Main()

   DbCreate( "count_demo.dbf", { { "AGE", "N", 3, 0 } } )
   DbUseArea( .T., , "count_demo.dbf", "People" )
   DbAppend()
   FieldPut( 1, 20 )
   DbAppend()
   FieldPut( 1, 15 )
   DbCommit()
   QOut( "Adults: " + LTrim( Str( DbCount( {|| FIELD->AGE >= 18 } ) ) ) )
   DbCloseArea()
   FErase( "count_demo.dbf" )

RETURN

Output

See also