Variables in expressions for checkbox

edited 10:45AM in FastReport VCL 5
Hi

I am experimenting with building a report with Delphi and FR VCL5 with mostly static fields. The report is not based on a database with clear tabular format, but is a single page with text and some values dispersed in it.
My idea was to do it with variables, so I used frx memo components with vars written like [cat2.varname1]. The data for the variables is provided in the report's OnGetDocValue handler.

The above works for the textual display, but how can I use a variable name in the Expression of a TfrxCheckBoxView to set its checked/unchecked state?
For an integer value I tried something like "[cat1.myvar]=5" to set the box as checked. I tried also other combinations with and without square brackets and <>, but the variable name is not recognized properly. Instead of the var name, which in this case is "cat1.myvar", in the OnGetDocValue handler I receive the whole text of the expression "[cat1.myvar]=5".

Is this by design or I am not writing the syntax of the expression properly?
The var names contain dots, but this works in other parts of the report.

Thanks.

Comments

  • edited 10:45AM
    After more experiments I didn't find if it is possible to have variables in the Expression property. So I used the checkbox OnBeforePrint event to handle it. It parses the variable name and sends it to OnGetDocValue properly.

    procedure CheckBox1OnBeforePrint(Sender: TfrxComponent);
    begin
    CheckBox1.Checked := <cat1.myvar> = 5;
    end;
  • LurkingKiwiLurkingKiwi Wellington, New Zealand
    edited 10:45AM
    I'm not sure what OnGetDocValue event you mean, but I have found that the Delphi OnGetValue handler is called recursively with sub-parts of an expression as FR works its way through the parse. Your OnGetValue handler must return without changing the Value parameter unless the Varname parameter EXACTLY matches the item you're looking for - you can't have a "didn't match anything I'm looking for" else clause which changes Value, raises an exception etc.

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.