× 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.



I was trying to figure out why static variables in a subprocedure are
not being reinitialized when I reenter the program.

Being a good boy, I did a little research and found Barbara's answer
from two years ago, which as always is clear and complete.
Unfortunately, it's very frustrating, because it's not what I want to
hear <grin>.

"I think what you're suggesting is that when a _module_'s (not program)
main procedure returns with LR on, when that main procedure gets called
again, the subprocedure static should get reinitialized along with the
other globals in the module.  Maybe that would have been the right
behaviour, maybe not.  What about calls to the subprocedures between
calls to the main procedure?  Should the subprocedures be reinitialized
even before the main procedure gets called again?

As to whether this is right or wrong, maybe it would have been better to
have different behaviour for subprocedures in a module with a main.
Maybe
the subprocedures' static should have been subject to LR
reinitialization.
Or at least non-exported subprocedures.  But then there would have been
different behaviour for a subprocedure in a NOMAIN module.  Our thinking
was that subprocedures are more ILE-ish than RPG-ish, and should behave
like ILE things, and not be subject to the RPG cycle."


Okay, I can buy this.  It simply means that anything I want
reinitialized whenever the program restarts has to be global.  Pluses
and minuses there, but it's at least a workaround.

I would ask for one thing.  I would love a keyword either on the D spec
(or even up at the PI level) along the lines of *GLBREINZ that would say
"reinitialize this variable whenever global reinitialization is done".
That would allow us the best of both worlds.

Joe


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.