probabilmente in clipper 87 non si usavano ancora i cdx e quindi facevamo tutto in sequelziale
e quindi con il comando locate for, vi ricordate qualcosa ?
Code: Select all | Expand
anno1:= "1939" anno2:= "1999" set color to GR+/N @ 22, 15 say "ANNO INIZIALE:" get ANNO1 picture "9999" @ 22, 48 say "ANNO FINALE:" get ANNO2 picture "9999" read if (Val(anno1) > Val(anno2)) break endif locate for SubStr(settimana, 10, 2) = SubStr(anno2, 3, 2) if (Found()) locate for SubStr(settimana, 10, 2) != SubStr(anno2, 3, 2) ; next 60 endif if (Found()) ultimo:= RecNo() - 1 else ultimo:= LastRec() endif locate for SubStr(settimana, 10, 2) = SubStr(anno1, 3, 2) if (!Found()) __dbgotop() endif primo:= RecNo()
Adesso ho provato a non usare locate e fare un filtro
Code: Select all | Expand
#include "FiveWin.ch"REQUEST DBFCDXFunction test()Local oDlg,oFontlocal nYear1:= 1939,nYear2:= 2022local aRecords:= {} DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, 8 DEFINE DIALOG oDlg FROM 100, 100 TO 230,376; TITLE "Selection year" PIXEL FONT oFont @ 12, 10 SAY "From year:" OF oDlg SIZE 17, 8 PIXEL FONT oFont @ 10, 47 GET nYear1 OF oDlg SIZE 44, 12 PIXEL FONT oFont picture "9999" @ 26, 10 SAY "to year" OF oDlg SIZE 32, 8 PIXEL FONT oFont @ 24, 47 GET nYear2 OF oDlg SIZE 44, 12 PIXEL FONT oFont picture "9999" @ 46, 48 BUTTON oBtn PROMPT "Conferma" OF oDlg SIZE 42, 12 PIXEL FONT oFont DEFAULT ACTION ( oDlg:end( IDOK ) ) @ 46, 92 BUTTON oBtn PROMPT "Annulla" OF oDlg SIZE 42, 12 PIXEL FONT oFont CANCEL ACTION ( oDlg:end( IDCANCEL ) )ACTIVATE DIALOG oDlg CENTERED IF oDlg:nresult == IDOK if ((nYear1) > (nYear2)) return nil endif arecords:= Locate_Records(nYear1,nYear2) xbrowser aRecords Endifreturn nil//----------------------------------------------------//Function Locate_Records(nYear1,nYear2) local oDbf,nFirst,nLast local aLocate:= {} local cFilter1,cFilter2//---------------------------------------------------------// oDbf:= TDatabase():Open( ,"Lotto", "DBFCDX", .T. ) oDbf:setorder(1) oDbf:gotop()//---------------------------------------------------------// cFilter1 := "ltrim(str(year(data))) == '" + ltrim(str(nYear1)) +"'" cFilter2 := "ltrim(str(year(data))) == '" + ltrim(str(nYear2)) +"'" oDbf:setFilter(cFilter2) oDbf:gotop() If year(odbf:data) = nYear2 nLast:= oDbf:recno() - 1 else nLast:= LastRec() endif oDbf:clearFilter() oDbf:setFilter(cFilter1) oDbf:gotop() If year(odbf:data) = nYear1 nFirst:= oDbf:recno() - 1 else nFirst:= 1 endif oDbf:close() AaDd( aLocate,{nFirst,nLast}) return aLocate
secondo voi potrebbe girare bene ?