Recent

Author Topic: Strange square characters at end of TDBMemo?  (Read 5457 times)

bill0287

  • Full Member
  • ***
  • Posts: 146
Strange square characters at end of TDBMemo?
« on: December 13, 2013, 07:54:13 pm »
I have a TDBMemo tied to a TMemoField in a TDBF.

At the end of the memo are two square characters. I can delete them, post the data, but they always come back.  Is there something I can do to prevent this?

Lazarus 1.0.14
FPC 2.6.2
SVN 43446
Win32 XP

 
« Last Edit: December 13, 2013, 08:57:31 pm by bill0287 »

mica

  • Full Member
  • ***
  • Posts: 196
Re: Strange square characters at end of TDBMemo?
« Reply #1 on: December 13, 2013, 08:40:26 pm »
Lazarus version?
OS?

Looks like an Unicode/ANSI/whatever encoding problem

bill0287

  • Full Member
  • ***
  • Posts: 146
Re: Strange square characters at end of TDBMemo?
« Reply #2 on: December 13, 2013, 08:57:40 pm »
added above

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Strange square characters at end of TDBMemo?
« Reply #3 on: December 13, 2013, 11:01:37 pm »
Why don't you try to see what their values are?

I guess it is a LineEnding. If I'm correct you should get #13#10.

bill0287

  • Full Member
  • ***
  • Posts: 146
Re: Strange square characters at end of TDBMemo?
« Reply #4 on: December 13, 2013, 11:08:37 pm »
Unfortunately, I don't know how to do that. I just start typing in the DBMemo, post it, and then when I return to the record, there they are.

It's even worse than I thought. I do the same thing in another record's DBMemo, and that text new appends in some of the other records too.  I have no coding in this form...I am just connecting up Data Aware components.

I attached a simple test that shows DBMemo is all over the place in this case.
« Last Edit: December 14, 2013, 04:40:25 am by bill0287 »

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Strange square characters at end of TDBMemo?
« Reply #5 on: December 13, 2013, 11:26:25 pm »
TDBMemo is a descendent of TCustomMemo, meaning that it has both Lines and Text:

Assuming you have a TButton named Button1 and a TDBMemo named DBMemo1. Use the following code:

Code: [Select]
function GetMeLastTwoChars(SomeStr: String): String;
var
  L: Integer;
begin
  L := Length(SomeStr);
  if L>1 then
    Result := Format('#%d, #%d',[Ord(SomeStr[L-1]), Ord(SomeStr[L])])
  else
    Result := 'Less than two chars!';
end;

procedure TMainForm.Button1Click(Sender: TObject);
begin
  ShowMessage('Text: ' + GetMeLastTwoChars(DBMemo1.Text));
  ShowMessage('Line[0]: ' + GetMeLastTwoChars(DBMemo1.Lines[0]));
end;

bill0287

  • Full Member
  • ***
  • Posts: 146
Re: Strange square characters at end of TDBMemo?
« Reply #6 on: December 14, 2013, 04:29:51 am »
If I did this right I got back this:

Text: #32,#32
Line[0]:#32,#32

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Strange square characters at end of TDBMemo?
« Reply #7 on: December 14, 2013, 05:14:33 am »
I did not notice that you had attached a sample project. I tried it and did not see the problem. I'm using Lazarus 1.1, Rev: 41139 with FPC 2.7.1

My opinion it's a bug that got solved added.
« Last Edit: December 14, 2013, 05:26:04 am by engkin »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Strange square characters at end of TDBMemo?
« Reply #8 on: December 14, 2013, 07:43:10 am »
I used to have this "issue" in my college's lab 5-6 years ago which I can't reproduce in my desktop at home. It also only happens on several computers, not all. Since the lab maintainer upgraded the OS to Win 7, it no longer appears. I think it's related to certain Windows configuration that displays space characters instead of hiding it.

bill0287

  • Full Member
  • ***
  • Posts: 146
Re: Strange square characters at end of TDBMemo?
« Reply #9 on: December 14, 2013, 11:34:19 pm »
FYI.

I tested with Level IV DBf tables and the errors were gone. It seems to be related to level III tables.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Strange square characters at end of TDBMemo?
« Reply #10 on: December 15, 2013, 12:10:39 am »
Thanks for letting us know. I was digging in the source code trying to figure out possible reasons.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Strange square characters at end of TDBMemo?
« Reply #11 on: December 15, 2013, 04:04:46 am »
FYI.

I tested with Level IV DBf tables and the errors were gone. It seems to be related to level III tables.
FYI,
Bill raised bug report
http://bugs.freepascal.org/view.php?id=25422

As he indicated, the issue is DBase III specific but is solved in FPC fixes 2.6, and FPC trunk/2.7.1.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018