Subject Re: rowset.count()
From Andy <andy.taylor.1959@outlook.com>
Date Mon, 09 Sep 2019 14:16:06 -0400
Newsgroups dbase.getting-started

Vic,

You will probably find that the the old XML commands work faster.
For each table in use in my apps I set up a table object...
this allows me to access the following code as just one of the functions for that table object:

function countVisibleRecs(cStr)
   // Returns a visible record count given a passed filter string.
   // An empty string will return the live record count (assuming deleted is "off").
   // Note that macro substitution requires a private variable rather than local
                private cFilter; cFilter = cStr         // change filter str to private
      // Open the table, set the passed filter and count
                this.openTable()                                                // open the table in a free WorkArea
                if not empty(cStr)
                        set filter to &cFilter.                        // use macro substition        to set a filter
                endif                
                local nCount; count to nCount                // count visible records
                this.closeTable()                                                // close the table
                release cFilter                                                // release the private var
                return nCount
  



Wrote:

> thanks , Ken !
>
> getting (-1) as a result of rowset.rowcount()
>
> So, I had to count it one by one (table in not very big) but it
> is no  good anyhow
>
> Best Regards
> Victor
>
>
> Ken Mayer Wrote:
>
> > On 9/6/2019 7:33 AM, Vic wrote:
> > > Hi, everybody !
> > >
> > > I do filter rowset (depending on user\'s wish) through rowset.canGetRow
> > > function. rowset is well updated in grid. Still rowset.count() return the same
> > > number of rows. doesn\'t it respect filtering or my code is wrong ? :
> > >
> >
> > No, it doesn\'t. The count() method returns the full number or rows in
> > the table every time. Try using rowset.rowCount() instead.
> >
> > Ken
> >
> >
> > --
> > *Ken Mayer*
> > Ken\'s dBASE Page: http://www.goldenstag.net/dbase
> > The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
> > dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
> > dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm
>