Problem solve Get help with specific problems with your technologies, process and projects.

Recursive call

This tip walkes you through a simple program called "recursivilly".

Unfortunately, RPG does not support recursivity nor can we call a program that's already in the program stack. But there are cases when this would be greatly appreciated. So I here propose a trick, in the form of a small simple program, that lets us do just that. It consist in creating a duplicate of the program we intend to call "recursivilly" in library QTEMP, under another name. The code for that program UTRCPGM follows. I also provide an example: traditional case for recursivity, the calculation of the factorial of a given number, in the program UTRKFACT. Program TESTRFACT and Display File TESTDFACT provide the user interface.


To review this code, click here.

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

Search400's targeted search engine: Get relevant information on RPG.

Dig Deeper on iSeries CL programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close