[HELP] Assign object properties with looping

edited September 2010 in FastReport 4.0
Is it possible to assign object values using looping..???
I use this to made dynamic size of memo to fix with paper width using pascal script, not using design..

example : 5 memo, sometimes maybe 6-10..
___________________________________________________________________________

var
memo1,memo2,memo3, .....memo10 : TfrxMemoView;
i,count : integer;
memowidth, memoleft : Extended;

begin
memoleft:=0;
count:=5; //I'll use example 5 memo only to fix with page width
memowidth:=page1.paperwidth/5;

memo1:= TfrxMemoView.Create(MasterData1);
memo2:= TfrxMemoView.Create(MasterData1);
memo3:= TfrxMemoView.Create(MasterData1);
....memo10

for i:=1 to count
begin
//this I had the problem with, how I assign memo 1 to 5 (count) properties value using loop?

memoi.setbounds(memoleft,0,memowidth,0);
memoleft:=memoleft+memowidth;
end;

end.
______________________________________________________________________________________________
Thanks

Sorry my bad english

Comments

  • Anu de DeusAnu de Deus Hampshire, UK
    edited September 2010
    If you give your memos the name structure, like 'memo1','memo2','memo3', etc, you can do something like this:
    (if you need for more than 1 band, you will have to change your code accordingly)
    var
      lMemoX : TFrxMemoView; 
    i : integer;
    lSearchName : string;
    begin
    for i:= 1 to 10 do 
    begin
      lSearchName := 'Memo'+inttostr(i); 
      lMemoX := MasterData1.FindObject(lSearchName);
      if lMemoX <> nil then
          lMemoX.text := 'Im number ' +inttostr(i); 
    end;
    
    Alternatively, you could do a function to return the object you want like:
        while (Result = nil) and (i < MasterData1.Objects.Count) do
          begin
            lObj := MasterData1.Objects[i]; // tfrxComponent;
            if lObj is TFrxMemoView then
              if lObj.Name = 'TheName you are after' then   // you can use any property, not just the name. I use tag a lot.
                Result := lObj; 
            Inc(i);
          end;
    

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.