locate with Tdatabase

locate with Tdatabase

Postby Silvio.Falconi » Fri Nov 15, 2024 8:48 am

I must found two number of record on archive

I wish found the first( primo) and the last ( ultimo) on a Interval of years

the records go from 1871 to 2024 and there are 10538 records

Image

the fourth parameter is not true as it should be 3549 as you can see here

Image

I set the interval of years I made

Code: Select all  Expand view

#include "FiveWin.ch"

REQUEST DBFCDX

Function SetAnno()
    LOCAL aSetAnno := {}
    LOCAL primo, ultimo, ntotali_records
    LOCAL oDbf
    LOCAL nAnno1 := "1939"
    LOCAL nAnno2 := LTrim(Str(Year(Date())))  // year now

    // Apre il database
    oDbf := TDatabase():Open( , "Lotto", "DBFCDX", .T. )
   
    IF oDbf == NIL
        MsgInfo("Errore nell'aprire il database!", "Errore")
        RETURN NIL
    ENDIF


    oDbf:SetOrder(1)
    oDbf:GoTop()

     Select( oDbf:nArea )  // for use locate


    ntotali_records := oDbf:OrdKeyCount()


    LOCATE FOR Year(oDbf:data) = Val(nAnno2)
    oDbf:load()
    IF oDbf:Found()

        LOCATE FOR Year(oDbf:data) != Val(nAnno2)
        IF oDbf:Found()
            ultimo := oDbf:RecNo() - 1
        ELSE
            ultimo := oDbf:LastRec()
        ENDIF
    ELSE
        ultimo := oDbf:LastRec()
    ENDIF


    LOCATE FOR Year(oDbf:data) = Val(nAnno1)
    oDbf:load()
    IF oDbf:Found()
        primo := oDbf:RecNo()
    ELSE
        primo := 1
    ENDIF


    AAdd(aSetAnno, {nAnno1, nAnno2, ntotali_records, primo, ultimo})


    XBrowser aSetAnno


    oDbf:End()

    RETURN NIL
 



give me allways the first record of archive (1871) and not the first of 1939

how I can resolve ?
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: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 23 guests