Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with loops!!!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Kwisatz




PostPosted: 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 Sad...anyhelp would be great guys!!
Sponsor
Sponsor
Sponsor
sponsor
azndragon




PostPosted: 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




PostPosted: 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
code:
loop
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




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: