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

Username:   Password: 
 RegisterRegister   
 Press Enter to continue
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Fenrisulfr




PostPosted: Sun Mar 22, 2009 12:01 pm   Post subject: Press Enter to continue

I want my program to continue when the user presses the enter key so

Turing:

var enter : string (1) := chr (13)

loop
    Font.Draw ("Press ENTER to restart", 180, 80, defFontID, black)
    if hasch then
        getch (enter)
        exit
    else
    end if
end loop


but it continues anyway no matter what key I press. What am I doing wrong?
Sponsor
Sponsor
Sponsor
sponsor
BigBear




PostPosted: Sun Mar 22, 2009 12:04 pm   Post subject: RE:Press Enter to continue

You need to getch a key then exit your loop when that key is enter.
copthesaint




PostPosted: Sun Mar 22, 2009 12:08 pm   Post subject: Re: Press Enter to continue

Very basic and easy to do.
Turing:
var Keys : array char of boolean;
loop
Input.KeyDown (chars);
exit when chars (KEY_ENTER)
end loop/*exits loop when exit statment is true*/
put "Exited" /*to prove this works*/
BigBear




PostPosted: Sun Mar 22, 2009 12:15 pm   Post subject: RE:Press Enter to continue

If you break your program down line by line you are creating the variable enter and assigning it to chr(13)

Isn't enter 10?

Then you are in a loop displaying instructions then

Turing:
if hasch then
        getch (enter)
        exit
    else
    end if


Means if a key is pressed (hasch) then get a value for enter then exit the loop.

So it doesn't matter what key you enter it will exit.

try using an exit when statement.
Fenrisulfr




PostPosted: Sun Mar 22, 2009 12:26 pm   Post subject: Re: Press Enter to continue

yep got it to work... thank you all!
Insectoid




PostPosted: Sun Mar 22, 2009 1:13 pm   Post subject: RE:Press Enter to continue

I just Input.Pause for these.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: