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




Apart from having to reclaim an activation group or defining a "mode" procedure parameter, does anybody know a good way to re-initialise a static procedure variable?

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.

If I have to make the variable global - what benefit is there of using static procedure variables? I'm not trying to be churlish - I just can't seem to make sense of it. :-)

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


One solution, of course, is to put SimpleProc() in it's own service prgoram by itself. Give it it's own unique activation group, and use the RCLACTGRP command to reset the counter. I guess that's better than resetting the entire program each time.

The other way -- the way I usually go about it -- is to have two subprocdures... maybe call them ResetSimpleProc() and SimpleProc() and put them in their own module. That way, you can declare a global variable that only those two subprocedures can access, and you can clear the variables by calling ResetSimpleProc() without needing to reclaim the activation group. You could even use bind-by-copy if you wanted the routines to be part of a particular program and only that program.

HTH

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.