Operating System - OpenVMS
1747992 Members
5180 Online
108756 Solutions
New Discussion юеВ

Re: How to define arguments for callable programs written in COBOL

 
John T. Farmer
Regular Advisor

How to define arguments for callable programs written in COBOL

What is the proper syntax for call arguments in a called COBOL program. I wish to adhere to the standard calling procedures used by the RTL ("By Descriptor", "By Referenc" & "By Value"). I have seen that coded in COBOL where upon entering the called program, it had to resolve the variable addresses and again, upon exiting, it had to copy the information back to any return arguments. My only experience has been in passing fixed field length data on the "Procedure Division Using" line.

Thanks,

John
OpenVMS v7.2
COBOL v2.6-1060
Alpha hardware
19 REPLIES 19
Hein van den Heuvel
Honored Contributor

Re: How to define arguments for callable programs written in COBOL

John,

[Welcome to the HP ITRC OpenVMS Forum]

All this is nswerred in great detail in the Cobol Users Guide: "Interprogram Communication
12.4 Accessing Another Program├в s Data Division"
You can only receive by reference.
You'll have to play games (typically LIB$COPYxxxx and LIB$MOVxxx calls, or even cobol helper functions) to deal with descriptors. And "SET {pointer-id} . . . TO REFERENCE OF identifier" to get at data passed by value.

"A called COBOL subprogram must have arguments passed to it using
BY REFERENCE, which is the default, or BY CONTENT. BY VALUE,
OMITTED, and BY DESCRIPTOR are HP extensions and will not work
as expected if passed to a COBOL program. These argument-passing
mechanisms are necessary when calling Run-Time Library Routines and
system service routines as described in Chapter 13."

Good luck,
Hein.
John T. Farmer
Regular Advisor

Re: How to define arguments for callable programs written in COBOL

Hein,

Thank you for the detailed response. I have been away from VMS for about 4 years. A little rusty, but that info sounds familiar. Thanks for the doc reference.

John
Richard J Maher
Trusted Contributor

Re: How to define arguments for callable programs written in COBOL

Hi John,

Attached is a COBOL example program that receives arguments BY DESCRIPTOR (or more specifically, receives Descriptors BY REFERENCE :-)

Look for the TIP_LOGON routine, and also the OUT_MSG that is called by SYS$PUTMSG with the message text passed BY DESCRIPTOR.

I don't think there's and BY VALUE passing in there but, as Hein pointed out, you just SET WS_POINTER_VAR TO REFERENCE LINKAGE_SECTION_VAR and the 32-bit value will be stuck in your pointer. (What if it's a pointer-64?)

Regards Richard Maher
comarow
Trusted Contributor

Re: How to define arguments for callable programs written in COBOL

Many years ago I taught the class, Utilizing
VMS Features from Cobol. If you search the data base, there are a bunch of examples of various calls.

Search under Example-COBOL.



John T. Farmer
Regular Advisor

Re: How to define arguments for callable programs written in COBOL

I'm sorry, where would I do that search? I am new to this group.

Thanks,

John
comarow
Trusted Contributor

Re: How to define arguments for callable programs written in COBOL

John,

It appears they are in an older database.
If you give me your email address I'll send you some examples, or log a call.

Bob C.
Jan van den Ende
Honored Contributor

Re: How to define arguments for callable programs written in COBOL

John,

PLEASE, no plain e-mail adresses!
It is easy enough to morph them such tat a human can reconstruct it.

These fora, like so many others, are quite popular for address-minibg!.

I wil ask a moderator to change it aASAP.

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
comarow
Trusted Contributor

Re: How to define arguments for callable programs written in COBOL

I sent a collection of old VAX examples.
Not much has changed.
Richard J Maher
Trusted Contributor

Re: How to define arguments for callable programs written in COBOL

Hi John,

Here's one I prepared earlier :-)

I knew I had a reasonable example of BY VALUE passing in COBOL so here it is. (A good example of I$CC calling also, if I do say so myself)

Good luck!

Regards Richard Maher