Key Press
Author |
Message |
Alpha
|
Posted: 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
|
|
|
Dan
|
Posted: 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 |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
Alpha
|
Posted: 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
|
Posted: 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 |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
|
|