image\gflag13_shg.gif

Tutorial Course - Hole #13

 

The last structure left to discuss is also the most complex. The For command controls the number of times a snippet of code is executed. The variable is incremented each time through until the value is reached.

 

image\lolli.gifRemember the infamous question posed, "How many licks does it take to reach the center of the tootsie roll tootsie pop?" In case you've forgotten your Saturday morning cartoons, the answer is "Three, it takes three licks to reach the tootsie roll center of the tootsie roll".

Let's use the For command to ask this very important question.

center=2
For licks = 1 to center
Display(2, "Tootsie Roll Center", "Taking lick # %licks%")
Next
Message("Answer to the Universe", "%licks% licks to reach the tootsie roll center.")