5.14 Formatting Field Values

You can specify a format in the Format Pattern field on the Field Description form. Formats are described in detail in Chapter 13, Formatting Data Values. If you leave the Format Pattern field blank, form gets the format from the default formatting set.

Form selects the appropriate conversion routine based on the data type of the field. For example, if the data type of the field is boolean, you should enter a format for boolean values in the Format Pattern field.

Form applies your format both when displaying a value on the screen, and when accepting input from the operator. On output, form always justifies the formatted value before displaying it. Numeric values (money, real, integer, or long) are right justified, other values (date, time, boolean, string, or character) are left justified. On input, form always removes trailing blanks from the entry, and justifies the entry within the field before formatting the value. Numeric values (money, real, integer, or long) are right justified, other values (date, time, boolean, string, or character) are left justified.

When you specify a Format Pattern on an Entry Allowed numeric field, your format pattern should format all values to the exact width of the field. If it does not, form may not be able to input the field value that it previously displayed. This is because the input conversion routines match your format pattern literally; if there are extra blanks at the beginning of the field (due to justification), the input conversion will fail. If you write your format pattern so that the formatted result fits exactly in the field, then form will not have to justify it. Alternatively, if your entry format is compatible with the standard input formatting rules, the conversion routines can use the standard input formatting rules when your formatting pattern fails. See the Input Formats section of Chapter 13, Formatting Data Values for more information about the standard input formatting rules.

As an example of a format pattern, lets say that you would like to display a date field (named startdate) in a form, but just show the day of the week that corresponds to the date. This should be a display only field, since the operator could not enter a complete date. The screen below shows the Field Description screen for the startdate field.

gifs/00000001.gif