Home RAP

Global Variables

edited July 2010 in RAP
I have declared global variables as follows in the Global|Declarations

ProvGroupUnits: Double;
ProvIndividualUnits: Double;

The following code is present in the DetailAfterPrint handler:

ShowMessage ('Incoming='+ FloatToStr(ProvIndividualUnits));

if Transaction['Insurance Category'] = 'B' then
ProvGroupUnits := ProvGroupUnits + Transaction['Units (2)']
ProvIndividualUnits := ProvIndividualUnits + Transaction['Units (2)'];

ShowMessage ('Outgoing='+ FloatToStr(ProvIndividualUnits));

When the report is executed, the value of "Incoming" is ALWAYS zero even
though the value of "Outgoing" is always equal to Transaction['Units (2)'].

Which suggests the "global" variable is going out of scope and/or being
reinitialized. I do have the following code in the global OnCreate
handler but taking it out doesn't change things at all.

ProvIndividualUnits := 0.;
ProvGroupUnits := 0.0;

Any suggestions or workarounds?




  • edited July 2010
    Hi David,

    Which version of Delphi and ReportBuilder are you using?

    1. Be sure you are declaring the two globals as variables, not constants.
    2. Are you certain Transaction['Units (2)']; contains a non-zero value? It
    helps to first write this code in Delphi so you can debug it and see what is
    actually happening, then move it to RAP.
    3. Try a simpler case, in my testing I created a global variable named
    MyVariable: Double; Then inside the DetailAfterPrint, I increased its value
    by one and displayed it. This worked as expected.


    Nico Cizik
    Digital Metaphors

    Best Regards,

    Nico Cizik
    Digital Metaphors
This discussion has been closed.