
-----------------------------------
Mattlap
Wed Apr 27, 2011 8:42 pm

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 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?"


get ok 
if ok = "no"
then put "Alright then let's get started"
elsif ok = "yes"
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"
    end if
    end loop
end if




Please specify what version of Turing you are using
4.1.1

-----------------------------------
Insectoid
Wed Apr 27, 2011 8:46 pm

RE:How to make a functioning loop in Turing?
-----------------------------------
You need an exit statement. It's kind of like an 'if'.

[code]
loop
    exit when quit = "yes"
end loop
[/code]

If quit = "yes" the loop will exit.

-----------------------------------
Tony
Wed Apr 27, 2011 8:48 pm

RE:How to make a functioning loop in Turing?
-----------------------------------
You will need to use [tdoc]exit[/tdoc] to terminate a loop. Reading tutorials we have posted on the forums will also help with the understanding of various concepts.

-----------------------------------
Mattlap
Wed Apr 27, 2011 8:50 pm

Re: How to make a functioning loop in Turing?
-----------------------------------
I'll try that right now. Thanks for the uber fast reply  :D

-----------------------------------
Zren
Wed Apr 27, 2011 8:56 pm

RE:How to make a functioning loop in Turing?
-----------------------------------
Edit: God dammit you guys >.