Data Division (cont) [ COBOL/HP-UX Language Reference for the Series 700 and 800 ] MPE/iX 5.0 Documentation
COBOL/HP-UX Language Reference for the Series 700 and 800
Data Division (cont)
The VALUE Clause
Function
The VALUE clause defines the value of constants, the initial value of
working storage items, and the values associated with a condition name.
General Formats
Format 1
VALUE IS literal-1
Format 2
Format 3
Syntax Rules
1. A signed numeric literal must have associated with it a signed
numeric PICTURE character-string.
2. All numeric literals in a VALUE clause of an item must have values
which are within the range of values indicated by the PICTURE
clause, and must not have a value which would require truncation
of nonzero digits. Nonnumeric literals in a VALUE clause of an
item must not exceed the size indicated by the PICTURE clause.
________________________________________________________________________
|(OSVS) (VSC2) (MF) |
| |
| |
| |
|3. The VALUE clause is allowed for internal floating-point data |
| items. |
| |
________________________________________________________________________
________________________________________________________________________
|(OSVS) |
| |
| |
| |
|4. VALUES ARE can be used with format 1. |
| |
________________________________________________________________________
________________________________________________________________________
|(MF) |
| |
| |
| |
|5. The VALUE clause is allowed for external floating-point data |
| items. |
| |
________________________________________________________________________
Format 2
[REV BEG]
6. The words THRU and THROUGH are equivalent.
7. Any number of format 2 entries can be written for a data item.
8. Format 2 must be used only in connection with a condition-name.
9. In a condition-name entry, the VALUE clause is required. The VALUE
clause and the condition-name itself are the only two clauses
permitted in the entry.
10. Literal-2 must be less than literal-3.[REV END]
________________________________________________________________________
|[REV BEG](MF) |
| |
| |
| |
|11. Literal-4 must not be equal to any literal-2, and in any |
| literal-2 THROUGH literal-3 pair, literal-4 cannot be greater |
| than or equal to literal-2 and less than or equal to |
| literal-3.[REV END] |
| |
________________________________________________________________________
Format 3
12. All identifiers must have been previously defined. If either
identifier-1 or identifier-2 is a group item, the definition of that
group must have been completed by the appearance of another data
item at the same or lower level number.
13. If literal-5 is an alphanumeric literal, then no operator may follow
it.
14. Literal-5 and integer-1 must not be floating-point values and must
not be negative values.
General Rules
1. The VALUE clause must not conflict with other clauses in the data
description of the item or in the data description within the
hierarchy of the item. The following rules apply:
a. If the category of the item is numeric, all literals in the
VALUE clause must be numeric. If the literal defines the
value of a working storage item, the literal is aligned in
the data item according to the standard alignment rules.
(See the section "Standard Alignment Rules" in the
chapter COBOL Concepts.)
b. If the category of the item is alphabetic, alphanumeric,
alphanumeric edited or numeric edited all literals in the
VALUE clause must be nonnumeric. The literal is aligned in
the data item as if the data item had been described as
alphanumeric. (See the section "Standard Alignment Rules"
in the chapter COBOL Concepts.) Editing characters in
the PICTURE clause are included in determining the size of
the data item (see the section "The PICTURE Clause"
earlier in this chapter) but have no effect on
initialization of the data item. Therefore, the VALUE for
an edited item is presented in an edited form.
________________________________________________________________________
|(MF) |
| |
| |
| |
|c. If the item is numeric edited, the value can be a numeric |
| literal or a nonnumeric literal. If the value is a numeric |
| literal, the value contained in the item will be the same as |
| if the numeric literal were moved to the numeric edited |
| item. |
| |
________________________________________________________________________
d. Initialization takes place independent of any BLANK WHEN ZERO
or JUSTIFIED clause that can be specified.
2. A figurative constant can be substituted in both Format 1 and
Format 2 wherever a literal is specified.
________________________________________________________________________
|(OSVS) (VSC2) (MF) |
| |
| |
| |
|3. Any VALUE clause associated with COMPUTATIONAL-1 |
| or COMPUTATIONAL-2 (internal floating-point) items must |
| specify a floating-point literal. The condition-name VALUE |
| phrase must also specify a floating-point literal. In |
| addition, the figurative constant ZERO and both integer |
| and decimal forms of the zero literal can be specified |
| in a floating-point VALUE clause or condition-name VALUE |
| phrase. |
| |
|4. A VALUE clause can not be specified for external floating-point |
| items. |
| |
| A VALUE clause can be specified for external floating-point |
| items. (MF) |
| |
________________________________________________________________________
5. The characteristics of a condition-name are implicitly those of its
associated conditional variable.
6. The FALSE phrase is meaningful only if the associated condition-name
is referenced in a SET condition-name to FALSE statement. (See the
section "The SET Statement" earlier in this chapter.)
Condition-Name Rules
7. In a condition-name entry, the VALUE clause is required. The VALUE
clause and the condition-name itself are the only two clauses
permitted in the entry. The characteristics of a condition-name are
implicitly those of its conditional variable.
8. Format 2 can only be used in connection with condition- names.
Wherever the THRU phrase is used, literal-1 must be less than
literal-2, and so on.
9.
________________________________________________________________________
|(OSVS) (VSC2) (MF) |
|A condition-name entry can not be associated with an external |
|floating-point item but can be associated with an internal |
|floating-point item. |
________________________________________________________________________
________________________________________________________________________
|(MF) |
|A VALUE clause can be specified for external floating-point |
|items. |
________________________________________________________________________
________________________________________________________________________
|Constant-Name Rules |
| |
|(MF) |
| |
| |
| |
|10. Format 3 can be used only in a constant-name entry. |
| |
|11. The characteristic of the constant-name is that of an integer if |
| Format 3 is used, and is that of the literal if Format 1 is |
| used. |
| |
|12. Any number of arithmetic or logical operators can be used. The |
| result is evaluated using integer arithmetic in strict |
| left to right order. No parentheses can be used. If any |
| intermediate result is less than zero, the final value |
| is undefined. A constant-name may be used in place of |
| integer-1. |
| |
|13. The logical operations AND and OR act on the binary |
| representation in a bit-wise manner. |
| |
|14. LENGTH of identifier-1 is the size of the storage allocated for |
| identifier-1. If identifier-1 is a group item, the length |
| includes all subordinate data items. |
| |
|15. NEXT is the offset of the next data item asssuming it is |
| declared with the same level number as the previous data |
| item. |
| |
|16. START of identifier-2 is the offset at which identifier-2 |
| begins. |
| |
|17. For rules 5 and 6, the offset is defined as follows: |
| |
| if identifier-2 is part of an EXTERNAL record or a LINKAGE |
| record, then the offset is calculated from the start of the |
| associated 01-level; |
| |
| if identifier-2 is defined in LOCAL-STORAGE, then the offset is |
| calculated from the start of the LOCAL-STORAGE SECTION; |
| |
| otherwise the offset is calculated from the start of the DATA |
| DIVISION. |
| |
|18. Offsets are not portable across different COBOL implementations |
| and no reliance should be placed on particular values outside |
| this compilation unit. |
| |
________________________________________________________________________
Data Description Entries Other than Condition-Names and Constant-Names
(MF)
19. Rules governing the use of the VALUE clause differ with the
respective sections of the Data Division:
a. In the File Section, the VALUE clause must be used in
condition-name entries only.
b. In the Working-Storage Section and the Communication Section,
the VALUE clause must be used in condition-name entries. The
VALUE clause can also be used to specify the initial value of
a data item; in which case the clause causes the item to
assume the specified value at the start of the object
program. If the VALUE clause is not used in an item's
description, the initial value of that data item is
undefined.
c. In the Linkage Section, the VALUE clause must be used in
condition-name entries only.
________________________________________________________________________
|(OSVS) (VSC2) (MF) |
| |
| |
| |
|20. In the File Section and the Linkage Section, and Local-Storage |
| Section,(MF) the VALUE clause can be used in data item entries, |
| but is documentary only. |
| |
________________________________________________________________________
21. The VALUE clause must not be stated in a data description entry that
contains a REDEFINES clause, or in an entry that is subordinate to
an entry containing a REDEFINES clause. This rule does not apply to
condition-name entries.
22. If the VALUE clause is used in an entry at the group level, the
literal must be a figurative constant or a nonnumeric literal, and
the group area is initialized without consideration for the
individual elementary or group items contained within this group.
The VALUE clause cannot be stated at the subordinate levels within
this group.
23. The VALUE clause must not be written for a group containing items
with descriptions, including JUSTIFIED, SYNCHRONIZED, or USAGE
(other than USAGE IS DISPLAY).
________________________________________________________________________
|(VSC2) (MF) |
| |
| |
| |
|24. The figurative constant NULL can be specified in the VALUE clause|
| only if the data item is defined with USAGE POINTER or USAGE |
| PROCEDURE-POINTER. This is the only value you can specify in the |
| VALUE clause for such an item. The effect is to set the pointer |
| in such a way that it is guaranteed not to point to any data |
| item. |
| |
________________________________________________________________________
________________________________________________________________________
|(ANS85) |
| |
| |
| |
|25. A Format 1 VALUE clause specified in a data description entry |
| that contains an OCCURS clause, or in an entry that is |
| subordinate to an OCCURS clause, causes every occurrence |
| of the associated data item to be assigned the specified |
| value. |
| |
________________________________________________________________________
________________________________________________________________________
|[REV BEG](ANS85) |
| |
| |
| |
|26. If a VALUE clause is specified in a data description entry of a |
| data item which is associated with a variable occurrence data |
| item, the initialization of the data item behaves as if the value|
| of the data item referenced by the DEPENDING ON phrase in the |
| OCCURS clause specified for the variable occurrence data item |
| is set to the maximum number of occurrences as specified |
| by that OCCURS clause. A data item is associated with |
| a variable occurrence data item in any of the following |
| cases: |
| |
| |
| a. It is a group data item which contains a variable |
| occurrence data item. |
| |
| b. It is a variable occurrence data item. |
| |
| c. It is a data item that is subordinate to a variable |
| occurrence data item. |
| |
| If a VALUE clause is associated with the data item referenced by |
| a DEPENDING ON phrase, that value is considered to be placed in |
| the data item after the variable occurrence data item is |
| initialized. |
| [REV END] |
| |
________________________________________________________________________
________________________________________________________________________
|The Screen Section |
| |
|(MF) (XOPEN) |
| |
|The Screen Section provides screen handling facilities for use ACCEPT |
|and DISPLAY statements. It allows: |
| |
| the display of non-scrolling forms consisting of areas of the |
| screen as defined in the screen section. A screen section entry |
| is a screen description. It is similar in appearance to a data |
| description but defines a screen item or area of the screen |
| rather than an area in memory. |
| |
| the display items which constitute non-scrolling forms. The |
| details of the areas of the screen to be used are provided in the|
| associated ACCEPT and DISPLAY operations. (MF) |
| |
|The screen section contains a description of each field on the screen |
|which is accessed in a Format 4 ACCEPT or Format 2 DISPLAY operations.|
|Such a field is called a screen item. Many screen items describe only|
|the layout of fields within a field on the screen and are never |
|referenced explicitly. |
| |
|The screen section contains syntax which enables the operator |
|to: |
| |
| |
| * Specify the exact location of fields |
| |
| * Accept data typed at specified positions |
| |
| * Display literal text at specified positions |
| |
| * Define screen attributes |
| |
| * Control console features |
| |
|Table 3-6 summarizes the screen description clauses, screen |
|options and dat description clauses available in the screen section |
|and for use with ACCEPT and DISPLAY (MF) statements. It also |
|specifies options or clauses which can be used with each of the types |
|of fields defined below: |
| |
| |
| * An input field is a screen item whose description contains a TO|
| phrase. |
| |
| * An output field is a screen item whose description contains a |
| FROM phrase. |
| |
| * An update field is a screen item whose description contains a |
| USING phrase. |
| |
| * A literal field is an elementary screen item whose description |
| contains no PICTURE clause. |
________________________________________________________________________
________________________________________________________________________
|(MF) (XOPEN) |
| |
|There are two ways in which data entry is made to numeric and |
|numeric-edited screen fields; fixed format mode and free format mode. |
|Refer to your COBOL System Reference for further details. |
| |
|Fixed format mode is the default manner in which data entry is made to|
|numeric and numeric-edited screen fields. This mode formats and |
|echoes the entered data and also moves the cursor in accordance with |
|the requirements of the field's picture specification, as each |
|keystroke is received. Characters other than digits, "+", "-", and |
|the decimal point character, are rejected; insertion characters in |
|edited fields are skipped over as the cursor moves backwards and |
|forwards; any sign indicator is modified in accordance with its normal|
|specification; floating symbols move left and right in the field, and |
|insertion symbols appear and disappear as digits are inserted or |
|deleted. When the cursor reaches the last character position |
|in a field, any further character entered replaces the last |
|character. |
| |
|Free format mode is an alternative manner in which data entry can be |
|made to numeric and numeric-edited screen fields. The default mode is|
|fixed format mode (see above entry). This configurable mode allows |
|data to be keyed into a PIC X field of appropriate length, and it is |
|only when the operator leaves the field that the data is reformatted |
|to comply with the picture specification. Only the operator moves the|
|cursor from the field, your COBOL system disregards all characters |
|other than digits and the sign and decimal point symbols. It then |
|extracts, stores, or reformats the numeric value in accordance |
|with the normal COBOL rules for a MOVE to an item with the same |
|picture as the screen or working-storage item. The numeric value |
|is then usually echoed to the screen. See your COBOL System |
|Reference for details on configuration options available to |
|you. |
________________________________________________________________________
Table 3-6. Permitted Use of Options (MF) (XOPEN)
Permitted Use of Options (continued) (MF) (XOPEN)
X = clause/option allowed
1 = Data description clause allowed in the Screen Section
________________________________________________________________________
|(MF) (XOPEN) |
| |
|These clauses and options are described in the following sections. |
| |
|Function |
| |
|The screen section provides screen-handling facilities for use with |
|Format 4 ACCEPT and Format 2 DISPLAY statements. |
| |
|General Format |
| |
| SCREEN SECTION. |
| [screen-description-entry]... |
| |
|Syntax Rules |
| |
| |
| 1. The Screen Section must be the last section in the Data |
| Division. |
| |
| 2. Screen-description-entries contain screen description clauses. |
| Data description clauses allowed in the Screen Section are |
| restricted to those described in this chapter. |
| |
|General Rule |
| |
|The Screen Section contains a description of each field on the screen |
|which is accessed in a Format 4 ACCEPT or Format 2 DISPLAY operation. |
|Such a field is called a screen item. Many screen items describe only|
|the layout of fields within a field on the screen and are never |
|referenced explicitly. |
| |
|The Screen Description - Complete Entry Skeleton |
| |
|Function |
| |
|A Screen Description entry specifies the attributes, behavior, size |
|and location for a reference screen item which is accepted or |
|displayed at run time. |
| |
|Note that the availability of screen attributes is dependent on |
|your terminal hardware and operating system and COBOL run time |
|support. |
________________________________________________________________________
________________________________________________________________________
|(MF) |
| |
| GRID |
| LEFTLINE |
| OVERLINE |
| SIZE IS |
| COL |
| CONTROL |
| AUTO-SKIP |
| BEEP |
| NO-ECHO |
| EMPTY-CHECK |
| PROMPT |
| LENGTH-CHECK |
| ZERO-FILL |
| ACCEPT (Format 1, 2 and 3) |
| DISPLAY (Format 1) |
________________________________________________________________________
General Format
________________________________________________________________________
|(MF) (XOPEN) |
| |
|Syntax Rules |
| |
| |
| 1. Each Screen Description entry must start with a level number |
| from 01 through 49. |
| |
| 2. Each level 01 item must have a screen-name. |
| |
| 3. Screen-name assigns a name to the screen item described in the |
| screen description. Screen-name immediately follows |
| level number, conforming to the rules for user-defined |
| names. |
| |
| 4. A screen item can only be referenced in a Format 4 ACCEPT or |
| Format 2 DISPLAY statement. |
| |
| 5. Each elementary screen item must contain at least one of the |
| following clauses: BELL, BLANK LINE, BLANK SCREEN, COLUMN, |
| LINE, PICTURE, VALUE. |
| |
| 6. The data item in the FROM, TO and USING phrases are |
| "associated" with the screen item. The USING phrase is |
| equivalent to the combination of a FROM and TO phrase, each |
| specifying the same field. |
| |
| 7. An ACCEPT can be executed on a group screen item containing |
| screen items with FROM or VALUE phrases only if that group also|
| contains screen items with TO or USING phrases. |
| |
| 8. The clauses following screen-name can be specified in any |
| order. |
| |
| 9. A clause that appears in the description of a group screen item|
| applies to all the elementary subordinate items in that group |
| in whose descriptions would be allowed. |
| |
| 10. Any non-01 level screen item can have a data name, FILLER, or |
| no name. If no name is used, then FILLER is assumed (and the |
| item may never be explicitly referenced). |
| |
| 11. If the same clause is specified more than once for the same |
| screen item, the clause which appears at the lowest level |
| within the hierarchy is the one which takes effect. |
________________________________________________________________________
________________________________________________________________________
|(MF) (XOPEN) |
| |
|General Rules |
| |
| |
| 1. Screen descriptions define areas on the screen. Each entry |
| consist of a level number, an optional screen-name, and various|
| optional clauses relating to the positioning of fields as well |
| as to console functions. |
| |
| 2. When the screen item is displayed, data is taken from the |
| literal or data item named in the associated FROM or USING |
| phrase. Items within the TO phrase only are treated as though |
| FROM SPACE or FROM ZERO were specified, depending on the type |
| of screen item. |
| |
| 3. When the screen item is accepted, the data entered is moved |
| from the screen to the data item named in the TO or USING |
| phrase. Depending on the category of the item, conversion and |
| de-editing are done if necessary. |
| |
| 4. An input field is a screen item whose description contains a TO|
| phrase. |
________________________________________________________________________
________________________________________________________________________
|(MF) (XOPEN) |
| |
| |
| |
|5. An output field is a screen item whose description contains a |
| FROM phrase. |
| |
|6. An update field is a screen item whose description contains a |
| USING phrase. |
| |
|7. A literal field is an elementary screen item whose description |
| contains no PICTURE clause. |
| |
|8. An ACCEPT of a group screen item consist of accepting those |
| elementary subordinate items that are input or update fields. |
| They are accepted in the order their descriptions appear in the |
| screen section at the screen positions indicated by the screen |
| descriptions. 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. |
| |
|9. A DISPLAY of a group screen item consists of displaying those |
| elementary subordinate items that are output, update or literal |
| fields. They are displayed simultaneously at the screen |
| positions indicated by the screen descriptions. |
| |
|10. If the length of an ACCEPT or DISPLAY screen item exceeds |
| the length of the current line, wraparound is to the next |
| line. |
| |
|11. If a screen item is too large to fit within the physical screen, |
| truncation occurs at the first character that is off-screen for |
| output fields and alphanumeric input an update fields, and at the|
| first field that is off-screen for numeric and numeric-edited |
| input and update field. |
| |
________________________________________________________________________
________________________________________________________________________
|(MF) (XOPEN) |
| |
|The AUTO Clause |
| |
|Function |
| |
|The AUTO Clause automatically terminates an ACCEPT operation of the |
|screen item when the last character position is keyed. No explicit |
|terminator key is necessary. |
________________________________________________________________________
General Format
________________________________________________________________________
|(MF) (XOPEN) |
| |
|Syntax Rules |
| |
| |
| 1. The AUTO clause is allowed only with input and update |
| fields. |
| |
| 2. If this clause is specified at group level, it applies to all |
| elementary subordinate items. |
| |
| |
| |
|3. AUTO and AUTO-SKIP are equivalent. (MF) |
| |
| |
|General Rules |
| |
| |
| 1. Providing any REQUIRED or FULL clause is satisfied, the cursor |
| is positioned to the next screen item. Alternatively, if the |
| screen item is the last one in the ACCEPT operation, the entire|
| ACCEPT is terminated. |
| |
| 2. This clause overrides any existing configuration options for |
| automatic skipping and for the automatic termination of an |
| ACCEPT statement. (See your COBOL System Reference for details|
| of configuration options.) |
| |
| 3. In a fixed-format numeric-edited screen item, the AUTO clause |
| causes the decimal point position to be skipped automatically |
| once all of the integer places have been filled. Selection |
| of fixed format mode is a configuration option. (see |
| your COBOL System Reference for details of configuration |
| options.) |
________________________________________________________________________
________________________________________________________________________
|The BACKGROUND-COLOR Clause Function |
| |
|(MF) (XOPEN) |
| |
|The BACKGROUND-COLOR clause specifies the background color of the |
|screen item. |
________________________________________________________________________
General Format
________________________________________________________________________
|(MF) (XOPEN) |
| |
|Syntax Rules |
| |
| |
| |
|1. BACKGROUND-COLOR and BACKGROUND-COLOUR are equivalent. |
| |
|2. This clause is allowed with any screen item. |
| |
|3. If this clause is specified at group level, it applies to all |
| elementary subordinate items. |
| |
|4. Integer-1 must be a value from 0 to 7. |
| |
| |
|General Rules |
| |
| |
| |
|1. This clause is only available for use with a color screen. |
| |
|2. Integer-1 or identifier-1 specifies the background color of the |
| screen item. The colors and their corresponding values |
| are: |
| |
| |
| 0 black |
| 1 blue |
| 2 green |
| 3 cyan |
| 4 red |
| 5 magenta |
| 6 brown or yellow |
| 7 white |
| |
| |
|3. If this clause is not specified, the background color defaults to|
| black. |
| |
________________________________________________________________________
________________________________________________________________________
|(MF) (XOPEN) |
| |
| |
| |
|4. If a screen description contains a BLANK SCREEN clause, and |
| either contains a BACKGROUND-COLOR clause or is subordinate to |
| one that does, then when the screen item is displayed by a |
| DISPLAY statement the specified color becomes the default |
| background color. It remains the default background color until |
| either another screen item with this combination of options |
| is displayed (whether in the same DISPLAY statement or |
| another), or a Format 3 DISPLAY statement with both options is |
| executed. |
| |
|5. Identifier-1 must be an unsigned numeric integer and should |
| contain a value between 0 and 7. Any value higher than 7 |
| will be divided by 8 and the remainder used as the color |
| value. |
| |
|6. Identifier-1 must not be subject to OCCURS clauses. |
| |
|7. Whether a value of 6 in integer-1 or identifier-1 produces brown |
| or yellow color depends on the terminal hardware. |
| |
________________________________________________________________________
MPE/iX 5.0 Documentation