Creating a Script

This subsection describes how to derive a simple expression (using the exchange rate example) and apply the resulting script field to your report layout. For full details about creating scripts, see Appendix A, "Using JADE Report Writer Scripts".

To display the Add Script Field dialog

  1. Click the Script tab of the Catalog of Available Fields dialog. The Script sheet is then displayed.

  2. Click the New button on the toolbar of the Catalog of Available Fields dialog. The Add Script Field dialog is then displayed, as shown in the following image.

To enter the script name and define the return type of your expression

  1. Enter a name for your script field in the Script Name text box. You can use any character to name your script. The script name can be up to 30 characters long.

    In the previous image, inUSD has been entered as the script name to provide the example using the exchange rate.

  2. Click the Define Return Type button at the right of the Return Type list box.

    The Define Script Return Type dialog, shown in the following image, is then displayed.

  3. In the Type list box, select the primitive type that you want for the result of your expression (for example, Decimal, Binary, String, Real, and so on).

  4. In the Length text box, enter the length of result field if you selected Binary, Decimal, or String in the Type list box. For other primitive types, this text box is not enabled.

  5. In the Decimals text box, enter the number of decimal places if you selected Decimal in the Type list box. For other primitive types, this text box is not enabled.

  6. Click the Apply button to apply the primitive type that you have selected.

The Define Script Return Type dialog is then closed and the return type that you selected is displayed in the Return Type list box of the Add Script Field dialog, as shown in the following image.

In this example, the Decimal primitive type has been selected as the return type (that is, the output type for the result of your script). The script field (which has been named inUSD) receives the result of the expression as a decimal number.

To build the expression in the Add Script Field dialog

  1. In the Fields list box, select a field as the operand of your expression. Open up one of the field categories by clicking the plus (+) symbol and then double-click the required field.

    The following image shows the Summary Fields category opened up and the grand total field selected. In the example, this field is to be expressed in US dollars when the script is applied to the report.

    The selected field is then moved to the result area, as shown in the previous image.

    The exclamation mark (!) character indicates that this is a summary field; that is, a field that accumulates values as the report runs.

    For details about summary fields, see "Using the Summary Sheet", later in this chapter.

  2. Select an operator from the Commands list box.

    An arithmetic operator is required in the exchange rate example, as the value (grand total) is to be multiplied by the exchange rate.

    Open up the Arithmetic operators category by clicking the plus (+) symbol and then double-click the required field.

    The following image shows the Arithmetic operators category opened up and the multiply operator selected.

    In the result area, the asterisk symbol (*) represents the multiplication operator.

  3. In the Fields list box, select the operand of your expression. Open up one of the Fields categories by clicking the plus (+) symbol and then double-click the required command.

    In the exchange rate example, the value (grand total) is to be multiplied by the exchange rate. The exchange rate in this example has been set up as a report parameter. (For details, see "Using the Param Sheet", earlier in this section.)

    The following image shows the Parameter Fields category opened up and the exchange rate field selected.

  4. Click the Save button to apply the expression to the script.

  5. Click the Close button.

The Add Script Field dialog is then closed and the new script is added to the list on the Script sheet of the Catalog of Available Fields dialog.

To apply your script to your report

For details about inserting fields into your layout, see "Inserting Report Fields", earlier in this chapter, and for details about creating scripts, see Appendix A, "Using JADE Report Writer Scripts".

The Commands pane, Fields pane, and the Methods pane of the Add Script Field or Update Script Field dialog are described in:

If you encounter errors in your scripts, see "Resolving Errors in Scripts", in Appendix A.