tdatabase class not working with memos

tdatabase class not working with memos

Postby ellano » Thu Oct 04, 2018 9:53 am

Using FiveWin 18.07: one of my client reports that the program is not allowing to save data as usual (program previously compiled and worked correctly several years using version 14.04)

Further investigation narrowed the problem on the Tdatabase class:

While saving on a Memo field:

Code: Select all  Expand view
 prov:=""
  FOR i:=1 TO 6
     prov+=PADR(ALLTRIM(fill_in[i+236]),84)
  NEXT i
  msgstop(len(prov))  //504 as it should be
  oDbf:trincheras:=prov
  msgstop(len(oDbf:trincheras))  //still says 504 OK
  ....  //continue with other Memo fields
  prov:=""
  FOR i:=1 TO 6
     prov+=PADR(ALLTRIM(fill_in[i+242]),84)
  NEXT i
...


 


No apparent problem here, but the surprise comes when recovering the same field latter on:

Code: Select all  Expand view
msgstop(len(oDbf:trincheras))  //7 since the user choose to fill-in only seven space (correct), but, Where are my 504 characters saved? Field have been trimmed
FOR i:=1 TO 6
  fill_in[i+236]:=SUBSTR(oDbf:trincheras,(i-1)*84+1, 84)
NEXT
msgstop(len(fill_in[237])) //still 7 since field has been trimmed unexpectedly
...
//same for ALL other memo fields


Fixed provisionally with an ending character like this, but this was not planned at all :(

Code: Select all  Expand view
prov:=""
  FOR i:=1 TO 6
     prov+=PADR(ALLTRIM(fill_in[i+236]),84)
  NEXT i
  oDbf:trincheras:=prov+"^"  //mark end of field
  msgstop(len(oDbf:trincheras)) //now we have 505 characters
  prov:=""
  FOR i:=1 TO 6
     prov+=PADR(ALLTRIM(fill_in[i+242]),84)
  NEXT i
  oDbf:mediospase:=prov +"^"
...
//recover
msgstop(len(oDbf:trincheras))  //505 (forced by me)
FOR i:=1 TO 6
  fill_in[i+236]:=SUBSTR(oDbf:trincheras,(i-1)*84+1, 84)
NEXT
msgstop(len(fill_in[237])) //now, 84 (user is happy again) only problem is that he has to go though all 7000 registers and save all of them to fix this. Now he is not happy at all (neither do I)

 


Is there a simple fix modifying something on the TDataBase class?

Thanks
Emiliano Llano Díaz
ellano
 
Posts: 107
Joined: Tue Sep 15, 2009 7:52 am

Re: tdatabase class not working with memos

Postby nageswaragunupudi » Fri Oct 05, 2018 9:45 am

TDatabase trims values while saving to memo fields.
Do you not want to trim the values while saving?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: tdatabase class not working with memos

Postby ellano » Sat Oct 06, 2018 10:39 am

The old behavior while using this class was saving what it was told without further, hidden, actions.
It is a little confusing not finding what it has been saved on the field (even while sometimes, I must confess, is somewhat unnecessary saving extra spaces at the end of a string).

Now I am not even sure if this behavior is the "norm" even with string fields or not :?:

As I wrote in my previous post, I "repair" it adding an extra character at the end of the string.
ellano
 
Posts: 107
Joined: Tue Sep 15, 2009 7:52 am

Re: tdatabase class not working with memos

Postby nageswaragunupudi » Sat Oct 06, 2018 9:08 pm

We modified database.prg to resolve the issue.

Please send me an email to the address:
nageswaragunupudi [at] gmail [dot] com

We will send you revised libraries incorporating the modifications and modified database.prg. You may use these revised libraries.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: russimicro and 65 guests