FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour tdatabase class not working with memos
Posts: 107
Joined: Tue Sep 15, 2009 07:52 AM
tdatabase class not working with memos
Posted: Thu Oct 04, 2018 09: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 (fw): Select all Collapse
  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 (fw): Select all Collapse
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 (fw): Select all Collapse
 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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: tdatabase class not working with memos
Posted: Fri Oct 05, 2018 09: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
Posts: 107
Joined: Tue Sep 15, 2009 07:52 AM
Re: tdatabase class not working with memos
Posted: 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.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: tdatabase class not working with memos
Posted: Sat Oct 06, 2018 09: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

Continue the discussion