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 ).
You could also format data in a script using the formatter ; see Designer Scripts 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.
- 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.
- Click a data field that contains text, or add such a data field to the script with the Add field button on the right.
- Under Format you can choose one of the following options:
- 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.
Alternatively, you can enter a custom format mask: click in the Format column for the corresponding field and start typing a pattern to format the date (and optionally, the time).
Do not put the pattern in quotes. For possible patterns see Date and time patterns. Note that this will only work if the type of the field has been set to Date in the Data Mapping Configuration and if the field contains a valid date. The locale influences the way dates, times, numbers and currencies are formatted; see Locale.
- Close the Script Wizard. For a new script, don’t forget to add the to the template.
Font style
Text originating from variable data can be displayed in uppercase, lowercase or proper case.
- 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.
- Click a data field that contains text, or add such a data field to the script with the Add field button on the right.
- 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.
- 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.
- 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.
- 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.
- Under Format choose one of the following settings:
- 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 Dynamic Tables in a Print . ∑ is for transport rules at the end of a page and ∑↑ shows the subtotal of the previous page.
Alternatively, you can enter a custom format mask: click in the Format column for the corresponding field and start typing a pattern. 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. Note that for this to work, in the the field that contains the value must be set to SmallInteger, BigInteger, Float, SmallCurrency or LargeCurrency.
- Close the Script Wizard. For a new script, don’t forget to add the selector to the template.
|
|