This function returns the next make code in the keypad buffer in ASCII form along with the optional File a translation of this character (see Chapter 8. "RAM Files" for details concerning File a).
The USHORT value returned by this function contains the base ASCII character in the low order byte and the File a translation character in the high order byte. The base ASCII character returned in the low byte is always the same, no matter how the keypad has been re-mapped using file a. This allows the CFR to work with physical keys. The upper byte allows the logical mapping of these keys to application or national-language specific printable characters. If File a is not loaded, the ASCII character is duplicated in the high order byte of the returned value. The special keypad keys Enter, Fill, Space and Clear cannot be redefined in File a and are returned with the high order byte set to 0. The ASCII codes for these four special keys are defined in the CFRAPI26.H include file.
On the 7526 Model 200, when the Shift key is used in conjunction with the base ASCII characters A-Z and the numbers 1-9, the lower case letters a-z and the symbols +, -, #, $, %, /, &, *, and . are returned respectively. On the 7526 Model 100, the Shift key used in conjunction with the function keys F1-F4 will return the letters a-d respectively. The Alt key used in conjunction with F1-F4 will return the letters E-H respectively.
C Format
#include "cfrapi26.h" // Defined values
USHORT KbdReadAscii(code)
USHORT *code // Returned code
Returns: E_OK // If no error occurred
E_NO_DATA // If no valid code in buffer
Masm Format
Input: ah = 0
Call: INT 41h
Returns: bx = code
ax = 0 If no error occurred.
5 If no valid code in buffer
Comments:
The Shift key and the Alt key (Model 100 only) are used by the 7526 in two key sequences but are not directly returned as key presses. For example, pressing the Shift key followed by the A key will return only 1 character (lower case a).
Only keypad make codes result in a returned character, break codes are not returned.
If the special keypad functions Clear, Keylock, Beeper Adjustment or Contrast Adjustment are turned on via the KbdSetMode Function, the keypad sequences related to these functions are processed by the 7526 microcode and no character is returned. If these special functions are turned off, the corresponding ASCII character is returned.
Note:
Refer to CFRAPI26.H for key code defines..
Example
#include "cfrapi26.h" #include// Wait for a key to be pressed and display // the results
int far main (int funct,char far *params) { USHORT CharCount; UCHAR DisplayString [41];
// Use a union for easy access to the upper and lower bytes of the key value.
union { USHORT Code: // Full USHORT key value struct { UCHAR Base // Base character UCHAR Mapped; // File a mapped character } Chr; } Key;
VioClear (); // Clear the display
// Wait in a loop for a key to be pressed and // call IdleManager to allow other tasks to run
while (KbdReadAscii (&Key.Code) != E_OK) IdleManger (5); // Wait 25 milliseconds
if ((Key.Code == ENTER_KEY) &lor.&lor. (Key.Code == CLEAR_KEY) &lor.&lor. (Key.Code == FILL_KEY) { // The key pressed is one of the special // keys Enter, Fill or Clear which are processed // as full USHORT (2 byte) values
VioWrtCharStr ("Special Key", 11, 0, 0, &CharCount, NO_CURSOR_MOVE); } else { // The key is a displayable character // // Show the base character (representing the physical key) // and the character as mapped by File a
strcpy (DisplayString, "Base Character = x, Mapped Character = y"); DisplayString [17] = Key.Chr.Base; DisplayString [39] = Key.Chr.Mapped; VioWrtCharStr (DisplayString, 40, 0, 0, &CharCount, NO_CURSOR_MOVE); }
IdleManager (600); // Delay about 3 seconds to hold return (CONTINUE); // the message on the display }
This function determines the mode in which the keypad functions Clear, Contrast Adjust, Beeper Adjust and Keylock are handled, while the CFR is executing. The CFR determines if these keys are handled automatically by the 7526 microcode or received by the CFR from keypad entries.
C Format
#include "cfrapi26.h" // Defined values
USHORT KbdSetMode(keylock_mode, clear_mode, adjustment_mode)
UCHAR keylock_mode // keylock mode
UCHAR clear_mode // clear mode
UCHAR adjustment_mode // adjustment mode
Returns: E_OK // If no error occurred
E_PARAM // If parameter values are incorrect
Masm Format
Input: ah = 1
al = keylock_mode
bh = clear_mode
bl = adjustment_mode
Call: INT 41h
Returns: ax = 0 If no errors occurred
= 1 If parameter values are incorrect
Comments:
If Clear Mode is set to ON, pressing the Clear Key After termination of the CFR, the CFR receives a function code 2 restart call. When the CFR returns from the restart call, the terminal goes to idle mode.
If Keylock Mode is set to ON, pressing the Keylock Key sequence while inside a CFR results in terminating the CFR. After termination of the CFR, keylock mode will be started to allow changing of setup parameters or execution of diagnostics. When the user exits keylock mode the CFR receives a function code 2 restart call. When the CFR returns from the restart call, the terminal goes to idle mode.
Example
int far main (int funct,char far *params)