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

Username:   Password: 
 RegisterRegister   
 Why won't it let me exit?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Hack.saw




PostPosted: Sun Jun 18, 2006 12:16 pm   Post subject: Why won't it let me exit?

code:

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? Embarassed
Sponsor
Sponsor
Sponsor
sponsor
TheOneTrueGod




PostPosted: Sun Jun 18, 2006 12:47 pm   Post subject: (No subject)

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.

code:

get instr
exit when instr = "bored"
upthescale




PostPosted: Sun Jun 18, 2006 4:55 pm   Post subject: (No subject)

the 'exit when' is inside the last if satment, try taking it out!!!!
Hack.saw




PostPosted: Sun Jun 18, 2006 8:51 pm   Post subject: (No subject)

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 Very Happy
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: