Set up a script formatter
A Script Formatter can be used when one of the other formatter types are not suitable for your needs. You can customize the script to meet your requirements by following these steps:
-
On the
Project tab, in the
Configuration group, select
Project Settings
.
- Click the Formatting tab to view the formatter settings.
-
Click
Add.
The New field formatter window is displayed.
-
Type a name into the
Name field, set the Type to
Script Formatter, and click
OK.
The Properties of Script Formatter window is displayed.
-
On the
Properties of Script Formatter window, select the
Field data type from the list in the
Options group.
Sample script code is added to the text box in the Script Sample pane.
- If you want to adjust the sample code, click Select and then Copy to add a copy to the clipboard.
- Click Show Script to open the Script Code window.
- On the Edit menu select Paste to insert the copied sample code to the script editor.
-
To insert new script code, select the name of the Script Formatter from the Object list and the event (either
FormatDateField, FormatDoubleField or FormatField) from the Proc list. The code for the event is inserted in the code area.
-
In the script, you can also reuse existing formatters. The sample below shows script code that takes the result of
the Amount Formatter (AmountFormat) and adds a Euro sign (€) at the end of the formatted output text. The Amount Formatter is set
up so that only two placeholders after the decimal symbol are used.
Private Sub ScriptFormat_FormatField(ByVal FieldText As String,_ FormattedText As String, _ ErrDescription As String, _ ValidFormat As Boolean) Dim valid As Boolean valid = AmountFormat.FormatField (FieldText, _ FormattedText, _ ErrDescription) FormattedText = FormattedText + " €" ValidFormat = valid End Sub
- Close the Script Code window and test the implementation from the Testing pane of the Script Formatting Properties window.
-
In the script, you can also reuse existing formatters. The sample below shows script code that takes the result of
the Amount Formatter (AmountFormat) and adds a Euro sign (€) at the end of the formatted output text. The Amount Formatter is set
up so that only two placeholders after the decimal symbol are used.
- Click Close to save the settings and close the window.
- Optionally, click OK to close the Project Settings window.
- Save the changes to your project.