Search Results for

    Show / Hide Table of Contents

    Structure of a script

    The structure of a script depends on the language used; however there are some elements common to each language. These are the script’s title and body, and the main procedure which will be executed when the report runs. Below are examples of scripts in all four of the supported languages:

    PascalScript structure:

    #language PascalScript // optional
    program MyProgram;     // optional
    // 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.
    end.
    

    C++Script structure:

    #language С++Script    // optional
    // the “include” chapter should be placed before any other chapter
    #include "unit1.cpp", "unit2.cpp"
    int i, j = 0;          // the “variables” chapter can be placed anywhere
    #DEFINE pi = 3.14159   // “constants” chapter 
    void p1()              // functions
    {                      // no nested procedures
    }
    {                      // main procedure.
    }
    

    JScript structure:

    #language JScript      // optionally
    // the “import” chapter should be before any other chapter 
    import "unit1.js", "unit2.js"  
    var i, j = 0;          // the “variables” chapter can be located anywhere
    function p1()          // functions
    {                      // 
    }
                           // main procedure.
    p1();
    for (i = 0; i < 10; i++) j++;
    

    BasicScript structure:

    #language BasicScript  ' optionally
    ' the “imports” chapter should be located before Any other chapter 
    imports "unit1.vb", "unit2.vb"  
    Dim i, j = 0           ' the “variables” chapter can be placed anywhere
    Function p1()          ' functions
    {                      ' 
    }
                           ' main procedure.
    For i = 0 To 10        
      p1()
    Next
    

    A more detailed description of the FastScript engine can be found in its documentation. This information is not repeated here in this user manual:

    • syntactic charts for each of the supported languages

    • supported data types

    • operations with classes, properties, methods and events

    • nested functions

    • enumerations and sets

    Later we will look at examples of scripts written in the “PascalScript” and "C++Script" language. When a new report is created "PascalScript" language is selected by default.

    Back to top © 1998-2022 Copyright Fast Reports Inc.