Recent

Author Topic: LazReport: Two kinds of Variables  (Read 534 times)

bpranoto

  • Full Member
  • ***
  • Posts: 136
LazReport: Two kinds of Variables
« on: February 18, 2020, 05:26:55 pm »
Hello all,

I want make a printout report with LazReport of a simple table with just 2 fields: NAME and SALARY. I need to put the total salary.

To achieve it, I accumulate the salary record value into a variable TotalSalary on the MasterData band script: TotalSalary := TotalSalary + BufDataSet1."SALARY"

What I found is when I define the variable TotalSalary in the Variable Lists, eventhough there is no error on runtime, the TotalSalary variable is not updated.

However, if do not put the variable TotalSalary on Variable List, but initialize it on the BeforePrint script, then it works as expected.

Attached is a simple demo app with 2 buttons:
  • The first button is to show the case of what happens if we define the variable TotalSalary on Variable List (the fail case)
  • On the the Second button, the variable is not listed on the Variable List but is initialized on the Report's BeforePrint Script

Is my observation correct that there are two types of Variable or do I miss something?

Why is it designed this way? If the value of the variable on the Variable List is not supposed to be modified on the script, why don't throw an exception?




 

TinyPortal © 2005-2018