Using TParameterFormatter

TParameterFormatter is a special formatter class that handles a string of text containing one or more variable elements. Each variable can be any type of formattable data. You attach the appropriate formatter to each variable so that it is handled correctly at run time.

Each TParameterFormatter has a text template, defining the content of the text string. You set the text template through either the TParameterFormatter constructor or the SetTemplate member function. You then index the parameters, beginning at zero, and identify the type of each one by specifying a class name token. The parameter types are all formattable data types. For example, parameter 0 might be of type TFormattableNumber. You can also specify a text-ordering object when you construct the TParameterFormatter to provide language-sensitive, case-insensitive scanning.

At run time, you pass the TParameterFormatter instance a TFormattableParameterList instance that lists the values for each parameter. The TParameterFormatter raises an exception if it receives a parameter of the wrong formattable type.


TParameterFormatter can also scan text strings and return data parameters. You pass the Scan member function a list of the correct formattable data types, and it scans the text, returning the list of parameters.

In later releases, the Formatting framework will provide an editor for creating and modifying TParameterFormatter instances. When programming, you can create messages simply by typing in the text template, marking each variable range as a parameter and associating each parameter with a particular type of formattable data. Localizers can then use the same editor to create a translated version of the text template and attach formatters appropriate for a particular locale, without needing access to your code.

NOTE Currently, messages can be localized if your TParameterFormatter instance is accessible. See "Localizing TParameterFormatter instances" on page 226 for more information.

TParameterFormatter returns information about the results of an operation in either a TParameterFormatResult or a TParameterScanResult instance. These classes maintain a list of TFormatResult of TScanResult instances, each one describing the accuracy of the conversion for a single parameter.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker