
-----------------------------------
Hack.saw
Sun Jun 18, 2006 12:16 pm

Why won't it let me exit?
-----------------------------------

var instr : string
var guitar : int := Pic.FileNew ("guitar.bmp")
var drumset : int := Pic.FileNew ("drumset.bmp")
var keyboard : int := Pic.FileNew ("keyboard.bmp")

loop
    put "What is your favourite instrument?"
    get instr
    if instr = "guitar" then
        Pic.Draw (guitar, 100, 100, picCopy)
        delay (2000)
        cls
    elsif instr = "drums" then
        Pic.Draw (drumset, 100, 100, picCopy)

        delay (2000)
        cls
    elsif instr = "keyboard" then
        Pic.Draw (keyboard, 100, 100, picCopy)
        delay (2000)
        cls

        exit when instr = "bored"
    end if
end loop
put "Happy Father's Day!"

It won't let me exit out of this- when you type in bored its just begins again saying "What is your favourite instument?". What do I do?  :oops:

-----------------------------------
TheOneTrueGod
Sun Jun 18, 2006 12:47 pm


-----------------------------------
Code is linear.  That exit when lies within the elsif construct "keyboard".  This means that it'll only check to see if instr is "bored" when instr is "keyboard".  Obviously it can't be both at once, so it'll never exit :wink: .  You'll want to put the exit when directly after the get line.


get instr
exit when instr = "bored"


-----------------------------------
upthescale
Sun Jun 18, 2006 4:55 pm


-----------------------------------
the 'exit when' is inside the last if satment, try taking it out!!!!

-----------------------------------
Hack.saw
Sun Jun 18, 2006 8:51 pm


-----------------------------------
hehe thanks guys that was my cousin posting on my acount she just learning turing and they way she said it over the phone I couldnt figure out the problem :D
