gnucobol-users
[Top][All Lists]

RE: [open-cobol-list] RE: Question About Functions

 From: Bill Klein Subject: RE: [open-cobol-list] RE: Question About Functions Date: Tue May 10 12:02:56 2005

```It's two arguments.

The "B - C - 3" is all one arithmetic expression.  In order for any of the
"minuses" to be a unary operator, the following rule comes into play:

"... If the first operator in an arithmetic expression is a unary operator,
it shall be immediately preceded by a left parenthesis if that arithmetic
expression immediately follows an identifier or another arithmetic
expression.

NOTE For example, when '1' and '+ 2' are used as subscripts for a
two-dimensional table A, the arithmetic expression '+ 2' needs to be
enclosed in parentheses, as in A (1 (+ 2))."

See Rule 6 on page 121 of the '02 Standard.

> -----Original Message-----
> Behalf Of Robert Sherry
> Sent: Tuesday, May 10, 2005 8:38 AM
> To: 'Roger While'
> Subject: [open-cobol-list] RE: Question About Functions
>
> Roger,
>
>     Thanks for the response. Please consider the following
> function call:
>                 FUNCTION MAX( A   B - C        - 3 )
> How many arguments are being passed to the function MAX and
> how do you know?
>
> Bob Sherry
>
> -----Original Message-----
> Sent: Tuesday, May 10, 2005 1:00 AM
> Subject: Re: Question About Functions
>
> In so far that a specific function allows it, arithmetic and boolean
> expressions
> are legal.
>
> In fact you also can nest functions eg. from 2002 standard
> syntax rules :
>
> -- quote --
> If a function's definition permits arguments and a left parenthesis
> immediately follows function-prototypename-
> 1 or intrinsic-function-name-1, the left parenthesis is
> always treated as
> the left parenthesis of that
> function's arguments.
> NOTE For a function that may be referenced either with or without
> arguments, such as the RANDOM function, careful
> coding is necessary to ensure correct interpretation. For
> example, in the
> following:
> FUNCTION MAX (FUNCTION RANDOM (A) B)
> 'A' is treated as an argument to the RANDOM function. If 'A'
> meant to be a second argument to the MAX
> function, different coding is necessary - either:
> FUNCTION MAX ( (FUNCTION RANDOM) (A) B)
> or
> FUNCTION MAX (FUNCTION RANDOM () A B)
> or
> FUNCTION MAX (FUNCTION RANDOM A B).
> -- end quote --
>
> Roger
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Oracle Space Sweepstakes
> Want to be the first software developer in space?
> Enter now for the Oracle Space Sweepstakes!
> _______________________________________________
> open-cobol-list mailing list
> https://lists.sourceforge.net/lists/listinfo/open-cobol-list
>

```