TssScaler is a non-visual component that simplifies conversion between two linear scales. Neither scale need be zero based.

The TssScalerRange object uses the terms minimum and maximum, but note that range checking is not performed (the minimum need not be less than the maximum). These terms are merely convenient to refer to two points that have a known value on both scales.

For example: to convert from Fahrenheit to Celsius, set the Scale1 minimum and maximum to 32 and 212 respectively, and the Scale2 minimum and maximum to 0 and 100. (These values are chosen because 32°F = 0°C, and 212°F = 100°C, but you can use any two sets of values that are known to be equivalent.) The Scale1ToScale2 function then takes a Fahrenheit value and returns the Celsius, and the Scale2ToScale1 function takes a Celsius value and returns the Fahrenheit.

Note: If you frequently use a Fahrenheit to Celsius version of this component as described above, or any other particular version, then it is probably better to derive a specific conversion component from TssCustomScaler. The complete code for TssFahrenheitToCelsius is illustrated here.

This method has the following advantages:

  • the scale constants are fixed and cannot be inadvertently changed,
  • the ScaleXToScaleY functions can be replaced by more meaningful equivalents, such as CtoF or even ConvertCelsiusToFahrenheit.


Delphi 1 Yes    Delphi 2 Yes    Delphi 3 Yes    Delphi 4 Yes
Delphi 5 Yes Delphi 6 Yes Delphi 7 Yes Delphi 8 Yes
Delphi 2005 Yes Delphi 2006 Yes Delphi 2007 Yes


Download scaler.zip (5 KB)