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 available formatting functions depend on the data type of the corresponding field in the Data Model. In a data mapping configuration you can set the data type of each field. When you open a data file or database without a data mapping configuration, all fields are text fields (fields of the type string).

When the software warns about a mismatch between the type of a field in the wizard and in the current data model, click the Refresh Types button to update field types in the wizard to match the types in the data model.

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 in variable data can be displayed as long, medium and short dates with different time displays. There are quite a few presets, but you can also enter a custom format mask.

  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 you can choose one of the following options:
    • Custom Pattern opens a dialog in which you can enter a custom pattern the date (and, optionally, the time). The dialog shows an example of a date formatted according to the given pattern.
      Do not put the pattern in quotes. For possible patterns see Date and time patterns.
      The Custom Pattern option is only available when the type of the field has been set to Date in the data mapping configuration and the field contains a valid date.
    • Default Date displays the date with the default pattern for the current Locale.
    • Short Date displays the day, month and year in two digits each, for example 01.04.16.
    • Medium Date displays the day and month in two digits each and the year in four digits, for example 01.04.2016. (This is also the value of the Default Date.)
    • Long Date displays the day as a number, the month's full name and the year in four digits, for example 1. April 2016.
    • Short Time displays a time in hours and minutes in two digits each, for example 00:00.
    • Medium Time displays a time in hours, minutes and seconds in two digits each, for example 00:00:00. (This is also the value of the Default Time.)
    • Long Time displays a time in hours, minutes and seconds in two digits each, and adds a time zone, for example 00:00:00 EDT.
    • Short Date/Time displays the date as a short date and the time as a short time, for example 01.04.16 00:00.
    • Medium Date/Time displays the date as a medium date and the time as a medium time, for example 01.04.2016 00:00:00 (This is also the value of the Default Date/Time.)
    • Long Date/Time displays the date as a medium date and the time as a medium time, for example 1. April 2016 00:00:00 EDT.
  4. Close the Script Wizard. For a new script, don’t forget to add the selector to the template.

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. There are a few presets, but you can also type a format mask.

  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. In the data mapping configuration, set the field type to Integer, Float or Currency. When you open a data file or database, all fields are text fields (fields of the type string).
    • Standard: displays the number with the default pattern and symbols for the current Locale.
    • 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.
    • Leading zero adds a leading zero to a floating value between 0 and 1. This format is only available for fields that contain a float value. Note that when you open a data file or database without a data mapping configuration, all fields are of the type string.
    • ∑ (Sum) and ∑↑ (Sum Up) are used in Detail Tables in a Print context. is for transport rules at the end of a page and ∑↑ shows the subtotal of the previous page.
  4. Close the Script Wizard. For a new script, don’t forget to add the selector to the template.