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:

  1. On the Project tab, in the Configuration group, select Project Settings Project Settings icon.
  2. Click the Formatting tab to view the formatter settings.
  3. Click Add.

    The New Field Formatter window is displayed.

  4. Type a name into the Name field, set the Type to Script Formatter, and click OK.

    The Script Formatter Properties window is displayed.

  5. On the Script Formatter Properties 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.

  6. If you want to adjust the sample code, click Select and then Copy to add a copy to the clipboard.
  7. Click Show Script to open the Script Code window.
  8. On the Edit menu select Paste to insert the copied sample code to the script editor.
  9. 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.
    1. 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
      
    2. Close the Script Code window and test the implementation from the Testing pane of the Script Formatting Properties window.
  10. Click Close to save the settings and close the window.
  11. Optionally, click OK to close the Project Settings window.
  12. Save the changes to your project.