Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms
11.2 Designing Video Forms with ACCEPT and DISPLAY Statement Extensions
When you use the CONVERSION phrase with an ACCEPT numeric floating-
point operand, Compaq COBOL converts input data to floating-point (COMP-1 or
COMP-2 as appropriate). The converted result is then moved to the destination
as if moving a numeric literal equivalent to the input data with the MOVE
statement.
When an ACCEPT operand is not numeric, the CONVERSION phrase moves the
input characters as an alphanumeric string, using standard MOVE statement
rules. This lets you accept data into an alphanumeric-edited or JUSTIFIED field.
If you use the CONVERSION phrase while accepting numeric data, you can also
use the ON EXCEPTION phrase to control data entry errors.
If you do not use the CONVERSION phrase, data is transferred to the destination
item according to Format 1 ACCEPT statement rules.
11.2.5.2 Using ON EXCEPTION When Accepting Data with CONVERSION
If you enter illegal numeric data or exceed the PICTURE description (if not
protected) of the ACCEPT data (with an overflow to either the left or right of
the decimal point), the imperative statement associated with ON EXCEPTION
executes, and the destination field does not change.
Example 11–6 (and Figure 11–7) show how the ON EXCEPTION phrase executes
if you enter an alphanumeric or a numeric item out of the valid range. The
statements following ON EXCEPTION prompt you to try again.
If you do not use ON EXCEPTION and a conversion error occurs:
•
The field on the screen is filled with spaces.
•
The terminal bell rings and the terminal automatically reprompts you for the
data results.
Example 11–6 Using the ON EXCEPTION Phrase
IDENTIFICATION DIVISION.
PROGRAM-ID. ONEXC.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01
NUM-DATA
PIC S9(3)V9(3) COMP-3.
PROCEDURE DIVISION.
A00-BEGIN.
DISPLAY "Enter any number in this range: -999.999 to +999.999"
LINE 10 COLUMN 1
ERASE SCREEN.
ACCEPT NUM-DATA WITH CONVERSION LINE 15 COLUMN 16
ON EXCEPTION
DISPLAY "Valid range is: -999.999 to +999.999"
LINE 20 REVERSED WITH BELL ERASE TO END OF SCREEN
DISPLAY
"PLEASE try again... press your carriage return key to continue"
LINE PLUS REVERSED
ACCEPT NUM-DATA
GO TO A00-BEGIN.
STOP RUN.
Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms 11–13
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......