COBOL Manual for TNS and TNS/R Programs
Data Division
HP COBOL Manual for TNS and TNS/R Programs—522555-006
7-77
USAGE Clause
•
How NATIVE-n and BINARY/COMPUTATIONAL Formats Differ
The significant difference between a NATIVE-n data item (which occupies n
character positions by definition) and a COMPUTATIONAL data item that happens
to occupy n character positions is that the COMPUTATIONAL item has the
number of decimal digits declared by its PICTURE clause. Although a NATIVE-n
data item and a certain COMPUTATIONAL data item both occupy n character
positions, they cannot necessarily assume the same set of values.
For example, a NATIVE-2 data item and a COMPUTATIONAL data item with
PICTURE 9999 both occupy 2 character positions, but any value larger than 9999
is truncated on the left before it is assigned to the COMPUTATIONAL data item,
whereas the NATIVE-2 data item can be assigned any value in the range -32768
through +32767.
A program can specify a NATIVE-n data item as an operand anywhere that it can
specify a BINARY/COMPUTATIONAL item (of equivalent size in character
positions), such as in arithmetic expressions, MOVE statements, and so on. In all
cases, the value of the item is interpreted as a signed integer.
•
How NATIVE-n and COMPUTATIONAL-5 Formats Differ
The difference between a NATIVE-n data item and a COMPUTATIONAL-5 data
item is that the NATIVE-n data item is 2-byte-aligned and the
COMPUTATIONAL-5 data item is byte-aligned and requires a PICTURE clause
(see PICTURE clause).
•
POINTER Data Items
°
Clauses not allowed
A group or elementary data item described with a USAGE POINTER clause
cannot have any other clauses except VALUE IS NULL or VALUE IS NULLS.
The clause VALUE IS NULL or VALUE IS NULLS initializes the pointer to a
value (all ones) that causes an address fault if the pointer is referenced.
°
How HP COBOL pointers differ from HP C and Pascal pointers
An HP COBOL POINTER data item is not the same as a pointer in HP C or
Pascal. An HP COBOL POINTER data item merely provides a container for an
address. You can access an HP COBOL POINTER data item only in a
conditional expression, a SET statement, or as a parameter in the USING
phrase of a CALL or ENTER statement.
The statement
MOVE "ABC" TO PTR1
where PTR1 is an HP COBOL pointer, does not move the value “ABC” to the
address that PTR1 contains.