How to assign new value to variable by using previous value assigned to same variable

edited November 2013 in FastReport 4.0
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
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.

grid.jpg 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

  • gordkgordk St.Catherines On. Canada.
    edited 8:58AM
    once you have set the value in the ogv event it will not change
    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?
  • edited 8:58AM
    gordk wrote: »
    once you have set the value in the ogv event it will not change
    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.
    public
        { Public declarations }
        i: integer;
    
    procedure TForm7.frxReport1GetValue(const VarName: string; var Value: Variant);
    begin
    
     if (VarName = 'ID1') then
        Value :=  i;
    
     inc(i);
    
    end;
    

    grid.jpg


    Here I am incrementing i by only one count , Why it is getting incremented by 2 counts at report , any idea?
  • gordkgordk St.Catherines On. Canada.
    edited 8:58AM
    probably due to the report being a 2 pass report.
    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?

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.