Re: FUNCTION LENGTH



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(fjs-root-seglen)
from fjs-root-seglen
giving datalen

And got this.

IGYPS2095-S 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 fjs-root-seglen = function length(fjs-root-segment)
- 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 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.)

Frank

--

Frank Swarbrick
Applications Architect - Mainframe Applications Development
FirstBank Data Corporation
Lakewood, CO USA
P: 303-235-1403
F: 303-235-2075


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
phrase.




.



Relevant Pages

  • Re: Difficult example?
    ... If the data object being declared depends on the ... A reference to any other intrinsic function defined in this ... An elemental intrinsic function reference where each argument ...
    (comp.lang.fortran)
  • Re: Fortran standard question: intrinsic procedure as actual argument
    ... And "that 'scale' is referenced by a function call" is the difference which means it isn't analogous at all--it's completely different code. ... There is nothing at all that is very similar at all between your cases 3) and 4) in comparison to 1) and 2) except you chose the same name for a variable as an intrinsic function of the same name. ... That it is a function as opposed to a reference to the intrinsic has everything to do w/ context and nothing whatsoever to do w/ the spelling of the name. ...
    (comp.lang.fortran)
  • Re: ifort functions for test NaN and Inf
    ... Anybody knows an intrinsic function for testing if a variable is ... I have found in the reference the function ISNAN but not the ... ISNAN is not standard. ... However your compiler might not support this yet, ...
    (comp.lang.fortran)
  • ifort functions for test NaN and Inf
    ... Anybody knows an intrinsic function for testing if a variable is ... I have found in the reference the function ISNAN but not the ... equivalent for INF. ...
    (comp.lang.fortran)
  • intrinsic logical to integer conversion?
    ... but I've been trying to find an intrinsic function ... for this in my reference (Chapman), and I haven't been successful. ...
    (comp.lang.fortran)