PANTHEON™ manual

 Categories
 PANTHEON Help - Welcome
[Collapse]PANTHEON
 [Collapse]Guides for PANTHEON
  [Collapse]Guide for PANTHEON
   [Collapse]Settings
    [Expand]Subjects
    [Expand]Items
    [Expand]POS
    [Expand]Manufacturing
    [Expand]Personnel
     Calendar
    [Expand]Financials
    [Expand]Customs
    [Collapse]Program
     [Expand]Document Types
     [Collapse]Reports in PANTHEON
       Settings in Administration Panel
      [Expand]Reports Register
       Print Preview
      [Expand]Report Designer
      [Expand]Creating Reports
      [Expand]Groups and Aggregates
      [Expand]Formatting and Highlighting
       Nested Reports (Subreports)
      [Expand]Specifics of Printouts in PANTHEON
      [Collapse]Script
        "Hello, World!" Script
        Using Variables, Database Fields, and Aggregate Functions
        Using Report Objects in the Script
        Events
        Example of Using the "OnBeforePrint" Event
        Printing a Group Sum in the Group Header
        Running Total
        "OnAfterData" Event
        Service Objects
        Using the "Engine" Object
       [Expand]PANTHEON Functions for FastReport
       [Expand]Examples with Tables and Queries
       Report Design Considerations
      Document Texts
      Delivery Methods
     [Expand]Loyalty Cards
     [Expand]Administration Panel
     [Expand]Dashboard Components
      Dashboard Reports
      Ad-hoc analysis
     [Expand]ARES
      SQL urejevalnik
    [Expand]Documentation
    [Expand]Change User
   [Expand]Orders
   [Expand]Goods
   [Expand]Manufacturing
   [Expand]POS
   [Expand]Service
   [Expand]Financials
   [Expand]Personnel
   [Expand]Analytics
   [Expand]Desktop
   [Expand]Help
   [Expand]Messages and Warnings
   [Expand]Additional programs
   [Expand]Old products
  [Expand]Guide for PANTHEON Retail
  [Expand]Guide for PANTHEON Vet
  [Expand]Guide for PANTHEON Farming
 [Expand]User Manuals for PANTHEON
[Expand]PANTHEON Web
[Expand]PANTHEON Granules
[Expand]User Site

Load Time: 640.633 ms
print   |
Label

Calling the Variable from the Report's Variable Li

Calling the Variable from the Report's Variable List

Any variable that is defined in the list of the report variables (“Report>Variables...” menu item) can be referenced in a script. The variable’s name should be enclosed in angle brackets:

if <my variable> = 10 then ...

 

An alternative way is to use the “Get” function:

if Get('my variable') = 10 then ...

 

A variable’s value is changed only via the “Set” procedure:

Set('my variable', 10);

 

It is worth noting that to assign a string value to the variable you must add quotes around the value:

Set('my variable', '''' + 'String' + '''');

 

System variables, such as “Page#,” should be referenced in exactly the same way:

if <Page#> = 1 then ...

Referencing the Database Fields

Just as with variables, angle brackets should be used when referencing DB fields in a report:

if <Table1."Field1"> = Null then...

Alternatively the “Get” function can be used for accessing DB fields (in fact, this function is used implicitly by FastReport when calculating expressions enclosed in angle brackets).

Using Aggregate Functions in the Script

An idiosyncrasy of aggregate functions is that they must be used inside “Text” objects; once used in this manner they can then be used in the script itself. If an aggregate function only appears in a script (without appearing in a “Text” object) an error message is generated. This happens because an aggregate function must be connected to a specific band; once so connected it will work correctly.

Displaying a Variable's Value in a Report

Variables can be declared and used locally within a script. Once declared a script variable can have a value assigned to it. Here is a simple example of a script variable in use:

var

 MyVariable: String;

begin

 MyVariable := 'Hello!';

end.

The variable’s value can be displayed in a “Text” object, for example, by typing '[MyVariable]' into the object.

A variable’s name must be unique. This means the name must not duplicate the name of any other report object, standard function or constant. If there is an error in a script, a message will be displayed when the report is run and report construction will be stopped.



Rate this topic
Was this topic usefull?
Comments
Comment will also bo visible in forum!