Carriage Return into a Memo...

I'm having a problem with Chr(13) in Memo...

I have a memo with the following code:
Prazo de Entrega: [CadProp."PrazoEntr1"]
                  [CadProp."PrazoEntr2"]
Condi?§?µes Pgto.: [CadProp."CondPag1"]
                 [CadProp."CondPag2"]
                 [CadProp."CondPag3"]
                 [CadProp."CondPag4"]
                 [CadProp."CondPag5"]

When the data fields CondPag2..5 aren't filleds, a not necessary line space is printed... The solution I found is to put a IIF function on each line... But, to do that, I must insert on the IIF a Chr(13)...

I tried that way:
Prazo de Entrega: [CadProp."PrazoEntr1"][IIF( <CadProp."PrazoEntr2"> <> '', Chr(13) + '                 ' + <CadProp."PrazoEntr2">, '' )]

And the same logic to the CondPag fields... But it shows the error "Invalid variant type conversion"... When I remove the "Chr(13)", there are no errors, but the data fields are printed in the same line...

Finally, how can I force a Carriage Return into IIF functions?

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 5:37PM
    here is an answer i posted in the newsgroup.

    modify lines in memo text object
    you can place each of these expressions in a memo
    I usually do this in an rtf memo
    [Customers."Company"]
    [Customers."Addr1"]
    [IIF(<Customers."Addr2">='',<Customers."City">,<Customers."Addr2">)]
    [IIF(<Customers."Addr2">='',<Customers."State">,<Customers."City">)]
    [IIF(<Customers."Addr2">='',<Customers."Zip">,<Customers."State">)]
    [IIF(<Customers."Addr2">='','',<Customers."Zip">,)]

    or in a plain text memo which you want to size
    set memos stretchmode to smactualheight and write code in obp of band or memo

    procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
    begin
    memo3.lines.clear;
    memo3.lines.add('[Customers."Company"]');
    memo3.lines.add('[Customers."Addr1"]');
    if (<Customers."Addr2"><>'') then memo3.lines.add('[Customers."Addr2"]');
    if (<Customers."City"><>'') then memo3.lines.add('[Customers."City"]');
    if (<Customers."State"><>'')then memo3.lines.add('[Customers."State"]');
    if (<Customers."Zip"><>'') then memo3.lines.add('[Customers."Zip"]');
    end;
    ;)
  • edited February 2005
    Hello!

    First, I want to thank you for the help...

    I tried the second solution, because it seems to be the best for this, but, I have a GREAT problem with the code in the Report... I never could use it...

    This time, it shows an error at line 3: Undeclared identifier "Lines"...

    I used the following code (OnBeforePrint of the Memo4):
        Memo4.Lines.Clear;
        Memo4.Lines.Add( 'Prazo de Entrega: [CadProp."PrazoEntr1"]' );
        If (<CadProp."PrazoEntr2"> <> '') Then
            Memo4.Lines.Add( '                  [CadProp."PrazoEntr2"]' );
        Memo4.Lines.Add( 'Condi?§?µes Pgto.: [CadProp."CondPag1"]' );
        If (<CadProp."CondPag2"> <> '') Then
            Memo4.Lines.Add( '                 [CadProp."CondPag2"]' );
        If (<CadProp."CondPag3"> <> '') Then
            Memo4.Lines.Add( '                 [CadProp."CondPag3"]' );
        If (<CadProp."CondPag4"> <> '') Then
            Memo4.Lines.Add( '                 [CadProp."CondPag4"]' );
        If (<CadProp."CondPag5"> <> '') Then
            Memo4.Lines.Add( '                 [CadProp."CondPag5"]' );
        If (<CadProp."PercEmb"> <> 0) Then
            Memo4.Lines.Add( 'Embalagem: ' + FormatFloat( '###,###,##0.00', <CadProp."PERCEMB"> ) + '%' );
        Memo4.Lines.Add( 'Local de Entrega: [CadProp."LOCALENTR1"]' );
        If (<CadProp."LocalEntr2"> <> '') Then
            Memo4.Lines.Add( '                  [CadProp."LOCALENTR2"]' );
        Memo4.Lines.Add( 'I.C.M.S. ' + IIF( <CadProp."IncIcm"> = 'I', 'Incluso', 'Excluso' ) + ': ' + FormatFloat( '###,###,##0.00', <CadProp."AliqIcm"> ) + '%' );
        Memo4.Lines.Add( 'Validade da Oferta: [CadProp."VALEDIAS"] dias' );
    
    Edited wrote:
    By the way, how can I join this newsgroup you said about?

    Best regards,
    Gabriel Frones
  • edited 5:37PM
    I could do it replacing "Lines" for "Memo"...

    Thank you for the help!!

    Best regards,
    Gabriel Frones

Leave a Comment