Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

How to add a string at the end of a memo line

edited November 2005 in General
... or at any lines !

Hi,

I try to do a simple thing :-)
AT RUNTIME, I construct a memo and add different information.
For some information I use

{add Name}
lsLine := qBordereauPrint.FieldByName('lblname').AsString;
// dans le SELECT il y a un blanc entre nom et pr?nom d'ou le test sur un
blanc
if lsLine <> ' ' then
ppMemoAdresse.Lines.Add(lsLine);

and it is nice as I want to add this on a new line.

BUT I want also to add a number of lines (for instance address) and just
after I want to add AT THE END OF THE LAST LINE the house number.
I can't use "+" with the two strings because the first one is a memo
(address) and the next one a simple string (house number)
Right now if I use the same code my house number is on the next line ....
grrrrrrrr

example:

I want

EXON
Ted BRUNER
Camelia street, 4

... I get

EXON
Ted BRUNER
Camelia street,
4

So simple but can't find the way.

Home some one can help,

Best regards

Pierre

Comments

  • edited November 2005
    use a TppJITPipeline and create your own string field. Populate a
    TStringList with the appropriate values and use the OnGetValue event.

    Ed Dressel
    Team DM
  • edited November 2005
    Hum hum ... a bit complicated to add a string at the end of a line no ?
    I have a "before print" event.
    Then I build a ppMemo (used in the report) to display the address.
    Everything is going well ... (I add a string, a memo, and an other string
    field in the ppMemo without problem) but for one line I need to add a string
    just after adding a line in the Memo.
    Isn't possible to that without the TstringList ?
    It seems to be possible with a standard vcl DBMemo.

    MyMemo.text := MyMemo.Text + MyDbField.Asstring;

    ... but doesn't work with a ppDbMemo. I have "MyDbField" on a new line and
    not at the end of the line.

    So for instance
    SiemensLann
    , 4

    and not
    SiemensLann, 4

    Do you thing "TstringList" is the only solution ? (I have to rewrite all my
    procedure :-(( )

    Regards

    Pierre


  • edited November 2005
    Hi Pierre,

    You could possibly determine how many lines are currently in the memo, then
    add your text to the last line. Something like the following...

    liCount := ppMemo1.Lines.Count;

    ppMemo1.Lines[liCount] := ppMemo1.Lines[liCount] + MyDbField.Asstring;

    Be sure you do not have any line breaking characters inside your db field.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2005
    Hi,

    that's a way. Thanks.
    You talk about "line breaking". That's may be my problem. I don't add any
    line breaking after adding a line or a memo (each are coming from db field)
    but may be there is a default one. Can I deal with that ?

    Thanks,

    Pierre

  • edited November 2005
    I try "exactly" the same and I receive "index out of bound" error !

  • edited November 2005
    Hi Pierre,

    Sorry, my posts are usually in psuedo code. TStringLists are 0 based lists.

    liCount := ppMemo1.Lines.Count;

    ppMemo.Lines[liCount - 1] := ppMemo.Lines[liCount - 1] + MyDbField.AsString;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2005
    Shame on me !
    I try it but I forget to do "minus 1" on the left side ;-)

  • edited November 2005
    Working !

This discussion has been closed.