Deriving String Fields

The following example shows how you can derive string fields by using a single expression script.

In this example:

For details about the Fields pane, see Appendix C, "Script Fields".

To create a new script

  1. Click the New button on the Catalog of Available Fields dialog.

    The Add Script Field dialog is then displayed.

  2. Enter a name for your script in the Script Name text box.

In the example in the following image, the script has been named addresses.

To select the first field to concatenate

The field is then displayed on the Script Code sheet, as shown in the following image.

To select the concatenation symbol

At this stage, you could complete the expression simply by selecting the second address field. However, the address fields are to be separated by a comma and a space in this example.

To concatenate the comma separator

To concatenate the second string

  1. Select the concatenation symbol again (as described earlier in this section).

  2. In the Fields list box, double-click the field that you want to concatenate.

    In the example, this is the second address field; that is, address2.

The expression is now complete, as shown in the following image.

To complete the script, you need to set the return type. In this case, two address fields have been joined so it may also be necessary to extend the length of the result field to accommodate the combined strings.

To set the return type and change the length

  1. Click the Define Return Type button in the top right corner of the Add Script Field dialog.

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

  2. Select the type from the Type list box. In this case, the String default return type is selected.

  3. Enter a length in the Length text box. In this case, the length has been set to 60 to accommodate the combined address fields.

  4. Click the Apply button to complete the definition.

The Define Script Return Type dialog is then closed and the return type is displayed in the Return Type list box in the top right of the Add Script Field dialog.

For more details about return types, particularly for users who are new to scripting concepts, see "Return Types and Parameters", earlier in this appendix.

To complete the script

The new script is then listed on the Script sheet of the Catalog of Available Fields dialog.

To include it in your report design, drag it on to the layout, as shown in the following image.

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