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

Username:   Password: 
 RegisterRegister   
 any key pressed
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
lordroba




PostPosted: Sat Oct 14, 2006 7:18 pm   Post subject: any key pressed

(sorry, for the newb question but I am really lazy right now)

Can somebody give me the syntax to detect if a key was pressed. To be used like the example below(with proper syntax of course). I need the part with the '*'


If condition.... then
blah
blah
*Wait for a any key to be pressed, then continue
blah
blah
end if
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sat Oct 14, 2006 7:48 pm   Post subject: (No subject)

the [Turing Walkthrough] -> Input.KeyDown
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
TokenHerbz




PostPosted: Sat Oct 14, 2006 11:01 pm   Post subject: (No subject)

code:

Input.Pause
lordroba




PostPosted: Sun Oct 15, 2006 5:40 pm   Post subject: (No subject)

Actually I found that

code:
var ch : string (1)
getch (ch)


got the job done better. Thanks for the help guys Very Happy
[Gandalf]




PostPosted: Sun Oct 15, 2006 5:43 pm   Post subject: (No subject)

Why would you say that? I'd say it gets the job done worse. Why use two lines when you only need one?
Cervantes




PostPosted: Sun Oct 15, 2006 5:48 pm   Post subject: (No subject)

Also, think about this: your way requires you to create another global variables. The number of global variables should be minimized as much as possible, to make things more organized and clean. This is just making it messier.
frank26080115




PostPosted: Mon Oct 16, 2006 5:18 pm   Post subject: (No subject)

i find this works as a good "any key"

code:

loop
exit when hasch
end loop


it pauses the program until a key is pressed

"getch" always shows a flashing black thing that i dont like, and you cant hide the window during "getch"
richcash




PostPosted: Mon Oct 16, 2006 5:58 pm   Post subject: (No subject)

Quote:
"getch" always shows a flashing black thing that i dont like, and you cant hide the window during "getch"

code:
View.Set ("nocursor")
Sponsor
Sponsor
Sponsor
sponsor
lordroba




PostPosted: Mon Oct 16, 2006 8:06 pm   Post subject: (No subject)

hey, it's me again. sorry, you guys were right, Input.Pause does work a lot better. I had a bug in my code that was causing some undesired effects with Input.Pause before, so that's why I was hesitant to use it. Anyways, thanks again. (and sorry if I came off as a little cocky before, my bad)
Andy




PostPosted: Thu Oct 19, 2006 3:05 am   Post subject: (No subject)

frank26080115 wrote:
i find this works as a good "any key"

code:

loop
exit when hasch
end loop


it pauses the program until a key is pressed

"getch" always shows a flashing black thing that i dont like, and you cant hide the window during "getch"


if you dont have getch, then you can never use that hasch trick again because the character will remain in the buffer
Cervantes




PostPosted: Thu Oct 19, 2006 9:03 am   Post subject: (No subject)

On the contrary, you can use the hasch trick again. You need
code:
Input.Flush
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  [ 11 Posts ]
Jump to:   


Style:  
Search: