Computer Science Canada

Key Press

Author:  Alpha [ 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?

Author:  Dan [ Sun Feb 09, 2003 10:23 am ]
Post 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

Author:  Alpha [ Sun Feb 09, 2003 8:01 pm ]
Post 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.

Author:  Tony [ Mon Feb 10, 2003 3:56 pm ]
Post 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


: