The calculation allows you to create intelligent report templates from normal report templates. These are report templates that contain scripts. Scripts can be used to change the appearance of the printout depending on conditions. For example, it is possible to manage two different letterheads in one template using a suitable script. A letterhead used for faxing and one used for printing. The script language with which this is possible is called Pascal Script and is described with the extensions in the developer's manual. Since EULANDA® itself is created in Delphi (=Pascal successor), this script language is optimally adapted to the program.
The functions within the EULANDA® Report Designer are very powerful and versatile. However, not all results in demanding reports can be realized by static links and by setting properties.
Whenever elements are to be changed in their properties based on conditions, we need scripts. What the batch file is for MSDOS, the script language is for modern application systems. EULANDA® uses the language Pascal as script language for reporting. This is obvious because the report designer as well as the complete EULANDA® system was created in Pascal or Delphi.
By using the same script language, reports can be seamlessly integrated into EULANDA® without having to do without the advantages of the free definition of a report.
This chapter is only a short technical summary of the Pascal script options and shows in a short overview the operation of the script editor. The technical documentation for the individual script commands can be found in a separate manual in the online help.
Scripts are small program parts that are precompiled (translated) by the report designer. The different language elements can be dragged and dropped from the toolbox into the script editor window. Compiling is the translation of a language, in this case the Pascal language, into a form that machines can understand. The EULANDA® compiler does not generate any machine language, but, similar to JAVA, moves on an independent level. The main advantage of compilation is the faster execution speed during runtime. In addition, syntax errors (grammar errors) are detected immediately.
A script is event-driven. Each object, whether it is the main report, the individual tapes or the objects to be placed, has a series of events. These are automatically called by an internal logic. If such an event is linked to a script, it is executed as soon as the event occurs. There are events that are triggered directly at the start of printing, others at the end of printing or when a page change occurs, other events are triggered as soon as a data record changes, and so on.
EULANDA® knows about 100 events, so that you can achieve any desired functionality by scripts in the right event.
Properties and Methods
Scripts can be used to change the properties of elements, depending on conditions. Conditions can be that an invoice has negative revenues, customers with a particularly high turnover can be a condition or a reaction to certain product groups, certain weekdays or texts that are to be contained in fields.
A script can react to all these conditions and make changes. Changes can be, for example, the invisibility of elements, regions or entire print areas, but also the change of font, color, position, size or the content of fields.
Calculations can be used to make field changes; for example, a complete interest plan or leasing table can be created and output at the end of an offer.
Scripts are also used when you want to use a report for different purposes. For example, it is conceivable to print an invoice without letterhead, but if it is faxed, an electronic letterhead should be deposited. A script can detect these states and make the stationery invisible for output to the printer.
Scripts can be used to solve things that could otherwise only be realized in the program itself, i.e. that could no longer be freely changed from outside.
In the tutorials, report templates are described in detail, especially the why and how is explained there. Understanding the description requires knowledge of Pascal-Script and the query language SQL. Both requirements (Pascal-Script and SQL) are described in the additional manuals of the online help.
The delivery address should only be displayed in the header area of the invoice next to the address if a single delivery address exists; if several delivery notes exist for the invoice, the delivery addresses should be represented in the invoice text by subheadings. If the billing and delivery addresses are identical, the delivery address should not be printed either. A typical task for a script.
Structure of the script editor
Scripts can be created directly in the report designer. To do this, select the "Calculations" tab. This tab is divided into four large areas.
The area for the elements is located at the top left. All elements used are displayed in an outline. This structure is structured like an inverted tree whose root is the main element, i.e. the"report". The individual ribbons (= branches) leave from this and the elements (= sheets) positioned on them leave from the ribbons.
There is a series of events for each of the elements. You will find them in the top right-hand corner. If you select one of the elements in the element selection, you can view the events available for this element in the event area.
To be able to see the events, the "Events" option must be selected in the "View" menu.
Using the right mouse menu above an event, a script can be created using the "New" item or an existing script can be deleted.
Scripts are stored in the area at the bottom left of each event. You can select an event in the upper right area and then create the script for it in the script area by clicking with the mouse in the script area. A function block makes this easier. The desired Pascal script only has to be written into the block.
Script can be deleted in the event area. There you will find the function "Delete" in the right mouse menu.
A script can be compiled using the right mouse menu. Errors can still be detected and corrected in the editor. The error message is displayed in the lower window. If possible, double-click on the error message to display the incorrect line in the script area.
In the example above, the property of the "TextTitle" element is not "Caption" but "Caption". Such errors can be avoided if you drag and drop the property of the element directly from the toolbox.
After changes in the script area, you should always check the report template in the preview before saving.
If you want to find out quickly in a report whether scripts are stored there, it is quite tedious to look through all objects in the menu tree, even if stored scripts are marked by colored entries. It is easier to switch to the "Used modules" option in the "View" menu. All stored scripts are immediately listed in the event area.
The toolbox at the bottom right contains all essential properties that can be set for the individual elements via scripts. The toolbox view can be switched between data, elements and language via small tabs at the bottom.
This view shows the fields contained in the data sources and the corresponding data types. The data section is divided into two windows. The data source is set in the upper window. The fields of the selected data source are displayed in the lower window.
If a field value is required in the script, it can be dragged and dropped into the script area.
The data source "Basic values" is automatically available in all reports. The fields of the basic values are loaded from the operating system (user, PC name, etc.) and the SQL registry. For technical reasons, external data sources cannot be used in the script. Neither the basic values nor fields from the data sources invoices, etc.
To use values of these fields in the script, you have to place a database variable in the layout and set this field to not visible. This is done with the right mouse button.
The name of the database element and its value property, e.g. DbText1.FieldValue, can then be used in the script.
For all elements positioned in the design, the properties can be called up in the toolbox and partly also set via scripts. In the upper part of the window, select the element from the tree view. The properties of the selected element are displayed in the lower part. The most important property is certainly "visible". This can be used to set whether the element is to be printed or invisible. But also the extension and position (left/top) and other properties can be read and changed in the script during printing.
The language range of the script language can be called up on the last tab of the toolbox. All language functions are divided into groups listed in the upper window. The script language consists of the Pascal basic commands and the extensions that can be selected here. The range of languages is constantly being expanded and adapted to the growing needs. The documentation for the individual commands is described in a separate manual in the online help. This manual is called "Pascal-Script for intelligent reports".
Language in Calculations
The desired functions can be dragged and dropped into the script area.