Inline formatting trouble

edited 8:15PM in FastReport 4.0
Hello

I have the following rather complex memo text:

Original number: [Abs(<frxDBDatasetIncome."gross_sum">)] [IIF(<frxDBDatasetIncome."exchange_rate">>1,' ( '+(FloatToStr(<frxDBDatasetIncome."gross_sum">/<frxDBDatasetIncome."exchange_rate">) +' ' + <frxDBDatasetIncome."currency">)+' )' ,'domestic' ) ]

So in the IIF the first part is a calculated number, and then comes the currency.
The problem is that this looks like e.g. 2500 (8,3333333333333 EURO)

I want the 8,3333333333333 to be 8,33 but if I put the %2.2f before the last bracket it doesn't dot anything (perhaps because there is also a string in the expression).
The following doesn't work:

Original number: [Abs(<frxDBDatasetIncome."gross_sum">)] [IIF(<frxDBDatasetIncome."exchange_rate">>1,' ( '+(FloatToStr(<frxDBDatasetIncome."gross_sum">/<frxDBDatasetIncome."exchange_rate">) +' ' + <frxDBDatasetIncome."currency">)+' )' ,'domestic' ) %2.2f]

Please help me if you can.

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 8:15PM
    why not try doing your calcs in the obp of the band rather than using the iif function in the memo
    and pass the whole string expression into the text of the band.
    memo1.text := 'sometext' +' ' +'[expressionwith formatstring]';
    it will then be calculated and formatted.
  • edited 8:15PM
    gordk wrote: »
    why not try doing your calcs in the obp of the band rather than using the iif function in the memo
    and pass the whole string expression into the text of the band.
    memo1.text := 'sometext' +' ' +'[expressionwith formatstring]';
    it will then be calculated and formatted.

    Thank you, I will try it. Mostly I try resolve the issues in the memo, because if I edit the report half a year later it is obvious what it does at first sight.
  • gordkgordk St.Catherines On. Canada.
    edited 8:15PM
    "and pass the whole string expression into the text of the band."
    Should have read
    and pass the whole string expression into the text of the memo.
    BTW you can comment your code in the report just as you can in delphi.
  • edited 8:15PM
    I'm a newbie in here, so this might not be correct... but shouldn't there be a '#n' in the format string when used inside the brackets? Like this:

    Original number: [Abs(<frxDBDatasetIncome."gross_sum">)] [IIF(<frxDBDatasetIncome."exchange_rate">>1,' ( '+(FloatToStr(<frxDBDatasetIncome."gross_sum">/<frxDBDatasetIncome."exchange_rate">) +' ' + <frxDBDatasetIncome."currency">)+' )' ,'domestic' ) #n%2.2f]

    I've never got it working without the #n.

    Petter

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.