Variable in MemoView

BJLBJL Brussels, Belgium
edited 10:20AM in FastReport 3.0
In BCB code, a variable and its value have been added to the report. Its name is EXERCICE. Before calling PrepareReport, this value has been checked in BCB code.

In the design, a MemoView named MemoExer contains only [EXERCICE].

I get the following error:

MemoExer: Error in expression 'Exercice 2004 ??? 30 octobre 2004':
';' expected'. Process stopped...

I never had such problem in FR 2.53. Any idea?

BJL

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 10:20AM
    Here is a sample in delphi
    you'll have to translate to bcb

    edit1.text contains Exercice 2004 ??? 30 octobre 2004
    loading into variable at start

    procedure TForm1.Button4Click(Sender: TObject);
    begin

    frxReport3.LoadFromFile('MyReport.fr3');
    frxReport3.Variables:= ''''+EDIT1.TEXT+'''';
    frxReport3.SHOWReport;

    end;

    loading into variable in ogv event either syntax below can be used.
    procedure TForm1.frxReport3GetValue(const VarName: String;
    var Value: Variant);
    begin

    //if varname = 'EXERCICE' then value := 'Exercice 2004 ??? 30 octobre 2004';
    //if varname = 'EXERCICE' then value := EDIT1.TEXT;
    end;

  • BJLBJL Brussels, Belgium
    edited 10:20AM
    Thank you Gord,

    What you indicate is quite similar of what I read on page 34 of the programmer's manual. You should however clearly indicate if you use 4 single quotes or 2 double quotes. Unfortunately, this manual is 100% Delphi. The problems to convert to BCB occure often with the Variant type and with the single quote. In BCB single quote are normally translated to double quotes. For example, in FR 253 I could write
    frVariables->Variable["EXERCICE"] = Edit->Text;
    the equivalent in FR3 should be
    frxReport1->Variables["EXERCICE"] = Edit->Text;

    For an unknown reason, this does not work. It seems that FR3 expects an Integer index instead of "EXERCICE", so not looking for an existing variable and not adding the variable if it does not exist.

    I turn around the problem in setting a function which checks if the variable exists (with IndexOf), and in that case updates it, or add the new variable using AddVariable. To be sure of a good performance of this procedure, after setting each variable form BCB, I check it, reading it back in BCB by finding its index and the corresponding value. I can see that the value is identical to the value set. Surprinsingly however I got the error message mentionned previously saying that ";" was expected.
    On another Memo containing NEXTLASTPAGE] + [PAGE#, which works well in FR 253, I got a similar error message saying that "]" was expected...

    I stopped working on that project... If no solution exists to safely create or update variables from the BCB code, I will try to use the OnGetValue event, hoping that it will work like in FR 253. However, in FR235, I found that, when several FRF designs were used with the same frReport, the code was easier to follow in setting variables after loading the FRF file and before PrepareReport. When using OGV, all cases are mixed in the same place for all FRF designs.

    BJL

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.