Re: Linkage and Nested Subprograms
- From: "Frank Swarbrick" <Frank.Swarbrick@xxxxxxxxxxxxxx>
- Date: Wed, 22 Mar 2006 10:38:10 -0700
A "problem" with EXTERNAL GLOBAL, at least on my compiler, is that each
program within the run unit must have it declared exactly the same. In
other words, if you have...
01 EXT-DATA EXTERNAL GLOBAL.
05 EXT-1 PIC X(80).
05 EXT-2 PIC X(80).
If you want to add an EXT-3, say, then you have to recompile all of the
programs that include EXT-DATA, even if they don't "care" about the
additional data.
Not sure what Daniel is trying to do to know whether or not your way would
be fine.
Anyway, my compiler allows a LINKAGE SECTION data-name to specify the GLOBAL
clause. Not sure if this is an IBM extension or part of the COBOL 85/89
standard...
5.3.8 GLOBAL Clause
The GLOBAL clause specifies that a data-name is available to every program
contained within the program that declares it, as long as the contained
program does not itself have a declaration for that name. All data-names
subordinate to or condition-names or indexes associated with a global name
are global names.
A data-name is global if the GLOBAL clause is specified either in the data
description entry by which the data-name is declared or in another entry to
which that data description entry is subordinate. The GLOBAL clause
X can be specified in the Working-Storage Section, the File Section, and the
X Linkage Section, but only in data description entries whose level-number
is 01.
In the same Data Division, the data description entries for any two data
items for which the same data-name is specified must not include the GLOBAL
clause.
A statement in a program contained directly or indirectly within a program
which describes a global name can reference that name without describing it
again.
Two programs in a run unit can reference common data in the following
circumstances:
The data content of an external data record can be referenced from any
program provided that program has described that data record.
If a program is contained within another program, both programs can refer to
data possessing the global attribute either in the containing program or in
any program that directly or indirectly contains the containing program.
Frank
Pete Dashwood<dashwood@xxxxxxxxxxxxxx> 03/22/06 6:57 AM >>>
"LX-i" <lxi0007@xxxxxxxxxxxx> wrote in message
news:ba95e$4420a10a$45491d7a$14101@xxxxxxxxxxxxxx
With this discussion about nested subprograms, there's something that's
bugged me, but I'm not sure how to get around it (or if it can be gotten
around). If I have a subprogram, that itself has nested subprograms, only
the "main" subprogram has the linkage section visible. Is there a way to
make all the nested subprograms have visibility of the "main" subprogram's
linkage section (short of defining it and passing it with each call)?Sure, move the linkage parameters to a working-storage area defined as
EXTERNAL GLOBAL.(I do this in PowerCOBOL all the time).
(Some platforms might even let you apply these descriptors to Linkage
items... I'm not sure and I can't be bothered looking it up, so stick them
in WS; I KNOW that works... :-)
Pete.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ / \ / ~ Live from Montgomery, AL! ~
~ / \/ o ~ ~
~ / /\ - | ~ daniel@thebelowdomain ~
~ _____ / \ | ~ http://www.djs-consulting.com ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ GEEKCODE 3.12 GCS/IT d s-:+ a C++ L++ E--- W++ N++ o? K- w$ ~
~ !O M-- V PS+ PE++ Y? !PGP t+ 5? X+ R* tv b+ DI++ D+ G- e ~
~ h---- r+++ z++++ ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Who is more irrational? A man who believes in a God he doesn't see, or a
man who's offended by a God he doesn't believe in?" - Brad Stine
.
- Follow-Ups:
- Re: Linkage and Nested Subprograms
- From: Pete Dashwood
- Re: Linkage and Nested Subprograms
- References:
- Linkage and Nested Subprograms
- From: LX-i
- Re: Linkage and Nested Subprograms
- From: Pete Dashwood
- Linkage and Nested Subprograms
- Prev by Date: Re: Constants, Static, Public, Private
- Next by Date: Re: How to convert FB file to VBS32760 file?
- Previous by thread: Re: Linkage and Nested Subprograms
- Next by thread: Re: Linkage and Nested Subprograms
- Index(es):