HP3000-L Archives

December 2001, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Shahan, Ray" <[log in to unmask]>
Reply To:
Shahan, Ray
Date:
Mon, 17 Dec 2001 14:41:02 -0600
Content-Type:
text/plain
Parts/Attachments:
text/plain (120 lines)
Mr. Fochtman incorrectly states:


"In COBOL, a subprogram by default is DYNAMIC, which essentially
causes the data items to be declared Q-relative and thus not
retain their values between calls. However, if one declares the
routine as NON-DYNAMIC, the declared variables become DB-relative
and will retain their value between calls. This is outlined in
Ch 11 in the COBOL II reference manual."



The manual actually states:

"If you do not use one of these $CONTROL options and the source program
contains a LINKAGE SECTION, it is compiled as a non-dynamic subprogram. A
program containing no LINKAGE SECTION is considered a main program unless
$CONTROL SUBPROGRAM, DYNAMIC, or ANSISUB[REV BEG] or PROGRAM IS INITIAL
clause[REV END] is used for that program. ".

Thus the DEFAULT of a sub-prog is to NOT re-init WS values.

Ray S.




> -----Original Message-----
> From: Jerry Fochtman [SMTP:[log in to unmask]]
> Sent: Tuesday, December 18, 2001 1:47 AM
> To:   [log in to unmask]
> Subject:      Re: Retention of switch value in called program
>
> FYI....  Declaring an initial value in a DATA statement in
> FORTRAN essentially causes the variable to be 'static', known
> only to the routine declaring it.  For subroutines, this has
> the affect of having the address of the variable located
> in DB-relative and not Q-relative. Also, the variable is not
> 'reinitialized' on every call to the subroutine as the DATA
> statement initialization only occurs once at initial load/run
> of the program following the resolution of the links.  However,
> knowing this can also save stack space as sometimes programmers
> did this all the time and thus consumed large amounts of the
> DB-portion of the stack when it wasn't really necessary.
>
> In COBOL, a subprogram by default is DYNAMIC, which essentially
> causes the data items to be declared Q-relative and thus not
> retain their values between calls. However, if one declares the
> routine as NON-DYNAMIC, the declared variables become DB-relative
> and will retain their value between calls. This is outlined in
> Ch 11 in the COBOL II reference manual.
>
>
> At 10:23 AM 12/17/01 -0800, David T Darnell wrote:
> >This sounds like it works the same as the FORTRAN "COMMON" declaration.
> >There is another method for making a variable "static", which is:
> >
> >       INTEGER IVAR
> >       SAVE IVAR
> >
> >The above doesn't make IVAR available to other programs or subroutines,
> it
> >just allocates it as static, so that the next time the subroutine is
> >entered, the value is the same as the last time the subroutine was
> exited.
> >
> >Variables (once defined) can be added to a COMMON declaration, which can
> >be named or not. then, the same memory locations are available to all
> >subprograms in the same instance of a program, but are not shared among
> >multiple instances of the program (i.e. different sessions). On the
> >HP1000, we also had SYSTEM COMMON which would allow multiple programs
> >whether or not in different sessions to share the same memory locations.
> >
> >-dtd
> >
> >
> >
> >
> >
> >
> >
> >[log in to unmask] on 12/17/2001 09:51:00 AM
> >To:     [log in to unmask]@Internet
> >cc:      (bcc: David T Darnell/CO/KAIPERM)
> >Subject:        Re: [HP3000-L] Retention of switch value in called
> program
> >
> >Another approach I have used successfully from time to time is to declare
> >data items as EXTERNAL.
> >
> >This is a feature of COBOL-85 and beyond so the appropriate $CONTROL and
> >compiler entry point must be used.
> >
> >Basically, EXTERNAL creates a region outside your program which is shared
> >among and between the main program and subroutines without using the
> USING
> >clause.
> >
> >Each routine may change the area as it sees fit and the data remains as
> it
> >was last changed.
> >
> >You could also do this with data records because EXTERNAL can also be
> used
> >for files as well as the WORKING-STORAGE SECTION.
> >
> >This works whether the subroutines are called statically or dynamically.
> >
> >* 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 *
>
> * 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 *

ATOM RSS1 RSS2