FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour locate with Tdatabase
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
locate with Tdatabase
Posted: Fri Nov 15, 2024 08: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



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



I set the interval of years I made
Code (fw): Select all Collapse
#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 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

Continue the discussion