/
nesting.toby
50 lines (41 loc) · 1.08 KB
/
nesting.toby
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//--------------------------------------------------------
// nesting.toby -- A program to test nested FORs and IFs.
//
// This program will draw boxes increasingly large, and
// in many colors, to test if Toby can handle some
// nested FORs and IFs. It should look like a square
// with different colored lines pulsing, and in the
// end, four squares, moving in different directions
// should be drawn.
//
// There are cleaner ways to write this program, but
// we wanted to nest stuff.
//
// Copyright (c) 1999 Lighting and Sound Technologies
// Written by Ryan C. Gordon.
//--------------------------------------------------------
function main() returns nothing
number totalIterations
number boxSize
number boxLoop
number color
number direction
hideTurtle()
for direction = 1 to 4
color = 0
for totalIterations = 1 to 5
for boxSize = 1 to 100
color = color + 1
if (color > 15)
color = 0
endif
setPenColor(color)
for boxLoop = 1 to 4
goForward(boxSize)
turnLeft(90)
endfor
endfor
endfor
turnRight(90)
endfor
endfunction