Report with Code

edited 12:00PM in FastReport 4.0
Hello

I want the change the printed value of a field.
If the value is True I want to print 'Yes'.
I try to change on Delphi code on the OnGetText event but it doesn't have impact on the report.
I change the FastReport code on OnBeforePrint field event.
If i run the report from the designer it appear as expect but if I run the report from the program
it's has no impact.

What I'm missing?
Sorin

Comments

  • gpigpi
    edited 12:00PM
    Use IIF function
  • edited 12:00PM
    gpi wrote: »
    Use IIF function

    Thanks but IIf function raise an error.
    I use PascalScript
  • edited 12:00PM
    sorinh wrote: »

    Thanks but IIf function raise an error.
    I use PascalScript
    The IFF function can be sometimes be tricky. Write appropriate code in the script.
  • edited 12:00PM
    [/quote]
    The IFF function can be sometimes be tricky. Write appropriate code in the script.
    [/quote]

    I use the basic sintax
    "iif(<frdbBillB."Pay"> = True, frdbBillBPay.Text := 'Yes', frdbBillBPay.Text := 'No');"
    It's raise the error ')' expected?

  • edited 12:00PM
    sorinh wrote: »
    I use the basic sintax
    "iif(<frdbBillB."Pay"> = True, frdbBillBPay.Text := 'Yes', frdbBillBPay.Text := 'No');"

    The IIF can be used in the MemoView, not in event script.

    In the memo you can put something like:
    [iif(<frdbBillB."Pay"> = True, 'Yes', 'No')]

    Or if you want to use pascal code in script, you should try:

    procedure MyMemoOnAfterData(Sender: TfrxComponent);
    begin
    if <frdbBillB."Pay"> = True then
    TFrxMemoView(sender).Text := 'Yes'
    else TFrxMemoView(sender).Text := 'No';
    end;

  • edited 12:00PM
    Thanks
  • edited 12:00PM
    sorinh wrote: »
    I use the basic sintax
    "iif(<frdbBillB."Pay"> = True, frdbBillBPay.Text := 'Yes', frdbBillBPay.Text := 'No');"
    It's raise the error ')' expected?
    Exactly. I said tricky but read it as prone to producing error messages for no apparent reason.
    Even building the expression using the expression builder sometimes cannot get the simplest expression to work.

Leave a Comment