for filtered records you can say
use ('myfile')
count to xx for (condition of filteration)
as xx is a variable.
And for the deleted records:
set dele on
use ('myfile')
count to xx
=> xx will give the no. of undeleted records only
then
set dele off
count to yy
=> yy will give you all the records (undeleted+deleted)
the difference of (yy-xx) will give you the deleted records.
Hi,
there are several way to count record :
1. you can count record using COUNT FOR (your filter expression) if your view/table not filtered.
2. If your view already filtered (in local or remote view or filtered in cursor / Alias properties) you can use RECCOUNT(cAliasName) function.
Using FILTER is a really great way to decrease performance. ;-) If your tables are really small, it may not matter. But if you have larger tables out on a server, you don't want to spend much time in a filtered condition.
You might try using the SELECT command with your filter conditions. This will create a cursor (or you could even make it a table) on the local drive. Using _TALLY on the next line will give you the count...
SELECT * FROM voters.dbf WHERE republican = .t. INTO CURSOR bush
nForBush = _TALLY && count of selected records
You've already been shown the DELETED() keyword, just be sure you've got DELETED set to 'off' first.
Warning: the above was written off the top of my head before I've finished my first cup of coffee! ;-)
SELECT count(*) * FROM voters.dbf WHERE republican = .t. INTO Array aResult
aResult contains number of records.
Above is the most efficient way. In addition, it is beneficial, sometimes, to create index by 'Deleted()' expression, because any query/filter with set deleted on will be optimized.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.