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

Well, I've learned something new today.  I was always told RPG did not
support recursion.  Of course, I've never had a need for it, or at least,
never thought of a need.
RPG III does not support recursion.  ILE supports recursion.  I'm not sure
if ILE RPG program calls allow recursion, but procedure call definitely do.

Just this morning I wrote a program with a procedure which calls itself
recursively to walk a tree of records (like a bill-of-materials but not
actually that).  Since the operating system makes sure that there are
separate copies of the local variables, all I have to do is reposition the
file back to where it needs to be after returning from a callp.  This saves
needing to have a MODS or arrays to save data.

The only limitation is that procedures calls are limited in depth.  It was
255.  It could have been raised in the newer releases.  With the data I'm
working with, the depth should never be more than about three, so I'm not
checking for the limit.  If I hit the recursion limit I want the program to
crash.

If you need a greater depth than whatever the recursion limit is, you would
need to fall back to the old methods.

Ken
Opinions expressed are my own and do not necessarily represent the views of
my employer or anyone in their right mind.



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.