How to get memo text or value at run time

edited 2:55AM in FastReport 4.0
Hi

I'm using Delphi XE3's FR4. I want to get the value shown by a memo, do a calculation on that value and output the new calculation to another memo when the report is run.

But if I put the following code into any number of events (ClickObject, Preview etc..) . . . .

var srce, dest:TfrxMemoView;
begin
dest := TfrxMemoView(rpt_DayEnd.FindComponent('Memo35'));
srce := TfrxMemoView(rpt_DayEnd.FindComponent('Memo27'));
if (srce <> nil) and (dest <> nil) then
begin
dest.Text := performCalculationRequiringAFloatingPointValue(strtofloat(srce.value));
end;
end;

. . . . . . the srce.value shows '' and srce.text shows the formula within Memo27 from which the value is calculated.

How can I achieve what I'm trying to do here? Is it at all possible?

Thanks

Regards

Steve

Comments

  • gpigpi
    edited 2:55AM
    In delphi
    procedure TForm1.FormCreate(Sender: TObject);
    begin
         frxReport1.AddFunction('function ChangeMemoWithTag(Tag: string)');
         frxReport1.ShowReport();
    end;
    
    function TForm1.frxReport1UserFunction(const MethodName: String;
      var Params: Variant): Variant;
    var i, j: integer;
        c: TObject;
        page: TfrxReportPage;
        modified: Boolean;
    begin
         if MethodName = 'CHANGEMEMOWITHTAG' then
           begin
             modified := False;
             for i := 0 to frxReport1.PreviewPages.Count-1 do
               begin
                 page := frxReport1.PreviewPages.Page[i];
                 for j := 0 to page.AllObjects.Count - 1 do
                   begin
                     c := page.AllObjects.Items[j];
                     if c is TfrxMemoView then
                       if TfrxMemoView(c).TagStr = Params[0] then
                         begin
                           TfrxMemoView(c).Text := 'test';
                           Modified := True;
                         end;  
                   end;
                 if Modified then
                   begin
                     frxReport1.PreviewPages.ModifyPage(i, page);
                     frxReport1.Preview.Refresh;
                   end;  
               end;  
           end;
    end;
    
    in script
    procedure Memo1OnPreviewClick(Sender: TfrxView; Button: TMouseButton; Shift: Integer; var Modified: Boolean);
    begin
         ChangeMemoWithTag('2');                          
    end;
    
  • edited 2:55AM
    Thanks for your post, gpi. Unfortunately I can't test it since, as far as I can see, the version that ships with Delphi doesn't allow access to the Events of individual components nor does it give me scripting capability - or have I got this totally wrong?! I've only just begun to use FR :-)

    Thanks

    Steve
  • gpigpi
    edited 2:55AM
    Use TfrxReport.OnClickObject event

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.