I like this technique, and will take note of it for the future.
But is it just me who tries to go for the super-generalisation?
Imagine a big, established suite of programs, already calling this
subprogram from more than a few places, but a new requirement means it
suddenly has to know if it was called while the program calling it had
the terminal in block mode or character mode.
Linkage, External or whatever, you are going to fight very shy of making
all those calling places have to keep track of which mode they are in,
in a variable, a JCW or VAR, or even an Image dataset, so that the
subprogram can read this.
Easier, more reliable, and safer by far, to have the subprogram figure
this out for itself if it wants to know which mode the terminal is in,
and leave the rest of the suite absolutely unchanged.
Seeing a problem like this, I tend to make the jump from 'how do I tell
the subprogram which mode?' (as Walter says, possibly in many places) to
'how does the subprogram figure this out?' almost without thinking about
it.
And only go back to disturbing the established system to provide this
new information if, with my tail between my legs, I conclude that it's
something the subprogram just logically *cannot* figure out for itself.
Roy
In message <000001cafd4e$8991a360$6601a8c0@DJFJQK21>, Walter J. Murray
<[log in to unmask]> writing at 20:41:48 in his/her local time
opines:-
>Mike asks how to pass data to a subprogram without using a Linkage
>section.
>
>Assuming the main program and subprogram are both COBOL, here's a handy
>technique I have used to pass data between them without using parameters
>and a Linkage Section.
>
>Define data items in the Working-Storage Section of both the main
>program and the subprogram. Give them both the same name (important!)
>and the same Picture clause, and declare them both as EXTERNAL. A value
>stored in such a data item by one program will be "seen" by the other.
>
>It's a handy way to pass additional data between a program and a
>subprogram, without having to change the calling sequences (in possibly
>many programs).
>
>Walter
>
>Walter J. Murray
>
>
>-----Original Message-----
>From: HP-3000 Systems Discussion [mailto:[log in to unmask]] On
>Behalf Of Michael Caplin
>Sent: Wednesday, May 26, 2010 8:20 AM
>To: [log in to unmask]
>Subject: [HP3000-L] BLOCK MODE VARIABLE
>
>I have a subprogram that can be called from a block or character mode
>main
>program and I want the sub to know which called it without anything
>being
>passed in linkage. I can think of some ugly ways to do it. Does anyone
>know
>of an easy/simple way.
>TIA,
>mike
>
>* To join/leave the list, search archives, change list settings, *
>* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
>
>* To join/leave the list, search archives, change list settings, *
>* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
--
Roy Brown 'Have nothing in your houses that you do not know to be
Kelmscott Ltd useful, or believe to be beautiful' William Morris
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|