Computer Science Canada How to make a functioning loop in Turing? |
Author: | Mattlap [ Wed Apr 27, 2011 8:42 pm ] | ||
Post subject: | How to make a functioning loop in Turing? | ||
What is it you are trying to achieve? So basically I want to learn how to program. I would love to get into a programming oriented career (I'm in Gr. 9 by the way), and I'm taking Computer tech. Right now we're doing a little programming unit and it's really interesting. I downloaded Turing for my home, and I've used it a couple times. I can do the basic things like 'put', 'get', 'if', things like that, but I tried to make a loop. I don't know what's wrong. (I should explain that this is part of a project in my class to write 10 questions. This is one of them and I want to get a level 4 [i.e. going above and beyond what is expected] but if i can't figure this out, I feel that my chances of that 4 are slipping) Any help would be appreciated -Matt What is the problem you are having? It goes into a continuous loop that I can't get out of. Describe what you have tried to solve this problem I've really been trying to work it out here (my house) and at school for about an hour and I haven't been able to fix it. I've followed all of the error messages to the letter. It runs fine until this point, then if you put in 'yes' to the question, it goes in a continuous loop of asking "Are you sure?" while saying "Alright, let's get started." Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) put "Do you mind if I ask you some questions?"
Please specify what version of Turing you are using 4.1.1 |
Author: | Insectoid [ Wed Apr 27, 2011 8:46 pm ] | ||
Post subject: | RE:How to make a functioning loop in Turing? | ||
You need an exit statement. It's kind of like an 'if'.
If quit = "yes" the loop will exit. |
Author: | Tony [ Wed Apr 27, 2011 8:48 pm ] |
Post subject: | RE:How to make a functioning loop in Turing? |
You will need to use exit to terminate a loop. Reading tutorials we have posted on the forums will also help with the understanding of various concepts. |
Author: | Mattlap [ Wed Apr 27, 2011 8:50 pm ] |
Post subject: | Re: How to make a functioning loop in Turing? |
I'll try that right now. Thanks for the uber fast reply |
Author: | Zren [ Wed Apr 27, 2011 8:56 pm ] | ||
Post subject: | RE:How to make a functioning loop in Turing? | ||
Edit: God dammit you guys >.<' Loops for Dummies
|
Author: | Mattlap [ Wed Apr 27, 2011 9:03 pm ] |
Post subject: | Re: How to make a functioning loop in Turing? |
Alright so, to Insectoid: This is what happened: So I just tried what Insectoid said, and it said that there was a syntax error on 'quit'. This is what I put (because I don't remeber how to show it like it's showed in Turing): then loop put "Are you sure?" get ok if ok = "yes" then put "are you sure" elsif ok = "no" then put "Alright let's get started" exit when quit = "yes" end if end loop And as i said before, I just get a syntax error on the 'quit'. I also tried to substitute 'quit' for 'ok' (my variable) but it just repeated "are you sure?" (like it said it twice and did the 'get' command) And as for you Zren, all I could do was stare blankly at that, you have got to understand that i know next to nothing about programming (as I am in grade nine and this is literally my first exposure to programming) |
Author: | Tony [ Wed Apr 27, 2011 9:10 pm ] |
Post subject: | RE:How to make a functioning loop in Turing? |
quit is a keyword, not a variable name. The syntax error should have mentioned something along those lines. |
Author: | Mattlap [ Wed Apr 27, 2011 9:17 pm ] |
Post subject: | Re: How to make a functioning loop in Turing? |
Wow, I feel stupid now lol. Thanks so much, definately going to get that 4 now |