Link to home
Start Free TrialLog in
Avatar of chenwei
chenwei

asked on

A question about COBOL

Seems I am the first one who put up a question about COBOL. COBOL is a Grand-grand-pa old language. Truely speaking I don't like it. But I have to write programs in COBOL. That's quite paintful, isn't it? ;-)

Here is my question:
I have two programs, one is the calling-program and the other called-program. The calling-program will send parameters to the called-program. This is can be written like:
  CALL Called-Program USING Parm1, Parm2, ...
  .
  END-CALL
  ...

Furhter, the calling-program wait for the return value from the called-program. And I am not allowed to define EXTERNAL GLOBAL variables in the DATA DEVISION. I don't know how to do. I've read some COBOL books and haven't fond out any answer to my question.

Is there any COBOL-Dinosauier here? ;-)
Avatar of billious
billious

There certainly is - and by nearly that name. too!

in CALLED...

add a LINKAGE SECTION as part of the DATA division, traditionally after the WORKING-STORAGE SECTION.

LINKAGE SECTION
01 PARM1
01 PARM2

then PROCEDURE DIVISION becomes
PROCEDURE DIVISION USING PARM1, PARM2.

(It helps if PARM1, PARM2 are copylibs, obviously).

Data in PARM1, PARM2 can now be exchanged between programs.

CALLED-PROGRAM needs to be terminated by an

EXIT PROGRAM.

not by a STOP RUN.

This is the simplest method - there are many. There are also slight implementation dependancies - on some platforms, PARM1, PARM2, etc. must be 01 or 77-levels (ANSI-74 standard) for instance - but if you program for the most restrictive implementation then you should be OK.
(Hence, I use ANSI-74, not 85 or COBOL-II!)

...Bill


Did someone spell my name wrong. ;^)

chenwei,

I think billious has about covered everything.  If you need more we will be happy to help.

Cd&
Avatar of chenwei

ASKER

Hi billious,

Thanks for your answer. I use COBOL 85.

My situation is: How can I make the copylibs? Is this a seperated file where the commond used parameters are? Such as the head-file by C? Could give an example?

Thanks!

Supprised that someone really has the name COBOLdinosaur. ;-)
ASKER CERTIFIED SOLUTION
Avatar of billious
billious

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
On your compiler, lose those quotes (").

I was using a HIGHLY aberrant compiler at one stage, and some of its quirks stuck.

...Bill
Avatar of chenwei

ASKER

Hi Bill,

Thanks for your answer. I'll have a try. I use Tandem COBOL Compiler. But at home I have no Tandem Computer. Do you know occationally where can one download COBOL85 compiler for WIN NT for free? I've downloaded the Fujitzu COBOL compiler but it's quite complicated toi use it since one has to add the line-number each line. It's a plenty work and quite inconvinient.
TANDEM?  :^)

If you are using a TANDEM you can also bring in copy library sections with a ?SOURCE directive and you have a little more flexibility by using define name for the copy library file.

?SOURCE =FILENAME(SECTIONNAM1, SECTIONNAME2, ETC)

the source directive is handy if you are using embeded SQL, because it gets executed at the pre-precessing phase so you can include SQL in the copy sections if necessary. So the code is generated before both the COBOL85 and SQLCOMP steps.

Cd&
I'd suggest that there would be a command-line parameter on the Fuji COBOL that would turn off the line-number requirement. Personally, I'd've made it the default, but there you go.

A friend of mine used a Fuji compiler on NT, and had no such complaint - Time for some manual-reading, I'd suspect.

OR - first project! Write a prefixer! ( I didn't say you had to write it in COBOL!)

As for pre-processors yeah- been through that on IBM and Amdahl for interfacing to SUPRA.

...Bill