access functions from other units

How to get access functions from other project units in the code tab from fastreport.

I create a test program with 2 units (unit1, unit2) and copy the example code from the manual to the fr designer code tab.


#language PascalScript

program MyProgram;

// the “uses” chapter should be located before any other chapter

uses 'unit1.pas', 'unit2.pas';

var // the “variables” chapter can be placed anywhere

i, j: Integer;

const // “constants” chapter

pi = 3.14159;

procedure p1; // procedures and functions

var

i: Integer;

procedure p2; // nested procedure

begin

end;

begin

end;

  

begin // main procedure.

 ShowMessage('Hallo');                         

end.


When I run my proc and call frxReport1.ShowReport(), I get this error message (can't find unit2.pas):

Sure, unit1 & 2.pas are under S:\__test but how to tell the designer the correct path?

And when I run the script in the designer I get this error message: (BEGIN expected)


Comments

  • Try to comment first two lines of the script

  • Thank you. unfortunately same error.

  • Copy Unit2.pas into S:\__test\Win32\Debug folder

  • Thanks, but the Debug Folder ist for dcu-Files not for pas-Files.

    I can write the complete path in the script (same as copy pas files to Debug folder)

    Running the script:


    Running from the test program:


  • Is unit1.pas FS unit? FR will not works with Delphi's units. Use Fast Script unit

  • Thank you. Yes unit1.pas is a delphi unit.

  • edited February 27

    I had the same issue, not understanding how a FS unit should look like.

    What worked for me was the example on page 50 here: https://www.kapsw.cz/data/xinha/downloads/FastScriptDoc_en.pdf

    {**************************}

    { Unit1.pas demo }

    {**************************}

    procedure Unit1Proc(s: String);

    begin

    ShowMessage(s);

    end;

    begin

    ShowMessage('unit1 initialization');

    end.

    {**************************}

    { Unit2.pas demo }

    {**************************}

    uses 'unit1.pas';

    begin

    Unit1Proc('unit2 initialization');

    end.

    {**************************}

    { Unit demo }

    {**************************}

    uses 'unit1.pas', 'unit2.pas';

    begin

    Unit1Proc('hello from main proc');

    end.

    The unit name can be given with a full path, like 'C:\unit1.pas'

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.