xsharp.eu • Problema con DBFNTX e GoTo
Page 1 of 1

Problema con DBFNTX e GoTo

Posted: Thu Mar 22, 2018 11:20 am
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

Problema con DBFNTX e GoTo

Posted: Thu Mar 22, 2018 1:54 pm
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

Problema con DBFNTX e GoTo

Posted: Thu Mar 22, 2018 2:52 pm
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