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

Username:   Password: 
 RegisterRegister   
 Loop from only one of many choices -Help please?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
sportygal1994




PostPosted: Wed Mar 17, 2010 1:53 pm   Post subject: Loop from only one of many choices -Help please?

What is it you are trying to achieve?
I am trying to have the user select a choice from many different choices, and if one specific choice is selected then I want the program to loop back to the top of the code. If any other choice is chosen I don't want it to loop back.


What is the problem you are having?
I can't figure out how to make it loop from one option and not all of them.


Describe what you have tried to solve this problem
I put "loop" at the top of the code and "end loop" right above the "end if", since it is a choice. It tells me I have a syntax error and that it was expecting the "end loop" and the "end if" to have switched places.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
I decided to post a simple version to explain my problem. I'm actually trying to program a text-based adventure game, but I think this is easier to understand.

I'm trying to get it to loop back to the top after the user chooses the sad choice, but not the happy choice.
Turing:

var choice:int
put "Are you happy or sad?"
put "1) happy"
put "2) sad"
get choice
if choice=1 then
   put "good for you"
elsif choice=2 then
   put "why don't I try asking you again and you'll feel better."
end if


Please specify what version of Turing you are using
4.0.4c
Sponsor
Sponsor
Sponsor
sponsor
sportygal1994




PostPosted: Wed Mar 17, 2010 3:24 pm   Post subject: Re: Loop from only one of many choices -Help please?

Never Mind! I figured it out! I used an exit when statement! Thanx to all who looked at it though!
ProgrammingFun




PostPosted: Fri Mar 19, 2010 2:10 pm   Post subject: RE:Loop from only one of many choices -Help please?

I hope you realize that you can delete your post if you have solved the problem...
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  [ 3 Posts ]
Jump to:   


Style:  
Search: