Re: CALL using OMITTED
- From: "William M. Klein" <wmklein@xxxxxxxxxxxxxxxxx>
- Date: Mon, 29 Sep 2008 17:16:51 GMT
Frank,
Thinking a little more about this, I do NOT think IBM will/should "easily"
treat an omitted final parameter like an explicit OMITTED phrase (at least
without call prototypes).
IBM has an (undocumented?) feature that Micro Focus emulates with its
"sticky-linkage" compiler directive. The USEFUL part of this feature is that if
you call the same program using multiple (IBM extension) ENTRY statements and
one has 4 parameters and the 2nd call uses only 3 parameters, then
"addressability" is MAINTAINED for the omitted parameter.
The (less useful?) variation of this is if you call a program with NO ENTRY
statement and call it first with 4 parameters and then with 3 parameters, then
the 4 item retains "sticky-linkage" (i.e. addressability) from the previous
call.
THEREFORE< I don't think that they (IBM) could (uparwadly compatibly) treat an
omitted trailing parameter as the same as an explicit OMITTED parameter.
***
I still haven't heard make from my usually reliable sources, but this is my
opinion on the subject.
--
Bill Klein
wmklein <at> ix.netcom.com
"William M. Klein" <wmklein@xxxxxxxxxxxxxxxxx> wrote in message
news:8ceDk.360083$Qi2.151890@xxxxxxxxxxxxxxxxxxxxxxxxx
Frank,
I have sent a query off to my "usually reliable sources" within IBM, but I
would point out that the '02 Standard limits OMITTED to CALLs with
"call-prototypes" and also has the "omitted argument" relational test. IBM
doesn't have either of these, so their OMITTED support is certainly NOT up to
the '02 Standard level (nor do they claim it is).
--
Bill Klein
wmklein <at> ix.netcom.com
"Frank Swarbrick" <Frank.Swarbrick@xxxxxxxxxxxxxx> wrote in message
news:48DD0EC9.6F0F.0085.0@xxxxxxxxxxxxxxxxx
So we now have a small z/OS system, in addition to our z/VSE system, so I've
been trying out some features in Enterprise COBOL for z/OS that are missing
in COBOL for VSE/ESA. One feature I've always thought might be useful is
CALL with the OMITTED argument. So I wrote the following:
ID DIVISION.
PROGRAM-ID. COB1.
PROCEDURE DIVISION.
DISPLAY 'NEW TEST' UPON CONSOLE
DISPLAY 'TEST!' UPON CONSOLE
DISPLAY 'TEST2'
DISPLAY 'WHEEEE!!!' UPON CONSOLE
DISPLAY 'YET ANOTHER TEST' UPON CONSOLE
CALL 'COBX' USING BY CONTENT 'AAAA'
OMITTED
'CCCC'
OMITTED
STOP RUN.
ID DIVISION.
PROGRAM-ID. COBX.
DATA DIVISION.
LINKAGE SECTION.
77 A PIC X(4).
77 B PIC X(4).
77 C PIC X(4).
77 D PIC X(4).
PROCEDURE DIVISION USING A B C D.
IF ADDRESS OF A = NULL
DISPLAY 'A IS OMITTED'
ELSE
DISPLAY A
END-IF
IF ADDRESS OF B = NULL
DISPLAY 'B IS OMITTED'
ELSE
DISPLAY B
END-IF
IF ADDRESS OF C = NULL
DISPLAY 'C IS OMITTED'
ELSE
DISPLAY C
END-IF
IF ADDRESS OF D = NULL
DISPLAY 'D IS OMITTED'
ELSE
DISPLAY D
END-IF
EXIT PROGRAM.
END PROGRAM COBX.
END PROGRAM COB1.
This works. However, I also tried:
CALL 'COBX' USING BY CONTENT 'AAAA'
OMITTED
'CCCC'
Where I, umm, omitted the OMITTED keyword as the fourth parameter.
According to the Cobol 2002 standard, I believe this would work:
From 14.8.4.3 General rules:
"11) If an OMITTED phrase is specified or a trailing argument is omitted,
the omitted-argument condition for that
parameter evaluates to true in the called program. (8.8.4.1.7,
Omitted-argument condition.)"
This does not appear to work in Enterprise Cobol. I would have expected to
see 'D IS OMITTED'. But I did not. It printed the value of D, which was
spaces (I guess; or something not readable).
I can't find anything in the IBM docs that say what should be expected in
this situation. All I could find was this:
----------------
4.2.1.3 Testing for OMITTED arguments
You can specify that one or more BY REFERENCE arguments are not to be passed
to a called program by coding the OMITTED keyword in place of those
arguments in the CALL statement.
For example, to omit the second argument when calling program sub1, code
this statement:
Call 'sub1' Using PARM1, OMITTED, PARM3
The arguments in the USING phrase of the CALL statement must match the
parameters of the called program in number and position.
In a called program, you can test whether an argument was passed as OMITTED
by comparing the address of the corresponding parameter to NULL. For
example:
Program-ID. sub1.
. . .
Procedure Division Using RPARM1, RPARM2, RPARM3.
If Address Of RPARM2 = Null Then
Display 'No 2nd argument was passed this time'
Else
Perform Process-Parm-2
End-If
----------------
Well, I guess maybe this statement says it in some ways:
"The arguments in the USING phrase of the CALL statement must match the
parameters of the called program in number and position."
Since the number of arguments does not match I guess the result is
undefined. Annoying! I wonder if they would consider following the
standard... Seems to me this would be a very simple change. The IBM
calling convention sets the high-order byte in the address of the last
parameter. So its easy to know which parameter was last, and then assume
parameters after that are omitted.
The main reason I would like this is that sometimes a subroutine needs to be
extended to allow for more parameters. When a new parameter is added then
all programs calling it need to be changed to pass the additional parameter,
even if they don't actually have a use for it. My hope was that with
omitted trailing arguments the subroutine could just check for them being
omitted, and not use them. The way that it stands I find very little use
for it.
So close and yet so far! Argh!
They should also allow the test to be "IF data-name IS OMITTED", which is
also in the standard (rather than checking for an address of NULL).
Oh well...
Frank
.
- Follow-Ups:
- Re: CALL using OMITTED
- From: Frank Swarbrick
- Re: CALL using OMITTED
- References:
- CALL using OMITTED
- From: Frank Swarbrick
- Re: CALL using OMITTED
- From: William M. Klein
- CALL using OMITTED
- Prev by Date: Flowchart of Cobol code
- Next by Date: Re: Flowchart of Cobol code
- Previous by thread: Re: CALL using OMITTED
- Next by thread: Re: CALL using OMITTED
- Index(es):
Relevant Pages
|