Fixed-format mode is also known as formatted mode. It can best be described as "What you see is what you get". As each key is pressed, the field is automatically reformatted to conform to the picture string. The enhanced ACCEPT/DISPLAY syntax tries to ensure that the field always looks on the screen as it is stored in the Data Division, and its size is the same as the size of the data item.
Therefore, as with the DISPLAY statement, it is only really sensible to accept fields that are defined as USAGE DISPLAY with no implied sign or decimal point.
During data entry, characters other than numeric digits, the plus sign (+), minus sign (-) and the decimal point (.) are rejected. Insertion characters in edited fields are automatically skipped over as the cursor is moved backward and forward. Any sign indicator is automatically modified if a + or - is pressed, regardless of where the cursor is in the field.
Zeros are allowed as insertion characters only as a leading symbol before a decimal point, or as a trailing symbol following a decimal point. For example, PIC 0.9999 and PIC 999.90 are valid, but PIC 0.0009 and PIC 999.000 are not.
Data entry of simple numeric and numeric-edited fields with no zero suppression is similar to that for alphanumeric fields, except that insert mode is not supported in numeric and numeric-edited fields. If the decimal point character is pressed in a simple numeric field, the digits are right justified. For example, a field defined as PIC 9(5) which initially contains zeros is accepted as follows ( underscored characters indicate cursor position):
Initial display |
00000 |
Pressing 1 gives |
10000 |
Pressing 2 gives |
12000 |
Pressing 4 gives |
12400 |
Pressing Backspace gives |
12000 |
Pressing "." gives |
00012 |
Data entry into zero-suppressed fields is handled differently. The cursor is initially placed on the first character position that is not zero-suppressed. If all the digits before the decimal point are suppressed, the cursor is positioned on the decimal point itself.
While the cursor is to the left of the decimal point; that is, in the integer part of the field, the cursor moves to the right as digits are entered until the decimal point is reached. Any further digits are inserted immediately before the decimal point until all the integer places are filled. The cursor is then automatically moved to the first decimal digit and advances as the decimal digits are entered.
If you wish to enter digits after the decimal point when there are integer places still unfilled, the decimal point (.) must be entered.
For example, assume that a numeric-edited data field is defined as PIC ZZZ99.99 and initially contains zeros, the field is displayed as follows during the ACCEPT:
Initial display |
00.00 |
Pressing 1 gives |
10.00 |
Pressing 2 gives |
12.00 |
Pressing 3 gives |
123.00 |
Pressing 4 gives |
1234.00 |
Pressing Backspace gives |
123.00 |
Pressing 5 gives |
1235.00 |
Pressing 6 gives |
12356.00 |
Pressing 7 gives |
12356.70 |
Pressing 8 gives |
12356.78 |
If you want to enter 123.45 into the same field, the field appears as follows:
Initial display |
00.00 |
Pressing 1 gives |
10.00 |
Pressing 2 gives |
12.00 |
Pressing 3 gives |
123.00 |
Pressing "." gives |
123.00 |
Pressing 4 gives |
123.40 |
Pressing 5 gives |
123.45 |
Fixed format mode is only allowed on numeric-edited data items of up to 32 characters in length. If they are longer than 32 characters, they are automatically handled in free-format mode as described in the section Free-format Data Entry. Fields are also automatically treated as free-format if a SIZE clause is specified in the ACCEPT statement.