[comp.sys.apollo] Character I/O &Starbase

ix@cosmo.UUCP (Redaktion ix) (10/09/89)

Re  Character Processing with HpWindows &
Starbase


Hi, everyone interrested...

working with HPWindows and Starbase can be rather
strange, especially when I tried to have I/O in a
graphical window.

The reason is that according to my experience the
BACKSPACE and the DOT have got the same code (the
same applies to RETURN/CR and the "9".

I'd be very grateful, if anyone knew a more or
less efficient solution for this.

Thanks galore (in advance...)


Henning Behme
ix@cosmo.uucp

stroyan@hpfcdq.HP.COM (Mike Stroyan) (10/12/89)

When asking about HP systems that are not from the Apollo Division,
posting to comp.sys.hp instead of comp.sys.apollo will be more likely to
catch the eye of someone with the answer to your question.

HP Windows/9000 has three different input modes, ASCII, Two-Byte, and
Packetized.  I assume from your question that you are using either the
Two-Byte or Packetized input mode.  In these modes the byte pairs or
packets that you receive from read or winput_read will include data_byte
and control_byte members.  The control_byte value indicates what type of
event occured.  The event may be a normal key press or release, or a
special key press or release.  In the case of packetized input mode, the
event may be a window event such as a window move.

You need to examine the flags in the control_byte to determine what the
data_byte means.  For a normal key event the data_byte will contain
ascii values.  For a special key event the data_byte will contain one of
the #define constants from /usr/include/window.h.  The code fragment
below shows how to check for the keys that you mentioned when
interpreting a packet from winput_read.  An example program which
handles all keys and other events appears in the "HP Windows/9000
Programmer's Manual."

if (event->control_byte & K_EVENT) {
	if (event->control_byte & K_SPECIAL) { /* a special key */
		switch (event->data_byte) {
			case K_RETURN:
				printf("RETURN\n", event->data_byte);
				break;
			case K_BACKSPACE:
				printf("BACKSPACE\n", event->data_byte);
				break;
			default:
				break;
		}
	} else { /* a normal key */
		printf("'%c'\n", event->data_byte);
	}
}

Mike Stroyan, stroyan@hpfcla.hp.com