× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Ooops! My aplogies Alan - I had missed the bit where you said "program using the main keyword" - in which case I would not expect it to go away - since the program cannot end with LR on. In which case, it stays there until the activation group is reclaimed/ended

Regards

Paul Tuohy
ComCon
www.comconadvisor.com www.systemideveloper.com




Paul Tuohy wrote:
Hi Alan,

Not quite true. When a program ends with LR on, the static storage is not released but it is re-initialized when the program is called again.

Have a look at the following program. If I understood you correctly, you are saying that, if I call the program 3 times, I will see the values 1, 2, 3. I say you will see the values 1, 1, 1.

H dftActGrp(*No) actGrp('TEST')

d i s 5i 0

/free
i += 1;
dsply i;
*inLR = *On;
/end-Free

Regards

Paul Tuohy
ComCon
www.comconadvisor.com www.systemideveloper.com




Alan Campin wrote:
Global just means static storage. It never goes away.

An interesting question that maybe Barbara can answer is when does the
static storage go away when a program using the main keyword ends.

I know that static storage does not go away when a program using the main
keyword ends. LR has no meaning. It still is out there. I tried a test
program and determined that if you call a program with a global variable and
initialize to some value and end the program, if you go back in to the
program the storage is still set at the previous value. It does not reset or
destroy it.

So the question becomes when does the storage get released?

On Thu, Nov 11, 2010 at 9:21 AM, Nathan Andelin <nandelin@xxxxxxxxx> wrote:

I'll throw out a suggestion just for terminology sake. I prefer to call
module-level declarations, "module-level declarations", as opposed to
"procedure-level declarations", and rather than "global declarations". To
me a
global declaration would be something that might be shared across an entire
activation group, which might include any number of programs and service
programs in a call stack. Say you export a data structure from a service
program, for example, which is intended to be shared across an entire
activation
group. That's a lot more global than "module-level" declarations.

-Nathan.



----- Original Message ----
From: Vern Hamberg <vhamberg@xxxxxxxxxxx>
To: RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
Sent: Thu, November 11, 2010 8:46:08 AM
Subject: More on global declarations in RPG IV

In a recent thread, there was some question about global variables,
etc., when using the MAIN control keyword. I had mentioned that some
things still must be global. I believe that one of them is compile-time
arrays. If you want to find all the messages that deal with "global",
here's a way to do that -

Execute the following command -

DSPMSGD RANGE(*ALL) MSGF(QDEVTOOLS/QRPGLEMSG) DETAIL(*FULL) OUTPUT(*PRINT)

Then you can search for 'lobal' in the spooled file - this covers
possible upper- or lower-case "G" in the word "global"

So have fun. And I did find, in the RPG ILE Reference, this note about
CTDATA, footnote 2

This keyword applies only to global definitions.

Random musings while on vacation! I know, I'm rubbing it in!
Vern



--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.