COBOL Manual for TNS and TNS/R Programs
Intrinsic Functions
HP COBOL Manual for TNS and TNS/R Programs—522555-006
14-25
LENGTH Function
LENGTH Function
LENGTH, an integer function, returns the length of its argument (the number of
character positions it has, regardless of its current value).
argument
is a nonnumeric literal or data item of any class or category.
The returned value is determined as shown in this table. It includes any implicit FILLER
characters.
argument Returned Value
nonnumeric literal or
elementary data item or
data structure that does not
contain a variable occurrence
data item
Length of the value of argument.
data structure containing a
variable occurrence data item
Length of the current value of the data item specified in the
DEPENDING phrase of the OCCURS clause for the variable
occurrence data item. The current value is determined as if
the data item were a sending data item.
Example 14-17. LENGTH Function
Code:
01 STUFF-1 PIC XXXX.
01 STUFF-2 PIC 9999.
MOVE "AB" TO STUFF-1.
MOVE 12 TO STUFF-2.
DISPLAY FUNCTION LENGTH(STUFF-1).
DISPLAY STUFF-2.
DISPLAY FUNCTION LENGTH(STUFF-2).
DISPLAY FUNCTION LENGTH("ABC").
Output:
4
0012
4
3
( )
LENGTHFUNCTION argument
VST435.vsd