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

Username:   Password: 
 RegisterRegister   
 Unable to properly use my Input.KeyDown!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rovelius




PostPosted: Tue Apr 27, 2010 9:16 pm   Post subject: Unable to properly use my Input.KeyDown!

What is it you are trying to achieve?
I would like to be able to create a ENTER procedure in my code. I want to make a quiz which has question/answer, and then like when I click "ENTER" I want it to Clear Screen and move to the next question. I want to be able to make my variable become equal to NOTHING after ENTER has been clicked once, so it has to recheck and make me click ENTER again after other functions


What is the problem you are having?
code:
var continue : array char of boolean

procedure enter
    loop
        Input.KeyDown (continue)
        if continue (KEY_ENTER) then
            cls
            exit
        end if
    end loop
end enter

procedure Q1
    put "Type of Disorder Question"
    put "Pulmonary Fibrosis is a type of:"
    put "a) Temporary disease that causes swelling of the bronchioles and the interstitial tissues of the lungs"
    put "b) Long term disease that causes the swelling of the lips and the tongue"
    put "c) Chronic disease that causes swelling of the alveoli and the interstitial tissues of the lungs"
    put "d) Chronic disease that causes swelling of the bronchioles"
end Q1

procedure Q2
     put "Blablabla"
end Q2

locate (10, 20)
put "Testing this program"
enter
Q1
enter
Q2



Describe what you have tried to solve this problem
I am logically thinking that after I click ENTER, this saves my variable, and it bypasses the IF statement as it has been pressed and it does its function. While I do not want it to do that, I want it to recheck and look for another ENTER before it continues.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
TURING V4.1
Sponsor
Sponsor
Sponsor
sponsor
Euphoracle




PostPosted: Tue Apr 27, 2010 9:52 pm   Post subject: RE:Unable to properly use my Input.KeyDown!

You need to delay it. Turing will execute as fast as it can unless you tell it to wait. It will check if enter is pressed, say "YES" then immediately do Q1 then check again (all in under a millisecond!)

Consider using delay with an amount >= 50ms.
rovelius




PostPosted: Wed Apr 28, 2010 3:23 pm   Post subject: Re: Unable to properly use my Input.KeyDown!

Thank you very much!!! The delay worked brilliantly. Thank you for your help.

This is my final code:
code:

procedure enter
    loop
        Input.KeyDown (continue)
        if continue (KEY_ENTER) then
            cls
            exit
        end if
    end loop
    delay (50)
end enter
[/code]
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  [ 3 Posts ]
Jump to:   


Style:  
Search: