Formatting in Text Input Gadgets: Imperial Units
- Last UpdatedJan 28, 2025
- 1 minute read
The FORMAT object manages the information needed to convert the value of an object or type to a STRING, and vice versa.
The FORMAT object for a specific data type is normally a global PML Variable used for all text gadgets of that type.
For example, you can create the FORMAT object for a REAL object, so that a distance is displayed in feet-and-inches with fractions (rather than decimals) with a maximum denominator of 4:
!!RealFMT = object FORMAT()
!!RealFMT.DIMENSION = 'L'
!!RealFMT.UNITS = 'FINCH'
!!RealFMT.FRACTION = TRUE
!!RealFMT.DENOMINATOR = 4
!!RealFMT.ZEROS = 'FALSE'
For more information on the FORMAT object, refer to the Software Customization Reference documentation.
The TEXT gadget is created with type REAL and assigned a FORMAT object for converting values to and from text:
text .Dist 'Distance:' width 10 is REAL format !!RealFMT
When you assign a value in millimetres to the text gadget:
!!Form.Dist.val = 3505.2
The display-text of 11' 6 will be shown in the text gadget.
To switch from displaying feet-and-inches to displaying mm all that is necessary is to change the setting of the units member of the format object RealFMT from FINCH to MM.
The associated format also determines what can be typed into the field. If the associated format is FINCH or MM then you can enter distances in either inches or feet and inches.