Search Results for

    Show / Hide Table of Contents

    Using "uses" directive

    You can split large script to modules, like in Object Pascal:

    File unit1.pas:

    uses 'unit2.pas';
    
    begin
      Unit2Proc('Hello!');
    end.
    

    File unit2.pas:

    procedure Unit2Proc(s: String);
    begin
      ShowMessage(s);
    end;
    
    begin
      ShowMessage('initialization of unit2...');
    end.
    

    As you can see, you should write module name with file extension in quotes. The code placed in begin..end of the included module will be executed when you run script (this is analogue of initialization in the Pascal). In this example you cannot use unit1 from within unit2. This will cause circular reference and infinity loop when compiling such script. Such references are not allowed since FastScript does not have interface/implementation sections.

    Using #language directive, you can write multi-language scripts. For example, one module may be written in PascalScript, another one - using C++Script:

    File unit1.pas:

    uses 'unit2.pas';
    
    begin
      Unit2Proc('Hello from PascalScript!');
    end.
    

    File unit2.pas:

    #language C++Script
    
    void Unit2Proc(string s)
    {
      ShowMessage(s);
    }
    
    {
      ShowMessage("unit2 initialization, C++Script");
    }
    

    The #language directive must be the first line of the file. If this directive exists it overrides TfsScript.SyntaxType setting.

    Back to top © Copyright Fast Reports Inc.