|
Hi, I am not sure whether this helps or not, but there is a "sledgehammer" approach to reinitialize all static variables in a program or service program: RINZSTAT MI. The program or service program must be compiled to allow this ALWRINZ(*YES) which is not the default. This is an alternative to RCLRSC (if in the default activartion group) or RCLACTGRP (if in a separate activation group). Regards, Kevin Wright. > -----Original Message----- > From: Larry Ducie [mailto:larry_ducie@xxxxxxxxxxx] > Sent: Thursday, 6 January 2005 7:19 AM > To: rpg400-l@xxxxxxxxxxxx > Subject: Re: Static procedure variables - how to re-initialise? > > > Hi Scott, > > <Scott wrote> > No. Variables that are local to a subprocedure can only be > accessed from > that subprocedure (unless passed as a parm to something else, > referenced by > a global pointer, etc) > > So you need to add a "mode" parm to SimpleProc() or use a > global variable. > </Scott wrote> > > This is what I thought, and is the documented position of > IBM. I was hoping > that there was a neat trick that'd do the job. > > <Scott then wrote> > Sometimes you want to retain the value of something, but then > have it get > reset each time you call the subprocedure. For example, if > you created a > data structure in a subprocedure and returned a pointer to > it. You might > reset the contents of that data structure at the start of the > subproc every > time it's called -- and therefore don't need to be able to > initialize it > somewhere else. A static variable would work for that (It's > not the way I'd > do it, but it would work.) > </Scott then wrote> > > This may well be the neat trick! > > I can see now that the obvious benefit of static procedure > variables is the > ability to pass a static reference to other static variables > when returning > a call. This would usually be disasterous as all automatic storage is > vulnerable to the system reclaiming it once the call has > returned. Static > storage does not have this problem. > > So you could call a subprocedure that performs some action > and returns a > pointer to some internal static storage. This could be the > derived address > of a procptr , not just a data pointer! It could even be a > pointer to a ds > of pointers! > > Hmmm... > > Another possibility for experimentation to add to the > ever-growing list. :-) > > Cheers > > Larry Ducie > > > -- > This is the RPG programming on the AS400 / iSeries (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 mailing list archive is Copyright 1997-2025 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.