Re: FUNCTION LENGTH
- From: "William M. Klein" <wmklein@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 5 Jun 2009 13:59:16 -0500
What is posted below is 100% correct for Enterprise COBOL and for the Intrinsic
Function amendment to the '85 Standard. In the '02 Standard (and for many other
compilers) this has been expanded so that a numeric intrinsic function may be
used where a numeric sending item may be used and similarly for integer
If this is a feature that you would like in Enterprise COBOL, then I suggest
that you submit an "IBM Marketing REQUEST" and reference the SHARE requirement:
SSLNGC0313595 2002 ISO COBOL - Expand use of Numeric & Integer Functions
currently marked as "RECOGNIZED"
wmklein <at> ix.netcom.com
"Charles Hottel" <chottel@xxxxxxxxxxxxx> wrote in message
"Frank Swarbrick" <Frank.Swarbrick@xxxxxxxxxxxxxx> wrote in message
Hmm, this surprised me. I just tried this:
subtract function length(fjs-root-seglen)
And got this.
IGYPS2095-S EXPECTED A NUMERIC DATA ITEM OR A NUMERIC LITERAL, BUT FOUND
THE "SUBTRACT" STATEMENT WAS DISCARDED.
IBM ENTERPRISE COBOL FOR Z/OS 3.4.1
It works fine in a compute statement:
compute fjs-root-seglen = function length(fjs-root-segment)
I thought that FUNCTION LENGTH was allowed anywhere that a numeric data item
or numeric literal was allowed. Seems strange that it's not allowed here.
The IBM extension LENGTH OF fjs-root-seglen works fine.
Probably it follows the standard, though I can't imagine why the standard
would disallow that usage... (Too lazy to actually look at the standard at
the moment to try to explain it.)
Applications Architect - Mainframe Applications Development
FirstBank Data Corporation
Lakewood, CO USA
A numeric function can only be used where an arithmetic expression can be
specified. They cannot be used where an integer operand is required.
From the COBOL Language Reference:
Numeric functions A numeric function can be used only where an arithmetic
expression can be specified. Chapter 22. Intrinsic functions 461
A numeric function can be referenced as an argument for a function that allows
a numeric argument. A numeric function cannot be used where an integer operand
is required, even if the particular reference would yield an integer value.
The INTEGER or INTEGER-PART functions can be used to force the type of a
numeric argument to be an integer.
Integer functions An integer function can be used only where an arithmetic
expression can be specified. An integer function can be referenced as an
argument for a function that allows an integer argument. Usage notes: v
identifier-2 of the CALL statement must not be a function-identifier. v The
COPY statement accepts function-identifiers of all types in the REPLACING
- Re: FUNCTION LENGTH
- From: Frank Swarbrick
- Re: FUNCTION LENGTH