How to assign new value to variable by using previous value assigned to same variable
At fast report I have declared a variable 'i' at memo. Variable i is assigned the value equal to 1 initially , I want to increment its value by 3 each time in next display. It is displaying value i in 3*3 grid. So I want to display value of variable i in each grid incremented by 3. e.g 1, 4, 7, 10 ... etc.. How it can be done ?
I tried following both procedures
Another one I tried
But both procedures are not incrementing the value of i , it is displaying same value as i = 1 (which is initially assigned in each grid) as shown in image below.
while I want to display it as 1, 4, 7, 10 etc..
Is there any way to retrieve previously assigned value to the particular variable and increment it.
I tried following both procedures
procedure TForm7.frxReport1BeforePrint(Sender: TfrxReportComponent);
var
i: Integer;
begin
i := 1;
frxReport1.Variables['i'] := i;
i := i + 3;
end;
Another one I tried
procedure TForm7.frxReport1GetValue(const VarName: string; var Value: Variant);
var
i: integer;
begin
i := 1;
if (VarName = 'i') then
Value := i;
i := i + 3;
end;
But both procedures are not incrementing the value of i , it is displaying same value as i = 1 (which is initially assigned in each grid) as shown in image below.
while I want to display it as 1, 4, 7, 10 etc..
Is there any way to retrieve previously assigned value to the particular variable and increment it.
Comments
what you want to do is use the obp event using the name of a specific object and then modify the variables value.
whatversion and level of fr are you using.
xe version or full fr above basic?
I am using XE 3 with fr version 4.13. I find another solution to above problem by declaring global variable 'i' at XE3 and ID1 is variable declared at FR.
Here I am incrementing i by only one count , Why it is getting incremented by 2 counts at report , any idea?
When you create a categorized variable with no value each time the variable is encountered in the report
it triggers the ongetvalue event.
you should initialize the variable after loading the report and before calling show or prepare report or
in the onstart report event.
why not use internal report code and create a script variable in the report?