RAD Studio |  |

Adding New Measurement Types
See Also
Collapse All

If you want to perform conversions between measurement units not already defined in the StdConvs unit, you need to create a new conversion family to represent the measurement units (TConvType values). When two TConvType values are registered with the same conversion family, the Convert function can convert between measurements made using the units represented by those TConvType values.

You first need to obtain TConvFamily values by registering a conversion family using the RegisterConversionFamily function. After you get a TConvFamily value (by registering a new conversion family or using one of the global variables in the StdConvs unit), you can use the RegisterConversionType function to add the new units to the conversion family. The following examples show how to do this:

Creating a simple conversion family and adding units

Using a conversion function

Using a class to manage conversions

For more examples, refer to the source code for the standard conversions unit (stdconvs.pas). (Note that the source is not included in all editions of Delphi.)

See Also

Performing Conversions

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!