Formatting variable data

When a Text Script, made with the Text Script Wizard (see Using the Text Script Wizard) adds variable data to a template, it can easily change the way the data are formatted as well. This is done in the Text Script Wizard through a special formatting modifier or a format mask for each field that the script adds to the template.

The locale influences the way dates, times, numbers and currencies are formatted; see Locale.

You could also format data in a script using the formatter ; see Standard Script API.

Date

Dates can only be formatted via a script. All data in the Data Model are strings; they have to be converted to Date objects before applying a particular date format. See also: Creating a Date object from a string.

Font style

Text originating from variable data can be displayed in uppercase, lowercase or proper case.

  1. Open the Text Script Wizard: double-click to open an existing script in the Scripts pane or create a new Text Script using the Text Script Wizard; see Using the Text Script Wizard.
  2. Click a data field that contains text, or add such a data field to the script with the Add field button on the right.
  3. Under Format choose the correct setting:
    • Uppercase transforms all characters to uppercase.
    • Lowercase displays transforms all characters to lowercase.
    • Propercase transforms the first character of each word to uppercase and all other characters to lowercase.
    • None leaves the text as is.
  4. Close the Script Wizard. For a new script, don’t forget to add the selector to the template.

Numbers and currencies

Numbers, and strings existing of digits, can be displayed as a number with a certain formatting or as an amount of money.

  1. Open the Script Wizard: in the Scripts pane, double-click the script, or create a new Text Script using the Text Script Wizard; see Using the Text Script Wizard.
  2. Click the data field that contains the numeric value that you want to display differently, or add the data field to the script with the Add field button on the right.
  3. Under Format choose one of the following settings:
    • Custom Pattern: allows you to enter a custom format mask. For example, the pattern 000000 means that the number should count six digits; leading zeros are added to numbers shorter than six digits. For an overview of pattern symbols see Number patterns and http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html. The custom pattern will only work if the actual value of the field can be converted from a text to a number.
    • Grouped displays a number with three decimal places and sets the thousands separator for the value based on the current locale; see Locale.
    • Currency displays a number as an amount of money, with a thousands separator and rounded to two decimal places, based on the current locale; see Locale.
    • Currency no symbol does the same as Currency, but omits the currency symbol.
  4. Close the Script Wizard. For a new script, don’t forget to add the selector to the template.