ID Number: Q71771
3.00 3.10 3.11 3.12 3.50
OS/2
Summary:
Under OS/2, some functions such as getch(), getche(), and KbdCharIn()
may take longer to carry out when a program is run from within the
CodeView environment. The two sample programs below can be used to
demonstrate this behavior, which is the result of input processing
that is done by CodeView.
More Information:
When run under OS/2, the getch(), getche(), and KbdCharIn() functions
read characters directly from the console. These functions run slower
inside CodeView because CodeView automatically installs a keyboard
monitor to allow recording of user input to a program. This monitor
can be disabled with the /K command-line option. For example:
CVP /K TEST
Using the /K option will limit your ability to record debugging
sessions for dynamic replay. You can still record CodeView commands,
but you can't record user input to the program being debugged.
Another option is to use getchar(), which reads characters from stdin,
or to use getc(), which reads characters from a stream. Both of these
functions allow user input to be recorded without significantly
slowing down run time within CodeView.
Sample Code for getche()
------------------------
/* Compile options needed: /Zi /Od
*/
#include <conio.h>
#include <stdio.h>
void main(void)
{
int ch;
int true = 1;
do {
if ( kbhit() ) {
// ch = getchar(); // This function works at a normal speed.
ch = getche(); // This function runs slower in CVP.
}
} while( true );
}
Sample Code for KbdCharIn()
---------------------------
/* Compile options needed: /Zi
*/
#define INCL_KBD
#define INCL_VIO
#include <stdio.h>
#include <os2.h>
void main(void)
{
KBDKEYINFO kbci;
int true = 1;
do {
KbdCharIn( &kbci, IO_NOWAIT, 0);
if ( kbci.fbStatus != 0)
VioWrtTTY( &kbci.chChar, 1, 0 );
} while( true );
}