Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Hull and Outfitting

Formatting in Text Input Gadgets: Imperial Units

  • Last UpdatedJan 09, 2024
  • 2 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'

See the Software customization Reference Manual for further information on the FORMAT object.

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 we assign a value in millimeters 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.

For example:

Chosen Units

Typed-in Value

Displayed Value

FINCH

138

11' 6

INCH

138

138

INCH

11' 6

138

MM

3505.2

3505.2

Note that in every case the text field value is actually held in millimeters so that the command:

q var !!Form.Dist.val

prints

3505.2.

You can use the format object in your PML code when converting a value to a STRING:

!StringValue = !!Form.Dist.val.String(!!RealFMT)

Related Links
TitleResults for “How to create a CRG?”Also Available in