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



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



As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.