show only some records on Xbrowse ( nRecords, year)

show only some records on Xbrowse ( nRecords, year)

Postby Silvio.Falconi » Fri Sep 23, 2022 8: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: Select all  Expand view
 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

 


Image

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
Last edited by Silvio.Falconi on Mon Sep 26, 2022 8:39 am, edited 2 times in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: show only some records

Postby Marc Venken » Fri Sep 23, 2022 2:52 pm

Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: show only some records

Postby Silvio.Falconi » Sat Sep 24, 2022 6:58 am

I made a small test to try
I wish show only nrecord and only the year = nyear selected by user

Code: Select all  Expand view


#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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: show only some records on Xbrowse ( nRecords, year)

Postby Antonio Linares » Tue Sep 27, 2022 9:19 am

Dear Silvio,

SET FILTER is very slow

Using an index with scopes should be better
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: show only some records on Xbrowse ( nRecords, year)

Postby Silvio.Falconi » 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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: show only some records on Xbrowse ( nRecords, year)

Postby Silvio.Falconi » Tue Sep 27, 2022 10:20 am

this run ok

Code: Select all  Expand view

       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())) + "'"
Last edited by Silvio.Falconi on Tue Sep 27, 2022 10:32 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: show only some records on Xbrowse ( nRecords, year)

Postby Antonio Linares » Tue Sep 27, 2022 10:31 am

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: show only some records on Xbrowse ( nRecords, year)

Postby Silvio.Falconi » 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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: show only some records on Xbrowse ( nRecords, year)

Postby Silvio.Falconi » Tue Sep 27, 2022 10:39 am

also some errors

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: show only some records on Xbrowse ( nRecords, year)

Postby Silvio.Falconi » Wed Sep 28, 2022 7:24 am

I found a solution!!
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: show only some records on Xbrowse ( nRecords, year)

Postby Antonio Linares » Wed Sep 28, 2022 6:24 pm

+1
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 86 guests