MI Label Format Number

From Tuflow
Jump to navigation Jump to search

Introduction

To control the number of decimal places when creating labels for a number (float) field (eg. a Z or Elevation attribute), follow these steps.

With miTools

  1. Press the button
  2. Describe how to change the format with the .ini file. Image here

Without miTools

  1. Go to Layer Control, tick the label box for the layer you wish to label and press Label…. to display the dialog below. In the “Label with:” field, select Expression…
  2. 12.1.6.png


  3. The dialog below should now be displayed. For the expression, use the Format$() string function as shown below (this can be entered by using the Functions drop down list on the right of the dialog). The first argument is the attribute (Elevation in the example below), and the second is a format string.

  4. The attribute can be entered by using the Columns drop down list. For the format string, use something like “0.00” making sure that you provide the quotes. MapInfo uses the same (or very similar) formatting strings as Microsoft Excel does when formatting a Number cell. Examples are “0.00” to display to two decimal places, “0.0” to display to one decimal place. Examples from the MapInfo help are shown further below. The line entered in the dialog below is: Format$(Elevation,"0.00")
    12.1.6-2.png


Other Examples:

Format$( 12345, ",#") ' returns "12,345"
Format$(-12345, "$#") ' returns "-$12345"
Format$( 12345.678, "$,#.##") ' returns "$12,345.68"
Format$( 12345.678, "$,#.##;($,#.##)") 'returns "$12,345.68"
Format$(-12345.678, "$,#.##;($,#.##)") 'returns "($12,345.68)"
Format$(12345.6789, ",#.###") ' returns "12,345.679"
Format$(12345.6789, ",#.#") ' returns "12,345.7"
Format$(-12345.6789, "#.###E+00") ' returns "-1.235e+04"
Format$(-12345.6789, "#.###E-00") ' returns "-1.235e04"
Format$( 0.054321, "#.###E-00") ' returns "5.432e-02"
Format$(0.054321, "#.##%") ' returns "5.43%"
Format$(0.054321, "0.##\%") ' returns "0.05%"