[comp.os.vms] TPU: Key-name question

sommar@enea.se (Erland Sommarskog) (01/01/88)

I have a TPU procedure where I read a key and executes it
unless it's a printable character which I insert into the
buffer.

Unfortunately the following does not work:
Key := Read_key;
Function := Lookup_key(Key, PROGRAM);
IF Function <> 0 THEN
   Execute(Function)
ENDIF;

Thus, Lookup_key does not return Self_insert for an undefined printable
character. So I do:
ch := 32;
LOOP
   EXITIF (Key_name(ch) = Key) OR (ch > 127);
   ch := ch + 1;
ENDLOOP
And one more loop for 8-bit characters.

This isn't very efficient, and on an unloaded 750 you do notice the
delay. Thus, I'd like to find a more efficient way. Is there anyone
who has done this or has an idea? I'd assume one could deduce it more
directly from the key name. 
-- 
Erland Sommarskog       
ENEA Data, Stockholm    
sommar@enea.UUCP        
                   C, it's a 3rd class language, you can tell by the name.

sommar@enea.se (Erland Sommarskog) (01/03/88)

A while ago I asked whether someone knew a more efficient to
deduce what printable character, if any, the key name returned
by Read_key referred to than to loop.

There is. ASCII(Key) returns the character if it's printable.
For a non-printable character, it returns the null character.
Does this stand in the manual? Well, yes and no. For the ASCII
you find that it does only use the lowest byte of the integer it
gets. But the key-name coding is not there. (At least I haven't 
found it.) But in an article from The Leverage, feb 1987, Jeff 
Kennedy describes the coding. The last byte of the code is the
ASCII value for a printable character.

The most interesting with these codes is that you can very well use
key combinations like <ESC>-7 for commands. But, be careful:
TPU cannot distinguish between <ESC>-A, <ESC>-[A and <ESC>-OA.
It says, "escape, ah a keypad function!" And then it just cares
about the closing character of the sequence and ignores those
in between.
-- 
Erland Sommarskog       
ENEA Data, Stockholm    
sommar@enea.UUCP        
                   C, it's a 3rd class language, you can tell by the name.

mpk9172@ritcv.UUCP (Michael Kirby) (01/08/88)

From:	RITVAX::PAP9552      "Footprints in the sand..."  7-JAN-1988 13:19
Subj:	RE: tpu help

Someone posted a message questioning about tpu.  I forwarded the message
to someone a little more knowledgeable about tpu then myself, and this was
his reply:

=========

 
First what must be done is to set the current buffer to not translate the
control characters:

set(text, current_window, NO_TRANSLATE);

That should allow you to use all of the characters for the terminal.  But be
careful, it means that control characters will affect you terminal...

As to how the terminal operates with soft characters.  TPU does not reset
the terminal so that any soft characters go away, but will send a backward
question mark when a character cannot be printed.  This should solve most
of your problem...

                        Peter Portante
                        Rochester Institute of Technology
                        RITVAX@pap9552  - bitnet address