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

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




PostPosted: Sun Feb 09, 2003 10:12 am   Post subject: Key Press

Hi.

Say in a program after the initial run, you need to ask the user to either press R to rerun, enter to continue. How would you go about doing so?
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Sun Feb 09, 2003 10:23 am   Post subject: (No subject)

try somting like this:

code:

var key: string(1)

put "hit  r to  returen, hit c to contwen"

loop
getch(key)

if key = "r" then
put "now going back to progame"
%code here
end if

if key  = "c"  then
put "contiuowing"
%code  here
end if
end loop


sory for the bad spelling Sad
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Alpha




PostPosted: Sun Feb 09, 2003 8:01 pm   Post subject: (No subject)

How about say if I wanted the user to press the Enter key in order for the program to continue. I can't seem to find anything that would allow key recognition.
Tony




PostPosted: Mon Feb 10, 2003 3:56 pm   Post subject: (No subject)

you can use this program to determined ASCII value of any key pressed

code:

var c:string(1)
getch(c)
put ord(c)


or just simply use

code:

loop
if hasch then
getch(c)
exit
end if
end loop

continue program here...


hasch returns true if any key is waiting to be read from the buffer
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: