[Lazarus] lazreport: how to use global report variables

Jesus Reyes A. jesusrmx at gmail.com
Wed Jul 1 22:47:36 CEST 2015


On Tue, 30 Jun 2015 10:35:54 -0500, Graeme Geldenhuys  
<mailinglists at geldenhuys.co.uk> wrote:

> On 2015-06-30 14:03, Graeme Geldenhuys wrote:
>> I've used File -> Variable List to define a new variable (just the  
>> name).
>
>
> Digging deeper into the LazReport code, I finally found the solution.
>
> Even though you setup a variable, you must not refer to it via the
> Scripts.Values[] or Variables.Values[] properties. Go figure!
>
> Instead you use the Values.FindVariables() method.
>
>   FRPrint.Values.FindVariable('HideKlas').Field := '1';
>

Those are not global variables. They are report variables.

I think the easier way to modify global variables is through the  
frVariables object
ej.

frVariables['HideKlas'] := 1;


>
> For more details of what I've done, see the Lazarus Forum post.
>   http://forum.lazarus.freepascal.org/index.php/topic,28922.0.html
>
>
> Now this begs the question... What the hell does Scripts.Values[] and
> Variables.Values[] actually do?

They do the same thing they do for any TStrings list, ie. Assign values to  
supposedly existing "names" , for they to work you have to have a list  
like:

name1=value1
name2=value2
etc.

But in LazReport this TStrings list functionality is not used.

Report.Variables holds the list of variables and variables categories that  
you have defined in the Report (usually using the report designer gui).  
Variables categories can only be used as distinctive tags for a group of  
variables, and I guess that is the reason why there are a Values object  
too, which btw has a list of only variables.

I was not able to find a Report.Scripts property or field, maybe you mean  
Report.Script? in that case supposedly it holds the script to be run as  
"BeforePrint" script.

Jesus Reyes A.




More information about the Lazarus mailing list