[Coladam] SMARTLOGO TIPS - RECURSIVE PROCEEDURES

Daniel Bienvenu newcoleco at yahoo.fr
Fri Feb 19 21:13:45 CET 2010


>From "THE U.K. ADAM SUBSCRIBERS JOURNAL, ISSUE : FEB-MAR 91, PAGE 29"

Writing a SmartLOGO proceedure is just the same as teaching the computer a new command. A recursive proceedure tells the computer to act on the command again and again until you hit the <ESCAPE> key. 

Take this example:-

TO M:SIZE
FD :SIZE
LT 30
BK :SIZE
RT 60
FD :SIZE
LT 30
BK :SIZE
M  :SIZE
END

After saving it to the memory by pressing the <VI> key and run it by typing M 20 at the ? prompt. This gives M an initial value of 20 and draws the letter M over and over across the page. Adding + 20 to the 9th line making M  :SIZE + 20 and you will get an increasingly  larger letter M until the <ESCAPE> key is pressed.

You can control it's size by adding the line, IF :SIZE = 200 [STOP]

TO M:SIZE
IF :SIZE = 200 [STOP]
FD :SIZE
LT 30
BK :SIZE
RT 60
FD :SIZE
LT 30
BK :SIZE
M  :SIZE + 20
END

Now try this :-

TO SPIDER :N
IF :N > 50 [STOP]
FD :N
RT 30
SPIDER :N + 0.1
END

No prizes for guessing what this program does but type it in anyway. N goes up with an increment of 0.1 until N attains a level that is equal or higher than 50. when this is reached, the program stops. Type SPIDER 1 to run.

Send in your efforts for a regular LOGO spot in this newsletter.
 


      


More information about the Coladam mailing list