sign in
 
   
 
 
 
   
  COBOL TUTORIAL FOR BCA STUDENTS OF M G UNIVERSITY  
  UNIT 4: PROCEDURE DIVISION . . .  
   
     
 

ACCEPT STATEMENT

 
 

The ACCEPT statement is used to read low-volume data from the operator’s console, some other hardware device or from the operating system.

The general format of the ACCEPT statement is as follows:

 
   
 

When the FROM option is omitted, the data is read into the identifier from the operator’s console.


 
 

ACCEPT FLAG-A.

 
 

To read the value of FLAG_A from the console. The mnemonic-name option is implementer-dependent. The hardware device from which the data is to be read is to be equated to a mnemonic name in the SPECIAL-NAME paragraph.

For example, the following entry in the SPECIAL-NAMES paragraph

TYPEWRITER-1 IS CONTROL-DATA

may equate the mnemonic name CONTROL-DATA with the assumed implementor-name TYPEWRITER-1. The

 
  ACCEPT FLAG-1 FROM CONTROL-DATA.  
 

will read the value of FLAG-A fro the hardware device indicated by TYPEWRITER-1.

The DATE, DAY and TIME options are new features introduced in ANSI 74 COBOL. The DAY option returns the six-digit current date in the form YYMMDD where YY, MM and DD stand for year, month and day respectively. The DAY option returns a five-digit current date in the form YYDDD where YY stands for the year and DDD stands for the day of the year(001 to 365). The TIME option returns an eight-digit time in the form HHMMSSTT where HH, MM, SS, TT represent hour, minute, second and hundreds of a second respectively. For all the three options, the returned value is transferred to the identifier ( in the ACCEPT statement) according to the rules of the MOVE statement.

For example:


 
  ACCEPT THIS-DAY FROM DATE.  
 
will transfer the value of the current date to THIS-DAY.

 
   
  DISPLAY STATEMENT  
 

The function of the DISPLAY statement is opposite to that of the ACCEPT statement. It is used to display low-volume results on the operator’s console or some other hardware device.

The general format of the DISPLAY statement is:

 
   
 

If the UPON option is omitted, the values of the identifier-1/literal-1, identifier-2/literal- 2, etc. are displayed on the console. The UPON option with the mnemonic-name is implementor-dependent. The mnemonic name, as in the case of the ACCEPT verb, should be defined in the SPECIAL-NAMES paragraph. When more than one operand is specified, the values of the operands are displayed in the sequence they are specified. There will be no space between these values.

Example:

 
  DISPLAY “SUM IS”, THE-SUM.  
 

and suppose that the picture and current value of THE-SUM are 9(3) and 15 respectively. Upon execution of the statement, the following will be displayed on the console SUM IS015.