problemi con Append()

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

Moderator: wriedmann

User avatar
Gfb22
Posts: 105
Joined: Sat Oct 08, 2022 7:43 pm
Location: Italy

problemi con Append()

Post 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!
gfb
User avatar
wriedmann
Posts: 3765
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: problemi con Append()

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Gfb22
Posts: 105
Joined: Sat Oct 08, 2022 7:43 pm
Location: Italy

Re: problemi con Append()

Post 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
gfb
User avatar
Gfb22
Posts: 105
Joined: Sat Oct 08, 2022 7:43 pm
Location: Italy

Re: problemi con Append()

Post 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
gfb
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Re: problemi con Append()

Post 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
User avatar
robert
Posts: 4540
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: problemi con Append()

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
g.bunzel@domonet.de
Posts: 97
Joined: Tue Mar 01, 2016 11:50 am
Location: Germany

Re: problemi con Append()

Post 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
Last edited by g.bunzel@domonet.de on Mon Sep 25, 2023 8:20 am, edited 1 time in total.
User avatar
Gfb22
Posts: 105
Joined: Sat Oct 08, 2022 7:43 pm
Location: Italy

Re: problemi con Append()

Post 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
Attachments
Fatture Terzisti.prg.vimef.zip
(10.35 KiB) Downloaded 190 times
gfb
User avatar
Chris
Posts: 4936
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: problemi con Append()

Post 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?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
Gfb22
Posts: 105
Joined: Sat Oct 08, 2022 7:43 pm
Location: Italy

Re: problemi con Append()

Post 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 2089 times
and then this:
c2.jpg
c2.jpg (12.92 KiB) Viewed 2089 times
Grazie!
gfb
Attachments
Fatture Terzisti.prg.vimef.zip
(10.35 KiB) Downloaded 190 times
gfb
Post Reply