delphi and fastreport

adaada
edited 8:50PM in FastReport 4.0
Hello,

I want to know, how to get a delphi function in fastreport because some delphi functions are not enable in fastreport.
How can I do enable or export these function from delphi to fastreport?

Thanks.

Comments

  • gpigpi
    edited 8:50PM
    Use user function. See a Developer's manual
  • adaada
    edited 8:50PM
    Have you any real example to implement in fastreport?
  • gpigpi
    edited 8:50PM
    wrote:
    Custom Functions Connection to Report
    FastReport has a large number of built in standard functions, for use in report
    designing. There is also the ability to connect (add) your own custom functions. Function
    connection is performed using the ???FastScript??? script library interface, which is included in
    FastReport (to learn more about FastScript, refer to it???s library manual).
    An example of how procedures and/or functions can be connected. Function???s
    parameter quantity and type can vary. One cannot transfer parameters of ???Set??? and
    ???Record" type, as they are not supported by FastScript. You must transfer such parameters
    as simpler types, for example, to transfer TRect as X0, Y0, X1, Y1: Integer. See more
    about process of adding functions with different parameters in FastScript documentation.
    On the Delphi form declare the function or procedure and its code.
    function TForm1.MyFunc(s: String; i: Integer): Boolean;
    begin
    // necessary logic
    end;
    procedure TForm1.MyProc(s: String);
    begin
    // necessary logic
    end;
    create the onuser function handler for the report component.
    function TForm1.frxReport1UserFunction(const MethodName: String;
    var Params: Variant): Variant;
    begin
    if MethodName = 'MYFUNC' then
    Result := MyFunc(Params[0], Params[1])
    else if MethodName = 'MYPROC' then
    MyProc(Params[0]);
    end;
    Use the report component???s add method to add to the function list (usually in on create or
    on show event of the Delphi form).
    frxReport1.AddFunction('function MyFunc(s: String; i: Integer): Boolean');
    frxReport1.AddFunction('procedure MyProc(s: String)');
    Connected function can now be used in report script; furthermore, one can refer to
    it from objects of ???TfrxMemoView??? type. This function is also displayed in "Data tree"
    window???s function page tab. In this window functions are split into categories, and when
    you select any function, a hint about this function appears in the bottom pane of the
    window.
    Modify code sample above to register functions in separate category, and display
    function description hint:
    frxReport1.AddFunction('function MyFunc(s: String; i: Integer): Boolean', 'My functions', frxReport1.AddFunction('procedure MyProc(s: String)', 'My functions', ' MyProc procedure Your added items will now appear under the category ???My Functions???.
    If you want to register functions in one of the existing categories, use one of the
    following category names:
    'ctString' ??? string function;
    'ctDate' - date/time functions;
    'ctConv' - conversion functions;
    'ctFormat' - formatting;
    'ctMath' - mathematical functions;
    'ctOther' - other functions.
    If blank category name is specified, the function is placed in the functions tree root.
  • edited 8:50PM
    ada wrote: »
    Hello,

    I want to know, how to get a delphi function in fastreport because some delphi functions are not enable in fastreport.
    How can I do enable or export these function from delphi to fastreport?

    Thanks.
    Funny you ask this. I just did this last night. There are some essential string handling functions I wish FR had baked in. Absent that, I implemented via a user function.

    You have to register the signature of your function with the report component using the AddFunction method. The other side of the task is to actually execute the function when the report component is called to execute your custom function in the report file. That's handled in the OnUserFunction event.

    User functions are a pretty simple and effective solution.
  • edited 8:50PM
    kamiller42 wrote: »
    User functions are a pretty simple and effective solution.
    Just some more FYI... I came across this need when I realised the function QuotedStr was not available. I call out from the report to Delphi to get it done now.

    Today, I needed to call from Delphi to FR. I needed the OnClosePreview event in the FR script, but it's not available. Solution is simple. Code the report component's OnClosePreview event in Delphi to call MyReportComponent.DoNotifyEvent. Pass in the name of the method the report component should call in the FR script.

    If you need to call FR to Delphi or Delphi to FR, it can be done with ease. I do hope FR script gets a good upgrade in FR5. FR5, where are you?
  • adaada
    edited July 2011

    Thank you really gpi. I finished it with your first help...
  • adaada
    edited 8:50PM
    Thank you kamiller.
  • adaada
    edited July 2011
    gpi wrote: »
    Use user function. See a Developer's manual


    Hi,

    Did you implement record type in fastreport?

    Thanx

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.