FR4 IIF Error "Identifier expected"

edited 8:18AM in FastReport 4.0
Hi All,

I try to use IIF on a Memo Field to display a field value or a string.

The Expression I use is:

[IIF([frxAuftrag."BESTELLPREIS"] = -1,,[frxAuftrag."BESTELLPREIS"])]

It should print the string '-/-' it the field value is -1.

When I try to run the report, it stops with the error "Identifier expected".

I already tried using <> and [] as delimiters. Exchanged true and false values. No change.

Is there some help about using the expressions on Fields?
Or is there an example report where I can find it?

Or does anyone advise me how to do it right?

TIA Rolf

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 8:18AM
    bad syntax.
    should be
    [IIF(<frxAuftrag."BESTELLPREIS"> = -1),'-/-',<frxAuftrag."BESTELLPREIS">]
  • edited 8:18AM
    gordk wrote: »
    bad syntax.
    should be
    [IIF(<frxAuftrag."BESTELLPREIS"> = -1),'-/-',<frxAuftrag."BESTELLPREIS">]

    Thank you.

    Tried, but now the exception is: ';' expected.

    inside the expression and at the end doesn't help.

    Any idea?

    TIA Rolf
  • edited 8:18AM
    Over time I have found that the memo IIF() can be troublesome. Even building the expression via selection of function and fields in the editor instead of typing it, there were cases where I was unable to create an expression which worked, no matter what I tried. I think there is a bug which rears its head once in a while.
    Nowadays, when that happens I write the equivalent expression in the script. This is IMO also more readable, but it means that one must at least have the Standard edition of FR.
  • edited 8:18AM
    technisoft wrote: »
    Over time I have found that the memo IIF() can be troublesome. Even building the expression via selection of function and fields in the editor instead of typing it, there were cases where I was unable to create an expression which worked, no matter what I tried. I think there is a bug which rears its head once in a while.
    Nowadays, when that happens I write the equivalent expression in the script. This is IMO also more readable, but it means that one must at least have the Standard edition of FR.


    How would I do this in a script?
    I have the appropriate version, but never installed Scripting.
    Could you please outline (short) how to do an IIF in script?
    (not the symtax but more how to get the script into the report)

    TIA
    Rolf
  • edited October 2012
    Rolf wrote: »
    Rolf wrote: »
    Over time I have found that the memo IIF() can be troublesome. Even building the expression via selection of function and fields in the editor instead of typing it, there were cases where I was unable to create an expression which worked, no matter what I tried. I think there is a bug which rears its head once in a while.
    Nowadays, when that happens I write the equivalent expression in the script. This is IMO also more readable, but it means that one must at least have the Standard edition of FR.

    I tried this:
    selected the Memofield in Question,
    went to the "code" page of the reportdesigner,
    entered the following code:

    begin
    if <frxAuftrag."BESTELLPREIS"> = -1 then
    '-/- '
    else <frxAuftrag."BESTELLPREIS">;
    end.

    run the report,
    get the errormessage : "Script Error at 3:3:';' expected.

    Changed the code to :

    begin
    if <frxAuftrag."BESTELLPREIS"> = -1 then
    ;'-/-'
    else <frxAuftrag."BESTELLPREIS">;
    end.

    run the report,
    get the same errormessage : "Script Error at 3:3:';' expected.

    changed code to:

    begin
    if <frxAuftrag."BESTELLPREIS"> <> -1 then
    <frxAuftrag."BESTELLPREIS">;
    end.

    run the report,
    get the same errormessage : "Script Error at 3:1:';' expected.

    I don't quite understand the logic in this.
    I changed the code according to the error message some times more according to the error messages.
    The report engine (?) expects a ';' before the "true" expression, even if there are already 1 or more.
    So it looks like it can not read the code correct.

    Any ideas?

    TIA Rolf
  • gordkgordk St.Catherines On. Canada.
    edited 8:18AM
    begin
    if <frxAuftrag."BESTELLPREIS"> = -1 then
    '-/- ' \\ i expect this string is what is causing the problem in any code written

    else <frxAuftrag."BESTELLPREIS">;
    end.

    run the report,
    get the errormessage : "Script Error at 3:3:';' expected

    since i see a period after end it appears you have written this code in the empty begin end block of the code page instead of associating the code to and event of a band or memoview.


    begin
    if <frxAuftrag."BESTELLPREIS"> = -1 then
    begin
    memoname.allowexpressions := false;
    memoname.memo.text= '-/- ';
    end
    else
    begin
    memoname.allowexpressions := true;
    memoname.memo.text :=[frxAuftrag."BESTELLPREIS"]
    end;


    if you are going to use the script do it in the obp event of the band rather then in the obp of the memo.
    then you can set the memoview's memo.text property.
  • edited 8:18AM
    gordk wrote: »
    begin
    if <frxAuftrag."BESTELLPREIS"> = -1 then
    '-/- ' \\ i expect this string is what is causing the problem in any code written

    else <frxAuftrag."BESTELLPREIS">;
    end.

    run the report,
    get the errormessage : "Script Error at 3:3:';' expected

    since i see a period after end it appears you have written this code in the empty begin end block of the code page instead of associating the code to and event of a band or memoview.


    begin
    if <frxAuftrag."BESTELLPREIS"> = -1 then
    begin
    memoname.allowexpressions := false;
    memoname.memo.text= '-/- ';
    end
    else
    begin
    memoname.allowexpressions := true;
    memoname.memo.text :=[frxAuftrag."BESTELLPREIS"]
    end;


    if you are going to use the script do it in the obp event of the band rather then in the obp of the memo.
    then you can set the memoview's memo.text property.

    Works perfect

    (a last "end;" is missing)

    Thank you very much.

    Rolf
  • edited 8:18AM
    Hi All,

    the solution from the FR Support:

    [IIF(<frxAuftrag."BESTELLPREIS"> = -1,'-/-',<frxAuftrag."BESTELLPREIS">)]

    works fine.

    Rolf

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.