 |
» |
|
 |
|
 |

Copyright (c) Digital Equipment Corporation 1991, 1992. All rights reserved
LAYERED PRODUCT: VAX PLI OP/SYS: VMS
SOURCE: Digital Customer Support Center
OVERVIEW:
This program demonstrates how to set up a short form terminator
to trap the arrow keys as terminators.
*** CAUTION ***
This sample program has been tested using VAX PLI Version 3.4 on
VMS Version 5.4-2. However, we cannot guarantee its effectiveness
because of the possibility of error in transmitting or implementing
it. It is meant to be used as a template for writing your own
program and it may require modification for use on your system.
In this program, the arrow keys and function keys are used as terminators.
When an arrow key is pressed at the terminal, an escape sequence is
generated. The Terminator Mask argument has been set to the decimal value
27, which is the ASCII code for "escape". This will terminate the read
when any escape sequence is detected. After the read is terminated, the
Terminator Code argument returns a value that indicates which arrow or
function key has been pressed (UP, DOWN, LEFT, or RIGHT). The short form
of the terminator mask is used in this example. The PLI function UNSPEC
was used to set BIT 27 for escape, as well as the appropriate bits
for CR and TAB.
Because the arrow keys will be used as terminators, line editing must be
disabled. In addition, the Modifier parameter is set to TRM$M_TM_NOEDIT.
By using this modifier, the routine will read the arrow keys without
activating line editing or command line recall.
After the SMG$READ_STRING is terminated, the program displays the SMG
terminator code and an indication as to which arrow key, CR or TAB
was entered. The Terminator Codes are listed in the "VMS RTL
Screen Management (SMG) Manual", April 1988 .
NOTE: The arrow keys and all keypad keys are predefined terminators.
They are interpreted by the terminal driver, not SMG. They cannot
be turned off using SMG. A workaround using SMG is to read the
"terminator-code" and do the read again, i.e. "if terminator-code > 255"
then re-call SMG$READ_STRING. All this does is force your program to
ignore the terminator.
SMG only recognizes single-character terminators from the character set
0-255. The arrow and keypad keys are multiple character escape sequences,
i.e. ^[[A. SMG only reads the first character. You can turn off the arrow
and keypad keys using the $QIO system service, but not through SMG.
PROGRAM:
SMGTEST:proc options(main);
%include $stsdef;
%include $smgdef;
%include $trmdef;
%include smg$create_virtual_keyboard;
%include smg$read_string;
%include smg$create_pasteboard;
%include smg$create_virtual_display;
%include smg$paste_virtual_display;
dcl termset fixed bin(31);
dcl modifiers bit(32) aligned;
dcl outstr char(5);
dcl prompt char(26) init('Enter up to 5 characters: ');
dcl keyboard_id fixed bin(31);
dcl rows fixed binary(31) init(20);
dcl columns fixed binary(31) init(65);
dcl paste_rows fixed binary(31) init(3);
dcl paste_columns fixed binary(31) init(15);
dcl new_pid fixed binary(31);
dcl I fixed bin(31) init(0);
dcl display_id fixed bin(31);
dcl maxlen fixed bin(31) init(5);
dcl reslen fixed bin(15);
dcl wordterm fixed bin(15);
modifiers = trm$m_tm_noedit;
/* create the virtual keyboard*/
sts$value = SMG$CREATE_VIRTUAL_KEYBOARD(keyboard_id,,,);
if ^sts$success
then signal vaxcondition(sts$value);
/* create the paste board */
sts$value = SMG$CREATE_PASTEBOARD(new_pid,,,,);
if ^sts$success
then signal vaxcondition(sts$value);
/* create the virtual display*/
sts$value = SMG$CREATE_VIRTUAL_DISPLAY(rows,columns,display_id,,,);
if ^sts$success
then signal vaxcondition(sts$value);
/* paste the virtual display*/
sts$value = SMG$PASTE_VIRTUAL_DISPLAY
(display_id,new_pid,paste_rows,paste_columns,);
if ^sts$success
then signal vaxcondition(sts$value);
/*this will cause CR, TAB, or arrows to be interpreted as terminators*/
/*01234567890123456789012345678901*/
unspec(termset) = '00000000010001000000000000010000'b;
sts$value = SMG$read_string
(keyboard_id,outstr,prompt,
maxlen,modifiers,,descriptor(termset),
reslen,
wordterm,
display_id,,,);
if ^sts$success
then signal vaxcondition(sts$value);
if wordterm = smg$k_trm_ctrli
then put skip list ('tab terminated the read');
if wordterm = smg$k_trm_cr
then put skip list ('cr terminated the read');
if wordterm = smg$k_trm_up
then put skip list ('up arrow terminated the read', wordterm);
if wordterm = smg$k_trm_down
then put skip list ('down arrow terminated the read', wordterm);
if wordterm = smg$k_trm_left
then put skip list ('left arrow terminated the read', wordterm);
if wordterm = smg$k_trm_right
then put skip list ('right arrow terminated the read', wordterm);
end smgtest;
|
buy online or call 1.800.AT.COMPAQ
|
|