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



Jon Paris wrote:
On 30-Jan-08, at 2:55 PM, midrange-l-request@xxxxxxxxxxxx wrote:

RPG has had recursion for more years than I have been with the platform.
Guessing it came in V3R1 when ILE came.

I just checked. I think you are right ;)

It arrived with subprocedures in V3R2/V3R6 - V3R1 RPG IV did not support recursion.


But it wasn't supported for programs until V6R1. (Not counting the pseudo-recursion that you could get with *NEW.)

In V6R1, you can have an RPG module with a new type of main procedure called a linear-main procedure, as opposed to a cycle-main procedure. An RPG program created with this new type of main procedure can be called recursively.

Basically, you code the MAIN keyword on the H spec saying which procedure will be the main procedure, then you code the procedure pretty much like an ordinary subprocedure. The difference is that the prototype has EXTPGM instead of EXTPROC.

H main(mypgm)
D mypgm pr extpgm('MYPGM')

// Main procedure for program MYPGM
P mypgm b
. . .
if something;
// make a recursive call to _program_ MYPGM
mypgm();
endif;
. . .
// when it gets here, it returns automatically
P e


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.