The ACCEPT statement causes data keyed at the console or supplied by the operating system to be made available to the program in a specified data item.
Identifier can be an
internal floating-point data item.
The size of a data transfer is determined by the device and the run-time environment (see The SPECIAL-NAMES Paragraph for a list of function-names that can be used and your COBOL system documentation for details of devices and the limits of data transfer sizes).
If the device is capable of transferring data of the same size as the receiving data item, the transferred data is stored in the receiving data item. If otherwise, then:
If the FROM option is not given, it is equivalent to specifying FROM CONSOLE.
If the current command-line argument number is 0, it is intended that the program-name of the main program of the run unit will be returned. However, the effects of variations on program invocation can impact these results so that a utility or calling program can be returned instead.
If the current command-line argument number
is not in the range 0 to
99 inclusive or
exceeds the number of arguments on the command line when this ACCEPT statement is executed, imperative-statement-1, if specified, will be executed.
DAY-OF-WEEK,
and TIME are conceptual data items and, therefore, are not described in the COBOL program.
Char | Contents |
---|---|
1-2 | The two right-most numeric characters of the year in the Gregorian calendar. |
3-4 | Two numeric characters of the month of the year in the range 01 through 12. |
5-6 | Two numeric characters of the day of the month in the range 01 through 31. |
Char | Contents |
---|---|
1-4 | Four numeric characters of the year in the Gregorian calendar. |
5-6 | Two numeric characters of the month of the year in the range 01 through 12. |
7-8 | Two numeric characters of the day of the month in the range 01 through 31. |
Char | Contents |
---|---|
1-2 | The two right-most numeric characters of the year in the Gregorian calendar. |
3-5 | Three numeric characters of the day of the year in the range 01 through 366. |
Char | Contents |
---|---|
1-4 | Four numeric characters of the year in the Gregorian calendar. |
5-7 | Three numeric characters of the day of the year in the range 01 through 366. |
If EXCEPTION STATUS is to be examined this should be done immediately following the CALL statement. There must be nothing between the CALL and ACCEPT FROM EXCEPTION STATUS. File I-O operations will alter the exception status value making it unpredictable.
Unless otherwise specified in the CURSOR IS clause (see the section The CURSOR IS Clause earlier in this chapter), the cursor is initially positioned at the start of the first item. As the ACCEPT operation into each item is terminated, the cursor moves to the start of the next item.
In addition to the options available as screen description clauses, the following options can be used in the WITH phrase; SPACE-FILL, ZERO-FILL, LEFT-JUSTIFY, RIGHT-JUSTIFY TRAILING-SIGN and UPDATE. ZERO-FILL appears in this list and as a screen description clause because it has two different uses. Its second use is documented later in this chapter.
A configuration option is available which allows the entry of data into numeric and numeric edited screen fields in free format mode. In COBOL, nonedited numeric data items are intended for holding data in an internal form; however, this format enables such data items to appear on the screen. See your COBOL system documentation on user interfaces for more details. If free format mode is in effect, the data will appear automatically reformatted as follows:
The SPACE-FILL, ZERO-FILL, LEFT-JUSTIFY, RIGHT-JUSTIFY and TRAILING-SIGN options amend this format.
ACCEPT INPUT-FIELD TIME-OUT AFTER +10
a timeout would occur after 10 seconds had elapsed from the beginning of the ACCEPT, even if some characters were entered after 5 seconds into the ACCEPT processing.
If, on the other hand, ADIS were configured to do resets, if a program had the same code given above, then each time a new character were entered, the TIMEOUT "clock" would be reset to zero.
The ADD statement causes two or more numeric operands to be summed and the result to be stored.
The ALTER statement modifies a predetermined sequence of operations.
The ALTER statement is
classed as an obsolete element in the ANSI'85 standard and is scheduled to be
deleted from the next full revision of the ANSI Standard.
All dialects in this COBOL
implementation fully support this syntax. The FLAGSTD Compiler directive can be
used to detect all occurrences of this syntax.
Although it is a part of the
standard COBOL definition, this verb is explicitly excluded from the X/Open
COBOL language definitions and should not be used in a conforming X/Open COBOL
source program.
All other uses of the ALTER statement are valid and are performed even if procedure-name-1, procedure-name-3 is in an overlayable fixed segment.
The CALL statement causes control to be transferred from one object program to another within the run unit.
You may CALL the target
object program procedure indirectly, by address. Data, pointers to data, and
pointers to procedures can be passed as parameters to the called program
procedure, and returned by it. Parameter passing conventions can be controlled
in order to allow the called program procedure to be written in languages other
than COBOL, using different conventions.
A called COBOL program
can recursively call itself when it has the recursive attribute.
Syntax rules marked with an asterisk (*) are common to the CALL statement and to the CHAIN statement. In these rules, where "CALL or CHAIN statement" is specified, you should read "CALL statement" or "CHAIN statement" when applying the rules to the CALL statement or the CHAIN statement respectively.
Mnemonic-name must be
defined in the SPECIAL-NAMES paragraph. See the section The SPECIAL-NAMES
Paragraph earlier in this chapter for details of how to do this and
your COBOL system documentation on interfacing for details of
which calling conventions are supported in your run-time environment.
, literal-2
, and literal-3
must be nonnumeric literals and cannot be a figurative constant.
Local-Storage Section
or Linkage Section, and must be a level 01 data item, or a level 77 data item
, or an elementary item
, or any group item.
, Local-Storage Section
or Working-Storage Section,
and must be a level 01
data item, a level 77 data item
, or other level data
item.
General rules marked with an asterisk (*) are common to the CALL statement and to the CHAIN statement. In these rules, where "CALL or CHAIN statement" are specified, you should read "CALL statement" or "CHAIN statement" when applying the rules to the CALL statement or the CHAIN statement respectively.
or called procedure.
The program in which the CALL statement appears is the calling program. If the program being called is a COBOL program, literal-1 or the content of the data item referenced by identifier-1 must contain the program-name contained in the PROGRAM-ID paragraph of the called program (see The Program-ID Paragraph earlier in this chapter, particularly in regard to case sensitivity),
or the entry-name
contained in the ENTRY statement of a called program that must have been called
previously and not canceled since. Alternatively, the name of the called
program may be a name which identifies a file that contains executable program
code for the called program. The result of specifying different names that
identify the same file in two CALL statements or a CALL and a CANCEL statement
are operating system specific. See your COBOL system documentation for details
of how your system matches the given name to previously called programs,
program filenames or programs held in library files.
If the program being
called is not a COBOL program, the rules for the formation of the program or
procedure name are given in the COBOL system documentation on interfacing.
or ON EXCEPTION
phrase is ignored and control is passed to the end of the CALL statement
or, if the NOT ON
EXCEPTION phrase is specified control is passed to imperative-statement-2. If
control is passed to imperative-statement-2, execution continues according to
the rules for each statement specified in imperative-statement-2. If a
procedure branching or conditional statement which causes explicit transfer of
control is executed, control is transferred in accordance with the rules for
that statement; otherwise, upon completion of the execution of
imperative-statement-2, control is transferred to the end of the CALL
statement.
If the program specified by the CALL is not resident in memory, is not available for dynamic loading or is available but finds insufficient memory in which to load, then the program cannot be made available at that time and one of the following two actions will occur:
or ON EXCEPTION
phrase is specified in the CALL statement, control is transferred to imperative-statement-1. Execution then continues according to the rules for each statement specified in imperative-statement-1. If a procedure branching or conditional statement which causes explicit transfer of control is executed, control is transferred in accordance with the rules for that statement; otherwise, upon completion of execution of imperative-statement-1, control is transferred to the end of the CALL statement
and the NOT ON
EXCEPTION phrase, if specified, is ignored.
Program execution
will stop, without an implicit CLOSE statement for any file that is in open
mode in the run unit, and a run time error will be displayed.
Two or more COBOL
programs in the run unit can have the same program-name, and the reference in a
CALL statement to such a program-name is resolved by using the scope of names
conventions for program-names. See the section Conventions for Program-names
in the chapter Concepts of the COBOL Language.
For example, when two
programs in the run unit have the same name as that specified in a CALL
statement:
The mechanism used in
this example is as follows:
If the called program is not COBOL, it is only in its initial state the first time it is called within a run unit. A CANCEL of such a program has no effect.
On all other entries into the called program, the state of the program and each program directly or indirectly contained within it remains unchanged from its state when last exited. Some implementations of languages other than COBOL may provide alternative semantics and, if available, these will be detailed in your COBOL system documentation on interfacing.
On all other entries into
the called program, the states and positioning of all such files is the same as
when the called program was last exited.
or ENTRY statement
of the called program, in which case the number of operands in each USING phrase must be identical.
The number of operands
need not be identical.
or CHAIN
statement and in the corresponding USING phrase in the called program's PROCEDURE DIVISION header
or ENTRY statement or
parameter list if the called program is not COBOL
determines the correspondence between the data names used by the calling and called programs. This correspondence is positional and not by name equivalence; the first operand in the CALL
or CHAIN
statement's USING phrase corresponds to the first operand in the called program's USING phrase or parameter list, the second to the second, etc.
If the correspondence
cannot be completed because the numbers of operands are different, then if the
remaining unmatched operands are in the CALL or CHAIN statement they are
ignored and if they are in the PROCEDURE DIVISION header or ENTRY statement or
parameter list then they must not be referenced within the called program. The
positional correspondence may vary depending on the calling conventions implied
by mnemonic-name.
In the case of index-name, no such correspondence is established. Index-names in the called and calling programs always refer to separate indices.
and BY VALUE
phrases are transitive
across the parameters which follow them until another BY CONTENT, BY REFERENCE
or BY VALUE
phrase is encountered.
If no BY CONTENT, BY
REFERENCE
or BY VALUE
is specified prior to the
first parameter, the BY REFERENCE phrase is assumed.
either specified or
implied for a parameter, the program operates as if the corresponding data item in the called program occupies the same storage area as the data item in the calling program. The description of the data item in the called program must describe the same number of character positions as described by the description of the corresponding data item in the calling program.
If the BY REFERENCE
ADDRESS OF phrase is specified or implied then the program operates as if an
additional data item had been declared with USAGE POINTER and that data item
passed BY REFERENCE with a value acquired by a SET data item TO ADDRESS OF
identifier-3 statement.
If identifier-3 is in
the Linkage Section and has a level number other than 01 or 77 or is in the
Working-Storage Section, it is equivalent to passing the item BY CONTENT and
the address of identifier-3 cannot be modified by the called subprogram.
If the BY REFERENCE
literal-2 phrase is specified or implied then the object program processes
literal-2 as described for literal-3.
If the BY CONTENT phrase
is specified or implied for a parameter, the object program operates as if an
additional data item had been declared and this additional data item used as
the parameter in a BY REFERENCE phrase. If identifier-4 is specified, then both
the implied data description of the additional data item and its contents are
identical to that of identifier-4. If literal-3 is specified, then the implied
data description of the additional item is equivalent to an alphanumeric data
item with the same size as literal-3 and with its contents set to the value of
literal-3. If LENGTH OF identifier-5 is specified, then the data description of
the additional item is equivalent to PIC S9(n) USAGE COMP-5, where the value of
n is at least 9 and defines a data item that is large enough to hold the
maximum length of a data item in the COBOL system. The contents of the
additional data item are set to the number of bytes of storage allocated to
identifier-5.
If identifier-6 is
specified and is BINARY, COMP-4, COMP-5 or COMP-X, then the data description of
the additional data item is identical to that of identifier-6, except its usage
is COMP-5. The contents of the additional data item are identical to the COMP-5
representation of the contents of identifier-6. This conversion and
representation facilitates calling non-COBOL programs.
Otherwise, if
identifier-6 is specified then the implied data description of the additional
data item and its contents are identical to that of identifier-6.
If integer-1 is
specified, then the data description of the additional item is equivalent to a
signed numeric item USAGE COMP-5 that occupies the number of bytes of storage
indicated by the value of integer-2, if specified, or the size of the system
area otherwise (typically the size of a POINTER on the system).
If LENGTH OF identifier-7
is specified, then the data description of the additional item is equivalent to
PIC S9(n) USAGE COMP-5, where the value of n is at least 9 and defines a data
item that is large enough to hold the maximum length of a data item in the
COBOL system. The contents of the additional data item are set to the number of
bytes of storage allocated to identifier-7.
If the program being
called is a COBOL program, each parameter in the BY VALUE phrase of the CALL
statement must have a corresponding parameter declared in the USING phrase of
the PROCEDURE DIVISION header that also has the BY VALUE phrase specified or
implied.
The additional data item
generated as a result of the CALL statement, described above, is related to
this corresponding parameter in the called program, as follows.
If the additional data
item was subject to conversion from BINARY, COMP-4, COMP-5 or COMP-X to COMP-5,
then the data description of the corresponding parameter in the called program
must be identical to that of the data description of the additional data item
with the exception that the corresponding parameter's USAGE can be any of
BINARY, COMP-4, COMP-5 or COMP-X. On entry to the called COBOL program, a
conversion from the USAGE COMP-5 of the additional data item to the USAGE of
the corresponding parameter in the called program is performed.
If the additional data
item was not subject to conversion to COMP-5, the data description of each
parameter in the called program must be the same as the corresponding
additional data item. This means there is no conversion or extension or
truncation, of the additional data item to match the corresponding parameter in
the called program.
If the program being
called is not COBOL, the size of the additional data item should not exceed the
maximum size of the system area (typically the size of a POINTER on the
system); otherwise the system might become catastrophically corrupt.
The size of the system
area (typically the size of a POINTER on the system) is determined outside the
COBOL system and limits the maximum value the return value can take, but the
return value might not utilize the full size of the system area. The returned
value is available to the calling program after control is returned, either
implicitly in the special register RETURN-CODE or explicitly in the data item
specified in the GIVING phrase.
unless that calling
program has the recursive attribute.
or USAGE
PROCEDURE-POINTER
that were originally
derived from the address of a data item
or procedure
that is contained within
a called program become invalid and must not be used after a CANCEL statement
that references that called program is executed.
The CANCEL statement ensures that the next time the referenced program is called it will be in its initial state.
If the name contains the entry-name contained in an ENTRY statement, the results are undefined.
or GOBACK
statement.
or by execution of an
EXIT PROGRAM statement in a called program that possesses the initial
attribute.
The CHAIN statement transfers control from one object program to another in the run unit with no subsequent return of control. The effect is as though the chained program is the main program in the new run unit.
The chained program must be a COBOL program that is not a nested program. The name of the chained program must contain the name contained in the PROGRAM-ID paragraph of the chained program (see The Program-ID Paragraph earlier in this chapter particularly in regard to case sensitivity). Alternatively, the name of the chained program may contain a name which identifies a file that contains executable program code for the chained program. See your COBOL system documentation for details of how your system matches the given name to previously chained programs, program filenames or programs held in library files.
The CLOSE statement terminates the processing of reels/units and files, with optional rewind and/or lock or removal where applicable.
The statements CLOSE REEL
WITH LOCK and CLOSE UNIT WITH LOCK are treated as equivalent to CLOSE REEL FOR
REMOVAL.
It is documentary only.
Table 12-1: Relationship of Categories of Files and the Formats of the CLOSE Statement
CLOSE Statement Format | File Category | |||
---|---|---|---|---|
Non-Reel/Unit | Record Sequential Single-Reel/ Unit | Record Sequential Multi-Reel/ Unit | Non-record Sequential Single/ Multi-Reel/ Unit | |
CLOSE | C | C, G | A, C, G | C |
CLOSE WITH LOCK | C, E | C, E, G | A, C, E, G | C, E |
CLOSE WITH NO REWIND record sequential only |
![]() |
B, C | A, B, C | X |
CLOSE REEL/UNIT record sequential only |
![]() |
![]() |
F, G | X |
CLOSE REEL/UNIT FOR REMOVAL record sequential only |
![]() |
![]() |
D, F , G | X |
CLOSE REEL/UNIT WITH NO REWIND record sequential only | X | X | F, B | X |
The definitions of the symbols in the table are given below. Where the definition depends on whether the file is an input, output or input- output file, alternate definitions are given; otherwise, a definition applies to input, output, and input-output files.
Input Files and Input-Output Files:
All reels/units in the file prior to the current reel/unit are processed except those reels/units controlled by a prior CLOSE REEL/UNIT statement. If the current reel/unit is not the last in the file, the reels/units in the file following the current one are not processed.
Output Files:
All reels/units in the file prior to the current reel/unit are processed except those reels/units controlled by a prior CLOSE REEL/UNIT statement.
The current reel/unit is left in its current position.
Input Files and Input-Output Files (Sequential Access Mode):
If the file is at the end and label records are specified for the file, the labels are processed according to the operating system label convention. The behavior of the CLOSE statement when label records are specified but not present, or when label records are not specified but are present, is undefined. If the file is at the end and label records are not specified for the file, label processing does not take place, but other closing operations dependent on the run-time system are executed. If the file is not at the end, the closing operations dependent on the RTS are executed, but there is no ending label processing.
Input Files and Input-output Files (Random or Dynamic Access Mode); Output Files (Random, Dynamic or Sequential Access Mode):
If label records are specified for the file, the labels are processed according to the operating system standard label convention. The behavior of the CLOSE statement when label records are specified but not present, or when label records are not specified but are present, is undefined. If label records are not specified for the file, label processing does not take place, but other closing operations dependent on the run-time system are executed.
The reel or unit can be accessed again, in the proper order of reels or units in the file, if a CLOSE statement without the REEL or UNIT phrase has previously been executed for this file followed by the execution of an OPEN statement for the file.
This file cannot be opened again during this execution of this run unit.
Input Files and Input-Output Files (Reel/Unit Media):
Output Files (Reel/Unit Media):
The following operations take place;
Input Files, Input-Output Files, and Output Files (Non-Reel/Unit Media):
Execution of this
statement is considered successful. The file remains in the open mode, the file
position indicator remains unchanged, and no action takes place except as
specified in General Rule 4.
The current reel or analogous device is positioned at its physical beginning.
The CLOSE statement
is executed as if none of the optional phrases is present.
This is an illegal combination of a CLOSE option and a file category. The results at object time are undefined.
Except where otherwise stated in the general rules below, the terms "reel" and "unit" are equivalent and completely interchangeable in the CLOSE statement. Treatment of sequential mass storage files is logically equivalent to the treatment of a file on tape or analogous sequential media.
(This option has no
connection with the record or file locking used when sharing files.)
other than a delete file
can be executed that references that file, either explicitly or implicitly, unless an intervening OPEN statement for that file is executed.
The COMMIT statement releases all record locks in all files held by this run unit. For COBOL systems that support the WITH...ROLLBACK clause of the SELECT statement as other than documentary, COMMIT indicates the end of the current transaction and makes the effects of that transaction permanent.
The COMPUTE statement assigns to one or more data items the value of an arithmetic expression.
or a floating-point
item.
The intermediate results
obtained during the expression evaluation are truncated as if they were moved
to data items whose PICTURE is determined by the COBOL system. This behavior is
selected using the ARITHMETIC Compiler directive.
The CONTINUE statement is a no operation statement, indicating that no executable statement is present.
The DELETE statement logically removes a record from a mass storage file. It can be specified only for files with relative or indexed organization.
This rule is not
enforced.
and NOT INVALID KEY
phrase
in the DELETE statement. (See the section The INVALID KEY Condition in this chapter.)
The DELETE FILE statement physically removes the specified files from the physical devices on which they reside.
The DISPLAY statement causes data to be transferred from specified data items to the appropriate hardware device, such as the CRT screen.
The DISPLAY statement also
transfers data from your program to the CRT or video terminal screen:
non-scrolling forms, into which you can enter data, are displayed.
This restriction can be
ignored.
All permissible
function-names other than those specifically mentioned in the general rules for
Format 1 of the DISPLAY statement are treated as equivalent to CONSOLE and each
operand is transferred to the console device in the order listed. The total
size of data displayed is equal to the sum of the sizes of each operand. The
display starts from the current cursor position, overflowing onto the following
line(s) if necessary.
On earlier releases,
trailing spaces after the last operand were not displayed.
In addition to the
options available as screen description clauses, the following options can be
used in the WITH phrase; SPACE-FILL, ZERO-FILL, LEFT-JUSTIFY, RIGHT-JUSTIFY
TRAILING-SIGN and UPDATE. ZERO-FILL appears in this list and as a screen
description clause because it has two different uses. Its second use is
documented later in this chapter.
A configuration option is
available which allows the entry of data into numeric and numeric edited screen
fields in free format mode. In COBOL, nonedited numeric data items are intended
for holding data in an internal form; however, this format enables such data
items to appear on the screen. See your COBOL system documentation on user
interfaces for more details. If free format mode is in effect, the data will
appear automatically reformatted as follows:
The SPACE-FILL,
ZERO-FILL, LEFT-JUSTIFY, RIGHT-JUSTIFY and TRAILING-SIGN options amend this
format.
The entire screen is cleared either when the BLANK SCREEN option is specified or when literal-1 is SPACES and the DISPLAY starts at line 1 column 1.
The DIVIDE statement divides one numeric data item into others and sets the values of data items equal to the quotient and remainder.
Copyright © 2001 Micro Focus International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.