Doublepass and scripting variables
I have a report set to doublepass=true to print "Page X of Y" on a page footer
I also accumulate a running total in a variable.
I set the variable to zero in the onreportprint event but it looks like it only fires at the start of the first pass of the report thus accumulating in both first passes of the report.
Where should I initialize these variables to avoid the "double counting"
If the first pass did not count as printing then the onreportprint event would fire after the first pass ie at the start of the printing pass...
FWIW our Reports do something similar to your outlined approach (all Two-passes; all have Page Footer with "Page X of Y" on them; most have some sort of "running totals in variables").
We have tried to standardise the approach so do a lot of stuff in a Report Template and a "Commons" Unit.
And what this comes down to is that we tend to do the management of Variables only in one of the Passes. You can test via <Report>.Engine,FinalPass Property which of the two is executing (one of our "Common" routines translates this into a "FirstPass" Function for clarity).
It is not much of an improvement for "efficiency" but it does make debugging easier 😉
So for example calculating the Total Page Count is done in the "FirstPass", Calculating the Running Total(s) is done in the FinalPass.
Depending on your "architecture" / "house style" this might work for you too,..
In the sea of documentation I missed the finalpass property (sitting there to deal with my exact dilemma).
Appreciate your reply