Have you looked at the COUNT command, this should give you what you want.
COUNT Command
Counts table records.
Syntax
COUNT
[Scope] [FOR lExpression1] [WHILE lExpression2]
[TO VarName]
[NOOPTIMIZE]
Arguments
Scope
Specifies a range of records to be included in the count. The scope clauses are: ALL, NEXT nRecords, RECORD nRecordNumber, and REST. For more information on scope clauses, see the Scope Clauses online topic. Commands that include Scope operate only on the table in the active work area.
The default scope for COUNT is ALL records.
Attitude is Everything