Overview

JADE Report Writer scripts enable you to programmatically derive report fields by performing calculations involving one or more database fields, report special fields, or report parameters; for example, applying a variable tax rate to a currency field.

There are two ways of creating scripts, as follows.

Whichever way you create a script, your script becomes a pseudo field that you can click and drag from the Catalog of Available Fields dialog to your report layout in the same way that you apply any other field type. You can also use scripts in your report profile sort, selection, and group criteria. For details about inserting field, see "Inserting Report Fields", in Chapter 4.

In the following image, a script field that is derived from a script that calculates a value in US dollars is dragged onto the footer section of the report design from the Catalog of Available Fields.

In this example, the script is a single expression that multiplies the total sales value by an exchange rate to obtain the US dollar amount. If you want to make the field value conditional on another value, you need to code a full script and apply conditional instructions (for example, if, then, and else instructions) as you would when coding JADE methods. In the above example, you might want to print the US dollar conversion only on the end-of-year report, in which case you would make the calculation conditional on a date.

The primitive type methods are available to you when you create scripts are described in this appendix grouped by type; for example, Binary, Date, Character, and so on. In JADE, these are referred to as primitive types. The primitive types documented in Chapter 1 of the JADE Encyclopaedia of Primitive Types are types used to store values, and they can have methods added to them. The primitive types are displayed in the Methods list box of the Add Script Field and Update Script Field dialogs in the JADE Report Writer Designer application, as shown in the following image.

You can open up each category, or type, to display the list of the methods within that category.

The default set of script methods initially available in the Methods list box of the Add Script Field and Update Script Field dialogs of the JADE Report Writer Designer application comprises the most frequently used JADE primitive type methods. More primitive types and many more methods can be added to a report view from the Available Methods list box of the Script Methods sheet of the JADE Report Writer Configuration window.

When a method is added to a view, it becomes available as a script method in reports based on that view in the JADE Report Writer Designer application.

JADE developers can also add methods to primitive types in JADE schemas and these methods can also be added to a reporting view based on those schemas.