Help with loops!!!
Author |
Message |
Kwisatz
|
Posted: Wed Jan 08, 2003 7:50 pm Post subject: Help with loops!!! |
|
|
Hey guys i need sum help w/ a game. I'm done the whole game but i dunno how 2 loop it ...anyhelp would be great guys!! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
azndragon
|
Posted: Wed Jan 08, 2003 8:00 pm Post subject: (No subject) |
|
|
Use one of the following loops:
loop
put "Hi"
end loop
This way, the computer will say Hi forever.
You can also add an exit statement, such as:
exit when number > 1
This will have Turing exit the loop when number is over 1.
You can also try this loop:
for i : 1..20
put "Hi"
end for
This will have Turing say Hi 20 times, and then it will stop. |
|
|
|
|
|
Kwisatz
|
Posted: Wed Jan 08, 2003 8:06 pm Post subject: (No subject) |
|
|
its a game tho an i want it 2 ask the person too see if he wants to play again so i did this so i put it at the end
code: | cls
put "Do you want to play again? y/n"
get q
exit when q = "n"
end loop |
an i dunno where 2 put the cuz if i try putting it at the begining it always says "procedure's may only be declared at the program, module, or monitor level" |
|
|
|
|
|
Tony
|
Posted: Wed Jan 08, 2003 8:12 pm Post subject: (No subject) |
|
|
you put loop at the place where you want your program to start again once the loop is compeat. At the end of the loop, turing gous back to the 'loop' line and continues to run from there.
it should be smething like this
variables
procedures
loop
set varaible values here
main program
exit when answer="exit"
end loop
Hope this helps. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
|
|