Computer Science Canada

Getch

Author:  Beast_ [ Mon Jan 23, 2006 4:35 pm ]
Post subject:  Getch

Hey. I want to do one of those commands that when you say "Press any key to continue.", the user presses whatever key and it moves them up to the next step to the program. I forget how to do it, but i know getchs are involved. Help me plz Smile

Author:  Rasta Fella [ Mon Jan 23, 2006 4:53 pm ]
Post subject: 

You can also use this command Input.Pause It justs waits fo a user to input a key.

Author:  blaster009 [ Mon Jan 23, 2006 5:15 pm ]
Post subject: 

But don't say "Any key". Input.Pause doesn't accept certain keys (Control for example). My teacher, who prides himself in looking for ways to make my programs fail (because I have a 96 in the class, I suppose) made sure to take away marks because I said "Any key" and Input.Pause failed to recognize the Page Up button.

Author:  Rasta Fella [ Mon Jan 23, 2006 5:24 pm ]
Post subject: 

blaster009 wrote:
But don't say "Any key". Input.Pause doesn't accept certain keys (Control for example). My teacher, who prides himself in looking for ways to make my programs fail (because I have a 96 in the class, I suppose) made sure to take away marks because I said "Any key" and Input.Pause failed to recognize the Page Up button.


Yeah, actually alot of keys dont work when you use Input.Pause(page up, page down, end, insert etc.) But that's the only command I of my knowledge know that can be used for (press any key). But in general alot of keys on the keyboard work in accordance to this. If there is another method which can make you literally "press any key to continue" I would like to know for further reference.

Author:  person [ Mon Jan 23, 2006 6:26 pm ]
Post subject: 

Beast wrote:
Hey. I want to do one of those commands that when you say "Press any key to continue.", the user presses whatever key and it moves them up to the next step to the program. I forget how to do it, but i know getchs are involved. Help me plz


code:

var a : string (1)
getch (a)

Author:  Beast_ [ Mon Jan 23, 2006 7:50 pm ]
Post subject: 

He is right. I remember my programming teacher teaching us that stuff way back. She set it up like this:

code:
var stop : string (1)
put "Press any key to continue."..
getch (stop)
cls



To my knowledge, that is the most efficient way of doing a user-triggered continuation of a program, if you ever want it to clear the screen, to make your program look neater. Smile

Author:  Delos [ Mon Jan 23, 2006 8:51 pm ]
Post subject: 

Efficient, perhaps. Stable? No - so very simply crashed. Laughing

Author:  Clayton [ Tue Jan 24, 2006 2:03 am ]
Post subject: 

how did this crash
code:

var a:string(1)
getch(a)
cls

??????????
its never crashed for me

Author:  Delos [ Tue Jan 24, 2006 10:21 am ]
Post subject: 

Ah yes...well, since no one has ever mentioned this bug in Turing before, I'll keep it to myself for a while longer. It's not important, since I only know about 2 other people who are privvy to this knowledge...
In other words, the getch() method is, for all intents and purposes, good.

Author:  person [ Tue Jan 24, 2006 5:14 pm ]
Post subject: 

it doesnt crash for me

Author:  Clayton [ Wed Jan 25, 2006 2:56 pm ]
Post subject: 

Rasta Fella wrote:
blaster009 wrote:
But don't say "Any key". Input.Pause doesn't accept certain keys (Control for example). My teacher, who prides himself in looking for ways to make my programs fail (because I have a 96 in the class, I suppose) made sure to take away marks because I said "Any key" and Input.Pause failed to recognize the Page Up button.


Yeah, actually alot of keys dont work when you use Input.Pause(page up, page down, end, insert etc.) But that's the only command I of my knowledge know that can be used for (press any key). But in general alot of keys on the keyboard work in accordance to this. If there is another method which can make you literally "press any key to continue" I would like to know for further reference.

use the hasch command, in this case it would be used in a loop
code:

loop
exit when hasch
end loop

this way the loop will end whenever the program detects a character
(hasch means has character) you can try that


: