FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour show only some records on Xbrowse ( nRecords, year)
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
show only some records on Xbrowse ( nRecords, year)
Posted: Fri Sep 23, 2022 08:06 AM
I will display n records in an array, default 10 records
I use Tdatabase and made a Set filter as you can see on this method

Code (fw): Select all Collapse
  METHOD Load_Data(nCount) CLASS TLOTTO
     local aTemp  := {}
     local nLastRecords,nInit,nEnd

  DEFAULT nCount := 10

    ::olotto := TArchivioLotto():New()
    ::olotto:SetOrder(1)
    ::olotto:goBottom()

    IF nCount > 0
       nInit:=::olotto:lastrec()-nCount
       nEnd:= ::olotto:lastrec()
    ENDIF

      ::olotto:Exec( <||
                SET FILTER TO   (  nInit <= ::olotto:RECNO() .AND.             ;
                                    nEnd >=  ::olotto:RECNO()    )
            return nil
            > )

       ::olotto:gotop()
       xbrowser ::olotto
     ::olotto:ArrayToDBF( atemp, , nil, .t., .t. )

     xbrowser aTemp
    return aTemp




on this picture I use the dbf not the array


I don't understand why I don't care about a record on array aTemp, obviously I'm using the database and have an nInit/nEnd filter for the last records, by default the number of records to display is 10 until the final user should check the possibility of caricature at least fine at 500 through a combobox to select ( 10,20,30,50,100,200,300,500)


any help please
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: show only some records
Posted: Fri Sep 23, 2022 02:52 PM
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: show only some records
Posted: Sat Sep 24, 2022 06:58 AM
I made a small test to try
I wish show only nrecord and only the year = nyear selected by user

Code (fw): Select all Collapse
 

#include "fivewin.ch"

REQUEST DBFCDX

//----------------------------------------------------------------------------//
FUNCTION Main()


   RddSetDefault( "DBFCDX" )

   SetHandleCount( 100 )

   SET DATE FORMAT "dd-mm-yyyy"
   SET DELETED     ON
   SET CENTURY     ON
   SET EPOCH TO    year( date() ) - 20
   SET MULTIPLE    OFF

 //  HB_LangSelect("IT")

 Test_array()

RETURN nil

//----------------------------------------------------------//

function Test_array()
 local aDatalotto

 local nAnno   :="1871"
 loca nType    := 1
 local nRecords:= 5

 aDatalotto := Create_Array(nRecords,nAnno,ntype)

   Xbrowser aDatalotto

return nil

//----------------------------------------------------------//
function Create_Array(nCount,nyear,nType)

   local oDlg, oFont, oBrw, oGet1, oGet2, oDbf
   local nInit,nEnd,bFor
   local aTemp  := {}
   local aNew

   DEFAULT  nCount := 10  ,;
            nType:=1 //normal


    oDbf  := TDataBase():Open( nil, "LOTTO", "DBFCDX", .t. )


    // select only n records
   IF nCount > 0
       nInit:=oDbf:lastrec()-nCount
       nEnd:= oDbf:lastrec()
    ENDIF

      oDbf:Exec( <||
                SET FILTER TO   (  nInit <=  oDbf:RECNO() .AND. ;
                                    nEnd >=  oDbf:RECNO()    )
            return nil
            > )

   oDbf:GoTop()
   oDbf:FW_DbfToArray( , , , , , , aTemp )
   oDbf:close()

   xbrowser atemp    // show 6 records why ??


   // for condition year
   aNew     := {}
   AEval( aTemp, { |a| If( year(a[ 1 ]) = val(nYear) , AAdd( aNew, a ), ) } )
  * FW_DbfToArray( , , , , , , aNew)




  return  aNew





//----------------------------------------------------------------------------//



the first problem it show the 5 record + 1 I not understood why
then for the year not run ok

for a sample if the user want show year= 1991 and the last 100 records not run ok
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: show only some records on Xbrowse ( nRecords, year)
Posted: Tue Sep 27, 2022 09:19 AM

Dear Silvio,

SET FILTER is very slow

Using an index with scopes should be better

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: show only some records on Xbrowse ( nRecords, year)
Posted: Tue Sep 27, 2022 10:04 AM
Antonio Linares wrote:Dear Silvio,

SET FILTER is very slow

Using an index with scopes should be better


with tdatabase I not Know How make it


IF nCount > 0
nInit:=oDbf:lastrec()-nCount
nEnd:= oDbf:lastrec()
ENDIF

oDbf:setscope(0,nInit)
oDbf:setscope(1,nEnd)


then for the year ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: show only some records on Xbrowse ( nRecords, year)
Posted: Tue Sep 27, 2022 10:20 AM
this run ok

Code (fw): Select all Collapse
 
       cFilter:= "LTRIM(STR(YEAR(FIELD->DATA)))= '" + nyear + "'"
        oDbf:SetFilter(cFilter)
        oDbf:GoTop()


How I can add the number of records to show ?
sample only 5 records

give me error Here

nInit:=Ltrim(str(oDbf:lastrec()-nCount))
nEnd:=Ltrim(str(oDbf:lastrec()))

cFilter:= "LTRIM(STR(YEAR(FIELD->DATA)))= '" + nyear + "' .and. '"+;
nInit + "' <= Ltrim(str(FIELD-RECNO())) .and. '"+;
nEnd + "' => Ltrim(str(FIELD-RECNO())) + "'"
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: show only some records on Xbrowse ( nRecords, year)
Posted: Tue Sep 27, 2022 10:31 AM

Glad to see that you have recovered your strength :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: show only some records on Xbrowse ( nRecords, year)
Posted: Tue Sep 27, 2022 10:34 AM
Antonio Linares wrote:Glad to see that you have recovered your strength :-)



I'm still recovering, my knee hurts
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: show only some records on Xbrowse ( nRecords, year)
Posted: Tue Sep 27, 2022 10:39 AM
also some errors

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: show only some records on Xbrowse ( nRecords, year)
Posted: Wed Sep 28, 2022 07:24 AM

I found a solution!!

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: show only some records on Xbrowse ( nRecords, year)
Posted: Wed Sep 28, 2022 06:24 PM

+1

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion