// Henjin Loop Demo // (c) 2008, Notequalsoft Games // http://www.notequalsoft.com/games/henjin/ // This demo demonstrates all of the different looping constructs. // setup system System.Size 640 480 System.Continue true System.CreateImage WaitImage 619 460 18 17 "waiting.gif" System.WaitImage WaitImage // create textbox to display loop counters System.CreateTextBox TextBox 0 0 640 480 TextBox.DisplayAtOnce true label START // goto loop TextBox.Text "Goto loop:\n" set counter = 0 label GOTOLOOP set counter + 1 TextBox.AddText "{counter}\n" react if counter < 10 goto GOTOLOOP endif // while loop TextBox.Text "While loop:\n" set counter = 0 while counter < 10 set counter + 1 TextBox.AddText "{counter}\n" react endwhile // do-until loop TextBox.Text "Do-Until loop:\n" set counter = 0 do set counter + 1 TextBox.AddText "{counter}\n" react until counter = 10 // for loop TextBox.Text "For loop:\n" for i 1 10 1 TextBox.AddText "{i}\n" react endfor // for loop with negative step TextBox.Text "For loop with negative step:\n" for i 10 1 -1 TextBox.AddText "{i}\n" react endfor // for loop with a fractional step TextBox.Text "For loop with a fractional step:\n" for i 1 10 0.5 TextBox.AddText "{i}\n" react endfor // for loop with a step that ensures it won't end on the final value TextBox.Text "For loop with step ensuring final value not hit:\n" for i 1 10 2 TextBox.AddText "{i}\n" react endfor // nested loop example TextBox.Text "Nested loop example:\n" for i 1 10 1 TextBox.AddText "{i}:" for j 1 i 1 TextBox.AddText " {j}" endfor TextBox.AddText "\n" react endfor // repeat demo goto START