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
functions.
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"

Bill Klein
wmklein <at> ix.netcom.com
"Charles Hottel" <chottel@xxxxxxxxxxxxx> wrote in message
news:zJWdnQrVQ8jp9LXXnZ2dnUVZ_sadnZ2d@xxxxxxxxxxxxxxxx
"Frank Swarbrick" <Frank.Swarbrick@xxxxxxxxxxxxxx> wrote in message
news:4A279AF8.6F0F.0085.0@xxxxxxxxxxxxxxxxx
Hmm, this surprised me. I just tried this:
subtract function length(fjsrootseglen)
from fjsrootseglen
giving datalen
And got this.
IGYPS2095S EXPECTED A NUMERIC DATA ITEM OR A NUMERIC LITERAL, BUT FOUND
"FUNCTION".
THE "SUBTRACT" STATEMENT WAS DISCARDED.
IBM ENTERPRISE COBOL FOR Z/OS 3.4.1
It works fine in a compute statement:
compute fjsrootseglen = function length(fjsrootsegment)
 datalen
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 fjsrootseglen 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.)
Frank

Frank Swarbrick
Applications Architect  Mainframe Applications Development
FirstBank Data Corporation
Lakewood, CO USA
P: 3032351403
F: 3032352075
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 INTEGERPART 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
identifier2 of the CALL statement must not be a functionidentifier. v The
COPY statement accepts functionidentifiers of all types in the REPLACING
phrase.
.
 FollowUps:
 Re: FUNCTION LENGTH
 From: Frank Swarbrick
 Re: FUNCTION LENGTH
 References:
 FUNCTION LENGTH
 From: Frank Swarbrick
 Re: FUNCTION LENGTH
 From: Charles Hottel
 FUNCTION LENGTH
 Prev by Date: Re: Realistic reuse WAS Re: You know what they say about statistics and statisticians
 Next by Date: Re: FUNCTION LENGTH
 Previous by thread: Re: FUNCTION LENGTH
 Next by thread: Re: FUNCTION LENGTH
 Index(es):
Relevant Pages
