Adding New Measurement Types
Go Up to Using the VCL/RTL Index
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:
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.)