You are on page 1of 19

INPUT AND OUTPUT

VERBS
INPUT OUTPUT VERBS
 The verbs OPEN,READ,WRITE and
CLOSE are
available for such input-output operations.
ACCEPT
 Used to read low-volume data from the operator’s
console,some other hardware device or from the operating
system.
 The general format :
ACCEPT
 When the FROM option is omitted, the data is read
into the identifier from the operator’s console
 At the time of execution, a message is displayed on

the console (e.g., Enter the value) and the program is


suspended until the operator enters the data through
the console keyboard.
 Data entered by the operator will be left justified in

the identifier.
ACCEPT
 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 APARAGRAPH.
 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.
ACCEPT FLAG-1 FROM CONTROL-DATA
 will read the value of FLAG-A fro the hardware device indicated by
TYPEWRITER-1.
ACCEPT
 The DATE, DAY and TIME options are new features introduced in ANSI 74
COBOL.
 The DATE option returns the six-digit current date in the form YYMMDD
 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
DISPLAY
 used to display low-volume results on the operator’s console or some other
hardware device.
 The general format of the DISPLAY statement is
DISPLAY
 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. The operands must be of the usage
DISPLAY. The literals may be any literal or figurative constant except the ALL
literal.
 If a figurative constant is specified, only one occurrence of the constant is
displayed.
MOVE CORRESPONDING
 if the corresponding data items of both the records have identical names, then
instead of using separate MOVE statement, just one MOVE statement with the
CORRESPONDING option can be used.
MOVE CORRESPONDING
MOVE CORRESPONDING
MOVE CORRESPONDING
where dentifier-1 and identifier-2 should be group names.
editing, if specified, will be performed.
Source and destination groups can include data names that are not common.
Only those fields having identical names in the two records will take part in
the data movement.
The remaining data items in the destination group will remain unchanged.
ADD and SUBTRACT CORRESPONDING
ADD and SUBTRACT CORRESPONDING
 InADD statement numeric elementary items in the group referred
to by identifier-1 are added to and stored in the corresponding
elementary items of the group named in identifier-2.
 In UBTRACT statement, the corresponding numeric elementary
items of the group referred to by identifier-1 are subtracted from
and are stored in the corresponding numeric elementary items of
the group referred to by identifier-2.
GENERAL RULES CONCERNING CORRESPONDING
OPTION

 Identifier-1 and identifier-2 in all cases must refer to group


items i.e., these identifiers must not be data items with level
numbers 66, 77 or 88.
 Data items in identifier-1 and identifier-2 take part in the
specified operation (MOVE, ADD or SUBTRACT) only
when they have the same data name and same qualifiers up
to but not including identifier-1 and identifier-2.
GENERAL RULES CONCERNING CORRESPONDING
OPTION

 items are considered for addition or subtraction


respectively.
 This means that data items other than numeric are
not considered for the arithmetic operations even
though they may have identical names in the two
groups named in identifier-1 and identifier-2.
GENERAL RULES CONCERNING CORRESPONDING
OPTION

 All data items subordinate to identifier-1 and identifier-2


with level numbers 66 or 88 or containing a REDEFINES
or OCCURS clause, are ignored for the purpose of the
operation. Identifier-1 and identifier-2 may, however,
have a REDEFINES or OCCURS clause or may be
subordinate to data items having a REDEFINES or
OCCURS clause.
GENERAL RULES CONCERNING CORRESPONDING
OPTION

 FILLER data items are ignored.


 CORRESPONDING items can have different
locations within the group and the field sizes can
also be different.
GENERAL RULES CONCERNING CORRESPONDING
OPTION

ADD CORRESPONDING
OLD-REC TO NEWREC,
only ITEM-1 and ITEM-2
will take part in the add
operation. This is because
ITEM-3 and SEC-1 in NEW-
REC are not numeric data
items.

You might also like