[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
Reference Manual


Previous Contents Index

Additional References

5.3.53 VALUE IS

Function

The VALUE IS clause defines the values associated with condition-names, the initial value of Working-Storage Section data items, the value of Report Section printable items, the compile-time initialization of variables to the address of data, external constants, and the constant values of literal screen items.


lit

is a numeric or nonnumeric literal. In a screen description entry, it is a nonnumeric literal.

external-name

names a COBOL link-time bound constant. It must define a word or longword integer value. See Technical Notes for more information.

data-name

names a data item in the File or Working-Storage or Subschema Section. data-name may be qualified.

low-val

is a numeric or nonnumeric literal. It is the lowest value in a range of values associated with a condition-name in a level 88 data description entry.

high-val

is a numeric or nonnumeric literal. It is the highest value in a range of values associated with a condition-name in a level 88 data description entry.

numeric-integer-lit

is a positive numeric integer literal.

Syntax Rules

  1. The words THRU and THROUGH are equivalent.
  2. You must associate a signed numeric literal with either of the following:
    1. A data item that has a signed numeric PICTURE character-string
    2. A COMP-1 or COMP-2 data item
  3. If you specify a numeric literal value:
    1. It must fall in the range of values defined by the data item's PICTURE clause.
    2. It must not require truncation of nonzero digits; that is, it cannot have nonzero digits in positions represented by Ps in the item's PICTURE clause.
  4. If you specify a nonnumeric literal value, it must not exceed the size defined by the data item's PICTURE clause.
  5. The Format 1, 3, and 4 VALUE IS clause cannot be used in any entry that is part of the description or redefinition of an external data record.
  6. The Format 3 VALUE IS clause is allowed only for an item containing the USAGE IS POINTER phrase.
  7. The subject of the associated data description entry in a Format 4 VALUE IS clause must define a word or longword data item.
  8. In a screen description entry, the VALUE clause can be specified only at the elementary level.

General Rules

  1. The VALUE IS clause must be consistent with other clauses in the data description of both the item and all subordinate items. The following rules apply:
    • If the category of the item is numeric, all literals in the VALUE IS clause must be numeric. lit is aligned in the data item according to Standard Alignment Rule 1.
    • If the category of the item is alphabetic, alphanumeric, alphanumeric edited, or numeric edited, all VALUE IS clause literals must be nonnumeric. lit is aligned in the data item as if the data item were defined as alphanumeric. Editing characters in the PICTURE clause count toward data item size but have no effect on initialization. Therefore, if lit applies to an edited item, it must be in an edited form; Standard Alignment Rule 3 applies.
    • The BLANK WHEN ZERO clause does not directly affect initialization. However, the BLANK WHEN ZERO clause can change the category of the data item. If the category of the data item changes, the rules that apply change accordingly.
    • The JUSTIFIED clause does not affect initialization.
  2. In the File Section, the VALUE IS clause can apply only to condition-name entries. That is, you can use the clause only for level 88 data items. In the Linkage Section, VALUE IS produces a warning for the other 88 data items.
  3. Format 2 applies only to condition-name entries.
  4. If a VALUE IS clause is specified in a data description entry that contains an OCCURS clause with a DEPENDING ON phrase, every occurrence of the associated data item is set to the maximum value.
    A data item is associated with a variable occurrence data item in any of the following cases:
    • It is a group data item that contains a variable occurrence data item.
    • It is a variable occurrence data item.
    • It is subordinate to a variable occurrence data item.

    If a VALUE IS 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.
  5. If a VALUE IS clause is specified in a data description entry that contains an OCCURS clause, or in an entry that is subordinate to an OCCURS clause, every occurrence of the associated data item is assigned the specified value. (This applies to General Formats 1, 3, and 4.)

Condition-Name Rules for Format 2

  1. The VALUE IS clause is required in a condition-name entry. The condition-name entry can contain only the condition-name itself and the VALUE IS clause.
  2. The characteristics of a condition-name are implicitly the same as those of its conditional variable.
  3. When using the EXTERNAL option, the associated conditional variable must be a word or longword COMP data item.
  4. When using the REFERENCE option, the associated conditional variable must be POINTER usage.
  5. If the THRU phrase is used, each low-val, external-name, and data-name must be less than the corresponding high-val, external-name, and data-name.

Rules for Other Data Description Entries

  1. A Working-Storage Section VALUE IS clause takes effect only when the program enters its initial state.
  2. The VALUE IS clause initializes the data item to the value of lit.
  3. If a data item's data description entry does not have a VALUE IS clause, the initial contents of the data item are the following:
    • Zero, for numeric items
    • Undefined, for index data items, and data items whose descriptions include or are subordinate to an OCCURS clause
    • Spaces, for all other items
  4. In the Report Section, if an elementary report entry contains a VALUE IS clause but does not contain a GROUP INDICATE clause, the printable item assumes the specified value each time the Report Writer Control System (RWCS) prints the Report Group. However, if the entry contains the GROUP INDICATE clause, the RWCS presents the specified value only when certain run-time conditions exist. See the description of the GROUP INDICATE clause for more information.
  5. The VALUE IS clause cannot be used in a data description entry that has a REDEFINES clause or is subordinate to a data description entry with a REDEFINES clause.
  6. The VALUE IS clause can be in a data description entry for a group item. In this case:
    • lit must be a figurative constant or nonnumeric literal.
    • The group area is initialized as if the group were an elementary alphanumeric data item.
    • Initialization of group items is not affected by the characteristics of the group's subordinate group or elementary items.
    • The VALUE IS clause cannot be used in data description entries for the group's subordinate group or elementary items.
  7. The VALUE IS clause cannot be used in the data description entry for a group that contains subordinate items with any of the following clauses:
    • JUSTIFIED
    • SYNCHRONIZED
    • USAGE (other than USAGE IS DISPLAY)
  8. The VALUE IS clause cannot be used in the report group description entry for a group that contains subordinate items with a JUSTIFIED clause.
  9. The Format 3 VALUE IS clause results in the compile-time initialization of its data description entry to the address of data-name or to numeric-integer-lit. Use this clause to pass arguments to non-COBOL procedures requiring an address rather than a user-defined word.
  10. In Format 4, external-name must be the name of an external symbol (a symbol in another program unit) that is known to the linker when the program is linked.
  11. The Format 4 VALUE IS clause results in the linker storing the value of external-name at the storage location defined by the data description entry containing the VALUE IS EXTERNAL clause.

Technical Notes

  • external-name is a COBOL word formed according to the rules for user-defined names. The compiler translates hyphens in the COBOL word to underscore characters.
  • external-name names a constant whose value is unknown at compile time but known at link time.
  • Although the VALUE IS clause is not valid in the LINKAGE SECTION, the compiler allows such a specification, as a Hewlett-Packard extension. The clause, when specified in the LINKAGE SECTION, has no effect on program execution, and is flagged with an informational Hewlett-Packard extension diagnostic.

Additional References

Examples

  1. The following is an example of initializing alphanumeric data items:


    01  ITEMA  PIC X(20) VALUE IS "12345678901234567890".
    01  ITEMB  PIC XX    VALUE IS "NH".
    
  2. The following is an example of initializing numeric data items:


    01  ITEMX  PIC S9999 VALUE IS -39.
    01  ITEMZ  PIC 9     VALUE ZERO.
    
  3. The following is an example of assigning condition-name values:


    01  ITEMC  PIC 99.
           88  VAL1      VALUE IS 4.
           88  VAL2      VALUE IS 5 THRU 9 12.
           88  VAL3      VALUES ARE 10 14 THRU 23 27 29 30.
           88  VAL4      VALUES ARE 0 THRU 49, 51 THRU 99.
           88  VAL5      VALUES ARE 0 10 20 30 40 50.
    
  4. The VALUE IS EXTERNAL clause allows a COBOL program to equate a mnemonic system constant to a value representing a return status code rather than the numeric equivalent. The following are some examples of this clause:
    On OpenVMS


    Previous Next Contents Index