Page 1 of 1

Count xbrowse records

PostPosted: Thu Feb 22, 2024 11:13 am
by wartiaga
Hi, I have a xbrowse:

Lista40:cAlias := "ARQANO"

How I count records? I don't want the deleted ones to enter the sum.

Thanks!

Re: Count xbrowse records

PostPosted: Thu Feb 22, 2024 1:11 pm
by Silvio.Falconi
perhaps

len(oBrw:aArrayData )

or

oBrw:nDataRows

Re: Count xbrowse records

PostPosted: Fri Feb 23, 2024 4:07 am
by nageswaragunupudi
With or without XBrowse, we need to know the number of records in a DBF which are not deleted.
There is no simple function for this.

Does not matter whether SET DELETED is ON or OFF:

Both LASTREC() and RECCOUNT() include deleted records also.
ORDKEYCOUNT() also does not exclude deleted records by itself, but honors filters, scopes and index expressions.

So,

1)
Code: Select all  Expand view
SET FILTER TO !DELETED()
? OrdKeyCount()


2)
Code: Select all  Expand view

INDEX ON RECNO() TAG RECS FOR !DELETED() // keep this index tag also
// then
? OrdKeyCount( "RECS" )


3)
Code: Select all  Expand view
INDEX ON RECNO() TAG DELS FOR DELETED() // kee this index tag also
? OrdKeyCount(0) - OrdKeyCount( "DELS" )

Re: Count xbrowse records

PostPosted: Fri Feb 23, 2024 1:26 pm
by Silvio.Falconi
nageswaragunupudi wrote:With or without XBrowse, we need to know the number of records in a DBF which are not deleted.
There is no simple function for this.

Does not matter whether SET DELETED is ON or OFF:

Both LASTREC() and RECCOUNT() include deleted records also.
ORDKEYCOUNT() also does not exclude deleted records by itself, but honors filters, scopes and index expressions.

So,

1)
Code: Select all  Expand view
SET FILTER TO !DELETED()
? OrdKeyCount()


2)
Code: Select all  Expand view

INDEX ON RECNO() TAG RECS FOR !DELETED() // keep this index tag also
// then
? OrdKeyCount( "RECS" )


3)
Code: Select all  Expand view
INDEX ON RECNO() TAG DELS FOR DELETED() // kee this index tag also
? OrdKeyCount(0) - OrdKeyCount( "DELS" )



Nages,

is there a function in Xbrowse to calculate how many records are visible in xbrowse?

I explain to you:
at the bottom of the Xbrowse I want to insert two buttons to move the records and I want them to be activated only if the record count exceeds the actual display of the Xbrowse

Code: Select all  Expand view


@ 148, 320  BTNBMP aBtnBrow[1] ;
     RESOURCE "DWN_TBL", "", hBmp, "" ;
      SIZE 15, 13 PIXEL FLAT NOROUND GDIP WHEN lArrows  OF oDlg ;
      ACTION oBrw:KeyDown(VK_UP, 0)

 @ 148, 335 BTNBMP  BTNBMP aBtnBrow[2] ;
     RESOURCE "UP_TBL", "", hBmp1, "" ;
      SIZE 15, 13 PIXEL FLAT NOROUND GDIP WHEN lArrows OF oDlg ;
      ACTION oBrw:KeyDown(VK_DOWN, 0)

 


For example, if I have an Xbrowse in which 20 records are displayed at a time but there are more records in the archive (for example 50)
the lArrows must be true

Re: Count xbrowse records

PostPosted: Fri Feb 23, 2024 4:38 pm
by wartiaga
Silvio.Falconi wrote:perhaps

len(oBrw:aArrayData )

or

oBrw:nDataRows


Thank you!

Re: Count xbrowse records

PostPosted: Fri Feb 23, 2024 4:39 pm
by wartiaga
nageswaragunupudi wrote:With or without XBrowse, we need to know the number of records in a DBF which are not deleted.
There is no simple function for this.

Does not matter whether SET DELETED is ON or OFF:

Both LASTREC() and RECCOUNT() include deleted records also.
ORDKEYCOUNT() also does not exclude deleted records by itself, but honors filters, scopes and index expressions.

So,

1)
Code: Select all  Expand view
SET FILTER TO !DELETED()
? OrdKeyCount()


2)
Code: Select all  Expand view

INDEX ON RECNO() TAG RECS FOR !DELETED() // keep this index tag also
// then
? OrdKeyCount( "RECS" )


3)
Code: Select all  Expand view
INDEX ON RECNO() TAG DELS FOR DELETED() // kee this index tag also
? OrdKeyCount(0) - OrdKeyCount( "DELS" )


Mr Nages thank you! I solved it by adding the !deleted() in index