xsharp.eu • problemi con Append()
Page 1 of 3

problemi con Append()

Posted: Fri Sep 22, 2023 5:34 am
by Gfb22
Ho una finestra che immette i dati in una DataBrowser.
Terzisti.jpg
Quando registro i dati la procedura inserisce il nuovo record che viene visualizzato nella DataBrowser. La finestra di edit rimane attiva per i successivi inserimenti. Già al secondo inserimento il programma si arresta a lungo dopo il comando append() che non viene eseguito e, quindi dopo un'attesa di decine di secondi, sovrascrive l'ultimo record aggiunto.
In VO funziona tutto bene: il problema si presenta solo in #X.
Ecco la porzione di codice che genera l'errore.

Code: Select all

		IF self:lAggiungi		// Append
InfoMsg("Append", self)	// Messo per debug: il problema è dopo questo stop
			self:oTabReg:Append()	// FileLock è automatico durante l'operazione di Append
		ELSE
			self:oTabReg:GoTo(self:nRec)	// siamo sicuri che è il record corretto..
		ENDIF
		IF self:oTabReg:RLOCK()		// Blocco del record riuscito: REGISTRA i dati
			self:oTabReg:T_Data		:= self:SLE0_Data
			self:oTabReg:t_socio		:= ""
			self:oTabReg:T_COLTURA	:= ""
			self:oTabReg:T_CATEG	:= "20"
			self:oTabReg:t_terz		:= self:cTerzista
			self:oTabReg:T_DESCRI	:= self:SLE1_Des
			self:oTabReg:T_Quant	:= self:nNewQ
			self:oTabReg:t_rif		:= self:CBLTerzi
			self:oTabReg:T_ANT		:= "N"
			self:oTabReg:T_PREZZE	:= self:SLE3_Prezzo
			self:oTabReg:T_IMPORTE	:= IEuro
			self:oTabReg:T_QUAD	:= "ZZZZZ"
			self:oTabReg:T_MAG		:= "GAIA"
			self:oTabReg:T_SECONDI	:= PadL(int(Seconds() ), 5, "0")   // Secondi dalla mezzanotte, per alcuni Index cronologico inserimento
			self:oTabReg:Unlock()
			self:oTabReg:Commit()
		ELSE
			InfoMsg("Server occupato: registrazione non effettuata.", self)
		ENDIF
Cosa potrebbe essere la causa?
Grazie!

Re: problemi con Append()

Posted: Fri Sep 22, 2023 6:21 am
by wriedmann
Ciao Gian Ferruccio,
prima cosa: sia Append() che Goto() ritornano un valore logico se avevano successo o meno - e quello dovrebbe essere sempre controllato.
Se Append() fallisce, sei tu che invece a ritornare un errore sovrascrivi un altro record.
seconda cosa: che versione di X#?
Saluti
Wolfgang

Re: problemi con Append()

Posted: Fri Sep 22, 2023 7:46 am
by Gfb22
Buongiorno Wolfgang,
Metto un controllo per intercettare il ritorno da Append(), che comunque impiega troppo tempo! ..Che sia anche RLock() che, in effetti, in questo contesto non serve...
La versione di XIDE è la 2.17.
Grazie e questa sera riprovo.
gfb

Re: problemi con Append()

Posted: Fri Sep 22, 2023 12:26 pm
by Gfb22
..Provato e modificato anche indice ma il risultato è lo stesso.
Con il controllo su Append() almeno non mi sovrascrive i dati...
Faccio altre prove e se qualcuno ha un idea...
Grazie!
Terzisti2.jpg

Re: problemi con Append()

Posted: Fri Sep 22, 2023 7:49 pm
by ic2
Ciao Gian Ferruccio,

Could it be the anti virus program? Can you try it without to check? And can also try to rename the CDX file and see if it goes faster without indexes (which could point to many duplicate keys or very large fields in the index).

Dick

Re: problemi con Append()

Posted: Sat Sep 23, 2023 6:32 am
by robert
Gian Ferrucio,

Unfortunately your code is not complete and leaves some questions open:
- Is there an index scope active, or does the index have a condition?
- Is the same server used by the browser?
- Did you suspend notification on the server?

If the same server is used also by the browser, and if the notification is not suspended, then the browser will repaint and move the record pointer away from the new blank record. I can imagine that when the blank record does not fall in the index scope or does not fulfill the index condition, that a refresh of the browser could cause some problems.

Robert

Re: problemi con Append()

Posted: Sat Sep 23, 2023 10:34 am
by g.bunzel@domonet.de
Hi Gian Ferruccio,

the file is locked after your :Append(). The following RLock() can not work after that :Append().

I would try this:

self:oTabReg:Append(TRUE)


and first a Commit() and then Unlock():

self:oTabReg:Commit()
self:oTabReg:Unlock()

That should work.

Best regards.
Gerhard

Re: problemi con Append()

Posted: Sun Sep 24, 2023 8:20 pm
by Gfb22
Hi Robert,
"Unfortunately your code is not complete and leaves some questions open:
- Is there an index scope active, or does the index have a condition?
---> The CDX index has several orders but the active one has no conditions and no scope;
- Is the same server used by the browser?
---> No, it's the same DBF file but opened with distinct objects: one is just for recording data and the index has natural order --> self:oTabReg:SetOrder( 0 )
- Did you suspend notification on the server?"
---> Yes: there is
self:Owner:oSFFTTDetail:Browser:SuspendUpdate() before append() and
self:Owner:oSFFTTDetail:Browser:RestoreUpdate() after.
I attach the code of the module that gives the error.
In VO everything works.
thanks for the tips!
gfb

Re: problemi con Append()

Posted: Mon Sep 25, 2023 6:20 am
by Chris
Hi Gian,

Unfortunately the code is very incomplete, it misses the code for SubBrowseTerzisti and TERZISTI and cannot be compiled (so it can be tested) of course.

Can you please provide a full compilable and runnable sample showing the problem, together with all data file needed?

Re: problemi con Append()

Posted: Mon Sep 25, 2023 9:00 am
by Gfb22
Hi Chris,
you're right: here's the code with the subBrowseWin too.
I'll send you an email with the archives to try: if you compile the program, you can try this:
C1.jpg
C1.jpg (25.07 KiB) Viewed 1582 times
and then this:
c2.jpg
c2.jpg (12.92 KiB) Viewed 1582 times
Grazie!
gfb