Author |
Message |
Fenrisulfr

|
Posted: 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

|
|
 |
BigBear
|
Posted: 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

|
Posted: 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
|
Posted: 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
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

|
Posted: Sun Mar 22, 2009 12:26 pm Post subject: Re: Press Enter to continue |
|
|
yep got it to work... thank you all! |
|
|
|
|
 |
Insectoid

|
Posted: Sun Mar 22, 2009 1:13 pm Post subject: RE:Press Enter to continue |
|
|
I just Input.Pause for these. |
|
|
|
|
 |
|