Recursion in programs involves calling up the program to run again from the beginning. If not done carefully it can create infinite loops of code that won't terminate. If you run a program that gets stuck in a loop you can press the On button; the On button terminates execution of any program.
How to do itEdit
Writing code that does is simple, within the program you simply have a call to the current program. The syntax is PRGM:EXEC then whatever program.
PROGRAM:TEMP ://code ://code :pgrmTEMP
If you use recursion you always want to have some condition that has to be met in order for the recursive call to happen. An easy way to do this is to encapsulate the recursive call in an "If" statement or a while loop.
In this example we will write a simple counting program. Before we run this program we have to set X to a number, for this example we will assume it has been set to 0.
PROGRAM:COUNT :While X≤3 :Disp X :X+1->X :prgmCOUNT (Note: End is not needed here since the while already loops)
prgmCOUNT 0 1 2 3