Problema con DBFNTX e GoTo

Forum dedicato ai programmatori di X# in lingua italiana – Italian language forum

Moderator: wriedmann

Post Reply
User avatar
gianluca.pinoli
Posts: 36
Joined: Mon Nov 02, 2015 1:13 pm
Location: Italy

Problema con DBFNTX e GoTo

Post by gianluca.pinoli »

Buongiorno a tutti,
testando del codice importato da un progetto scritto in VO mi sono imbattuto in uno strano problema.
Sembra che la SKIP eseguita dopo un GOTO non si posizioni sul record corretto ed esce subito dal ciclo.
se dopo o al posto del GOTO inserisco una SEEK che mi posiziona sullo stesso record indicato dal GOTO (il primo record della chiave di ricerca) il tutto funziona correttamente

L'indice viene creato in questo modo:
oReport:CreateIndex(WorkDir()+"REPORTX2.NTX",'IDREPORT+IDCASSA+DToS(DATA)')


Questa versione mi restituisce 1 record

WHILE oReport:FIELDGET(#IDREPORT)=='3' .and. oReport:FIELDGET(#IDCASSA)==sFascia
sCodRepa := AllTrim(oReport:FIELDGET(#CAMPO1))
sData := DToS( oReport:FIELDGET(#DATA) )

IF sData != sDataOLD
//LEGGO IL TOTALE DI GIORNATA
nRecNo := oReport:RecNo
oReport:Seek('39999'+sDataOLD)

WHILE oReport:FIELDGET(#IDREPORT)=='3' .and. oReport:FIELDGET(#IDCASSA)=='9999' .and. oReport:FIELDGET(#DATA)==SToD(sDataOLD)

IF oReport:FIELDGET(#CAMPO1) == "TOTALE GENERALE "
nTotaleIncasso := oReport:FIELDGET(#IMPORTO)
nTotaleClienti := oReport:FIELDGET(#CLIENTI)
nTotaleBattute := oReport:FIELDGET(#PEZZI)
ENDIF
oReport:Skip()
END
oReport:GoTo(nRecNo)

sDataOLD := sData
ENDIF

oDBFasce:Append()
oDBFasce:FIELDPUT(#ORARIO,oReport:FIELDGET(#CAMPO1))
oDBFasce:FIELDPUT(#INCASSO,oReport:FIELDGET(#IMPORTO))
oDBFasce:FIELDPUT(#INC_P,(oReport:FIELDGET(#IMPORTO)/nTotaleIncasso)*100.00 )
oDBFasce:FIELDPUT(#BATTUTE, oReport:FIELDGET(#PEZZI) )
oDBFasce:FIELDPUT(#INC_B, (oReport:FIELDGET(#PEZZI)/nTotaleBattute)*100.00 )
oDBFasce:FIELDPUT(#CLIENTI, oReport:FIELDGET(#CLIENTI) )
oDBFasce:FIELDPUT(#INC_C, (oReport:FIELDGET(#CLIENTI)/nTotaleClienti)*100.00 )
oDBFasce:FIELDPUT(#DATAMOV, DToS(oReport:FIELDGET(#DATA)) )

oReport:Skip()
END


Questa versione mi restituisce Tutti i records della Fascia oraria passata come parametro

WHILE oReport:FIELDGET(#IDREPORT)=='3' .and. oReport:FIELDGET(#IDCASSA)==sFascia
sCodRepa := AllTrim(oReport:FIELDGET(#CAMPO1))
sData := DToS( oReport:FIELDGET(#DATA) )

IF sData != sDataOLD
//LEGGO IL TOTALE DI GIORNATA
nRecNo := oReport:RecNo
oReport:Seek('39999'+sDataOLD)

WHILE oReport:FIELDGET(#IDREPORT)=='3' .and. oReport:FIELDGET(#IDCASSA)=='9999' .and. oReport:FIELDGET(#DATA)==SToD(sDataOLD)

IF oReport:FIELDGET(#CAMPO1) == "TOTALE GENERALE "
nTotaleIncasso := oReport:FIELDGET(#IMPORTO)
nTotaleClienti := oReport:FIELDGET(#CLIENTI)
nTotaleBattute := oReport:FIELDGET(#PEZZI)
ENDIF
oReport:Skip()
END
oReport:GoTo(nRecNo)

sDataOLD := sData
oReport:Seek('3'+sFascia+sDataOLD)


ENDIF

oDBFasce:Append()
oDBFasce:FIELDPUT(#ORARIO,oReport:FIELDGET(#CAMPO1))
oDBFasce:FIELDPUT(#INCASSO,oReport:FIELDGET(#IMPORTO))
oDBFasce:FIELDPUT(#INC_P,(oReport:FIELDGET(#IMPORTO)/nTotaleIncasso)*100.00 )
oDBFasce:FIELDPUT(#BATTUTE, oReport:FIELDGET(#PEZZI) )
oDBFasce:FIELDPUT(#INC_B, (oReport:FIELDGET(#PEZZI)/nTotaleBattute)*100.00 )
oDBFasce:FIELDPUT(#CLIENTI, oReport:FIELDGET(#CLIENTI) )
oDBFasce:FIELDPUT(#INC_C, (oReport:FIELDGET(#CLIENTI)/nTotaleClienti)*100.00 )
oDBFasce:FIELDPUT(#DATAMOV, DToS(oReport:FIELDGET(#DATA)) )

oReport:Skip()
END


Qualcuno ha un'idea di quello che sta succedendo?
Il tutto funziona correttamente in VO.

Saluti
Gianluca
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Problema con DBFNTX e GoTo

Post by Chris »

Hi Gianluca,

Yes, good catch, this is a bug in the NTX driver (and only it, works ok with CDX) of the vulcan runtime. It is strange, because all those years nobody had found/reported it when vulcan was still alive, but we found it last month while investigating a bug in ReportPro and now you also found it separately!

Unfortunately I don't think there's much we can do about it right now, apart from making sure we don't have a similar bug in our X# version of the NTX driver. As for workarounds, they only other I could think of (which has worked in RP, too), is to use a series of Skip() commands, instead of a GoTo(). Your solution with Seek() sounds good, too, if there's an appropriate index of course.

Btw, I think there's no reason really using NTX at all anymore, apart from sharing data with old apps that use NTX, too. For new or ported apps that are independant of the old versions, I would use CDX only.

Chris
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
gianluca.pinoli
Posts: 36
Joined: Mon Nov 02, 2015 1:13 pm
Location: Italy

Problema con DBFNTX e GoTo

Post by gianluca.pinoli »

Thanks Chris,
at the moment i'm still "playing" with XSharp only in spare time...
Your advise to move to CDX make sense... In VO i'm still using NTX only when i need to create index at runtime.

Regards
Gianluca
Post Reply