Printing 3 edits controls with CRLF

Leo BidiLeo Bidi Montevideo, Uruguay
edited 3:31AM in FastReport VCL 5
Hi all.

I need to print a variable's report with the values of 3 edits controls value, but these controls may or may not have values inside and if they have need to put CRLF
between them.

Example:

1 ) edit1.text = '', edit2.text = '', edit3.text = '', then there is nothing to print
2 ) edit1.text = 'AA', edit2.text = '', edit3.text = '' then only prints 'AA'
3 ) edit1.text = 'AA', edit2.text = 'BB', edit3.text = 'CC' then need to print
AA
BB
CC

no matther the combination of the edits values, I need to print a CRLF between the edits

My code is this
cComent := '';

if edit1.Text <> '' then
   cComent := Edit1.Text + #13#10; 

if edit2.Text <> '' then
   cComent := cComent + edit2.Text + #13#10; 

if edit3.Text <> '' then
   cComent := cComent + edit3.Text;

Report.Variables['Coment'] := '' + cComentario + ''

What am I missing or doing wrong ?? I am very confused with the quotes [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> Many thanks !!![/img]

Comments

  • gpigpi
    edited 3:31AM
    Use script variable
    frxReport1.Script.Variables['Coment'] := cComentario;
    
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 3:31AM
    Thanks gpi for the answer , I've tried as you've mentioned but nothing was printed and 2 of 3 edits have text values on them.

    Does need any quotedstr() function in any of the edits ??
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 3:31AM
    Any other idea please ??
  • gpigpi
    edited 3:31AM
    Test project to support@fast-report.com please
  • Leo BidiLeo Bidi Montevideo, Uruguay
    edited 3:31AM
    Thank you gpi, I've resolved it this way.
        cComent := '';
    
        if edt_Coment.Text <> '' then
                cComen := cComent + edt_Coment.Text + #13#10;
    
        if edt_Payment.Text <> '' then
                cComent := cComent + edt_Payment.Text + #13#10;
    
        if edt_Env.Text <> '' then
            cComent := cComent + edt_Env.Text + #13#10;
    
        if cComent = '' then
            Report.Variables['Coment'] := '''' + cComent + ''''
        else
            Report.Variables['Coment'] := cComent;
    
  • LurkingKiwiLurkingKiwi Wellington, New Zealand
    edited 3:31AM
    There is something funny about the way FR handles variables - it has come up before. They appear to be more like script insertions.
    The documentation states that you must put quotes around the variables CONTENTS else it will be processed recursively like script.
    It also says you shouldn't have CRLFs in the value, but it works if the outer quotes are omitted.
    To set a variable to an empty string you have to use 6 singles quotes ('''''') in Delphi.
    See:
    http://www.fast-report.com/en/forum/?p=/discussion/comment/35768

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.