Computer Science Canada

Please help me exit this loop

Author:  bushnerd [ Tue Dec 27, 2005 9:21 pm ]
Post subject:  Please help me exit this loop

I am using the getch command and am trying to exit the loop when the box is clicked. Any idea what I am doing wrong, or how to improve this?



code:
procedure playbox
    cls
    demonstrationintro
    var note : string (1)
    var xmouse, ymouse, button : int
    mousewhere (xmouse, ymouse, button)
    drawfillbox (275, 260, 335, 320, 4)
    locatexy (280, 245)
    put "Exit"
    loop

        getch (note)
        if note = "1" then
            note2C
        elsif note = "2" then
            note4C
        elsif note = "3" then
            note2D
        elsif note = "4" then
            note4D
        elsif note = "5" then
            note2E
        elsif note = "6" then
            note4E
        elsif note = "7" then
            note2G
        elsif note = "8" then
            note4G
        end if
        exit when xmouse >= 275 and xmouse <= 335 and ymouse >= 260 and ymouse <= 320 and button = 1
    end loop
end playbox


thanks

Author:  MysticVegeta [ Tue Dec 27, 2005 9:29 pm ]
Post subject: 

No you dont have to use getch. Check Input.KeyDown if you have Turing 4.0.5

Author:  MysticVegeta [ Tue Dec 27, 2005 9:36 pm ]
Post subject: 

Also. The mousewhere should be inside the loop because otherwise it would just take one position (thestarting one)

Author:  bushnerd [ Tue Dec 27, 2005 10:26 pm ]
Post subject: 

Thank you, putting the mousewhere inside the loop did the trick. I was justing using the getch command just to get the program to work so that I have to do minor editing in class. We have to use parallelget to get input from a push button box that we will have made. Thanks again.


: