- Code: Select all Expand view RUN
- Function Locate_Records(anno1,anno2)
local aLocate:= {}
LOCAL nFirst,nLast
USE LOTTO ALIAS LOTTO
locate for year(LOTTO->data) = anno2
if (Found())
locate for year(LOTTO->data) != anno2 ;
next 60 // because once the extractions were 60
endif
if (Found())
nLast:= RecNo() - 1
else
nLast:= LastRec()
endif
locate for year(LOTTO->data) = VAL(anno1 )
if (!Found())
nFirst:= 1
else
nFirst:= RecNo()
endif
AaDd( aLocate,{nFirst,nLast,anno1, anno2})
XBROWSER aLocate
RETURN NIL
and it run ok as you can see here ( for a sample I seach the year 1946) I have the right record number ( column A)
If I select for another sample year 2009 I have the right record number ( column A) as you can see here
When I try to convert it with tdatabase it not run ok
- Code: Select all Expand view RUN
Function Locate_Records2(anno1,anno2)
local aLocate:= {}
LOCAL nFirst,nLast, oDbf
oDbf:= TDatabase():Open( ,"Lotto", "DBFCDX", .T. )
oDbf:setorder(1)
oDbf:gotop()
oDbf:Exec( < ||
locate for year(oDbf:data) = anno2
return FOUND()
> )
if (Found())
oDbf:Exec( < ||
locate for year(oDbf:data) != anno2 ;
next 60 // // because once the extractions were 60
return FOUND()
> )
endif
if (Found())
nLast:= oDbf:RecNo() - 1
else
nLast:= oDbf:LastRec()
endif
oDbf:Exec( < ||
locate for year(oDbf:data) = VAL(anno1 )
return FOUND()
> )
if (!Found())
nFirst:= 1
else
nFirst:= oDbf:RecNo()
endif
AaDd( aLocate,{nFirst,nLast,anno1, anno2})
XBROWSER aLocate
RETURN NIL
How I can resolve it ?
this is the test
- Code: Select all Expand view RUN
#include "fivewin.ch"
#include "Urllink.ch"
REQUEST HB_LANG_IT
REQUEST HB_CODEPAGE_ITWIN
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()
RETURN nil
//----------------------------------------------------------//
Function test()
local oDlg,oFont,oBold
local aGet:=array(10)
local oSay:=array(10)
local oScrollInizio
local bClick //action for urlink
local nRow:= 12
local ncol:= 10
local cTitle := "Impostazioni visualizzazione"
bClick := { | o | Locate_Records2(left(o:GetText(),4),2022) } //Locate_Records(left(o:GetText(),4),2022)
DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, 14
DEFINE FONT oBold NAME "MS Sans Serif" SIZE 0, 12 BOLD
DEFINE DIALOG oDlg ;
SIZE 500, 250 PIXEL TRUEPIXEL RESIZABLE ;
TITLE cTitle
@ nRow, ncol Say oSay[1] Prompt "Date predefinite " of oDlg SIZE 200,14 PIXEL FONT oBold
nRow+=20
@ nRow, nCol URLLINK oSay[2] OF oDlg PIXEL FONT oFont URL "1871 - Archivio Completo"
nRow+=20
@ nRow, nCol URLLINK oSay[3] OF oDlg PIXEL FONT oFont URL "1939 - Archivio a 10 Ruote"
nRow+=20
@ nRow, nCol URLLINK oSay[4] OF oDlg PIXEL FONT oFont URL "1946 - Estrazioni continue"
nRow+=20
@ nRow, nCol URLLINK oSay[5] OF oDlg PIXEL FONT oFont URL "2005 - Ruota Nazionale"
nRow+=20
@ nRow, nCol URLLINK oSay[6] OF oDlg PIXEL FONT oFont URL "2005 - Estrazioni trisettimanali"
nRow+=20
@ nRow, nCol URLLINK oSay[7] OF oDlg PIXEL FONT oFont URL "2009 - Estrazioni Automatizzate"
nRow+=40
@ nRow, ncol Say oSay[8] Prompt "Ultime estrazioni " of oDlg SIZE 200,14 PIXEL FONT oBold
nRow+=20
For n=2 to 7
oSay[n]:bAction = bClick
next
@ 100,10 BUTTON oBtnConfirm PROMPT "OK" of oDlg SIZE 80,22 DEFAULT ACTION ( oDlg:end( IDOK ) )
@ 100,10 BUTTON oBtnClose PROMPT "Annulla" of oDlg SIZE 80,22 CANCEL ACTION ( oDlg:end( IDCANCEL ) )
oDlg:bResized := <||
local oRect := oDlg:GetCliRect()
oBtnConfirm:nLeft := oRect:nRight - 200
oBtnConfirm:nTop := oRect:nBottom - 25
oBtnClose:nLeft := oRect:nRight - 100
oBtnClose:nTop := oRect:nBottom - 25
return nil
>
ACTIVATE DIALOG oDlg center
Return nil
Function Locate_Records(anno1,anno2)
local aLocate:= {}
LOCAL nFirst,nLast
USE LOTTO ALIAS LOTTO
locate for year(LOTTO->data) = anno2
if (Found())
locate for year(LOTTO->data) != anno2 ;
next 60 // PERCHè LE ESTRAZIONI ERANO 52
endif
if (Found())
nLast:= RecNo() - 1
else
nLast:= LastRec()
endif
locate for year(LOTTO->data) = VAL(anno1 )
if (!Found())
nFirst:= 1
else
nFirst:= RecNo()
endif
AaDd( aLocate,{nFirst,nLast,anno1, anno2})
XBROWSER aLocate
RETURN NIL
Function Locate_Records2(anno1,anno2)
local aLocate:= {}
LOCAL nFirst,nLast, oDbf
oDbf:= TDatabase():Open( ,"Lotto", "DBFCDX", .T. )
oDbf:setorder(1)
oDbf:gotop()
oDbf:Exec( < ||
locate for year(oDbf:data) = anno2
return FOUND()
> )
if (Found())
oDbf:Exec( < ||
locate for year(oDbf:data) != anno2 ;
next 60 // PERCHè LE ESTRAZIONI ERANO 52
return FOUND()
> )
endif
if (Found())
nLast:= oDbf:RecNo() - 1
else
nLast:= oDbf:LastRec()
endif
oDbf:Exec( < ||
locate for year(oDbf:data) = VAL(anno1 )
return FOUND()
> )
if (!Found())
nFirst:= 1
else
nFirst:= oDbf:RecNo()
endif
AaDd( aLocate,{nFirst,nLast,anno1, anno2})
XBROWSER aLocate
RETURN NIL