[comp.os.vms] A question of keys

herman%nrl.DECnet@NRL3.ARPA ("NRL::HERMAN") (06/30/87)

	I need to re-define the peripheral keys on the LK201 keyboard on the
VT240 terminal - which I use on a VAX under VMS.  I can re-define all the
keys on the numeric keypad, F17 through F20, HELP, DO, and the cluster of
6 keys above the arrow keys, using the DEF/KEY command.  That is, their 
re-definition is recognized by VMS and when I hit them the re-defined symbol 
appears on the screen.

	However, when I attempt to re-define the four arrow keys and F6
through F14, I cannot succeed.  VMS recognizes the new definitions, but
the new definitions do not appear on the screen when these keys are hit.
(Does VMS really recognize them? - I think I am ascertaining this by using
the SHOW KEY command).

	Can anyone explain this anomaly?


  herman%nrl.decnet@nrl.arpa
------

u3369429@murdu.OZ (Michael Bednarek) (07/01/87)

In article <8706301747.AA03624@ucbvax.Berkeley.EDU> "NRL::HERMAN" <herman%nrl.decnet@nrl.arpa> writes:
>
>	I need to re-define the peripheral keys on the LK201 keyboard on the
>VT240 terminal - which I use on a VAX under VMS.
>[...]
>	However, when I attempt to re-define the four arrow keys and F6
>through F14, I cannot succeed.  VMS recognizes the new definitions, but
>the new definitions do not appear on the screen when these keys are hit.
>[...]
>	Can anyone explain this anomaly?

Here is why:

[Extracted from SYS$HELP:HELPLIB.HLB :]

1 DEFINE
2 /KEY
3 Parameters

[]

  The LEFT and RIGHT arrow keys and the F6 through F14 VT200 keys  are
  reserved   for  command  line  editing.   You  must  issue  the  SET
  TERMINAL/NOLINE_EDITING command before defining these keys.  You can
  also  press  CTRL/V to enable keys F7 through F14.  Note that CTRL/V
  will not enable the F6 key.

So you can't have both. I use the DECUDK (User Defined Keys) function
which down-loads strings to the VT2xx which are then accessible by pressing
SHIFT/Fx. This function is mentioned on page 29 of the "VT220 Programmer
Pocket Guide".

A procedure to do that was once published in "Vax Professional", October 1986,
page 14, by Gerardo Hugo Fisanotti of Galmes y Casale S.R.L. - Argentina.

I wrote a slightly simpler one which follows below. It also accepts a file
name which contains the commands. I execute this procedure every Monday morning
from my LOGIN.COM and never switch the thing off until Friday.

Michael Bednarek		u3369429@{murdu.oz.au | ucsvc.dn.mu.oz.au}
Institute of Applied Economic   ...seismo.CSS.GOV!munnari!
  and Social Research (IAESR)	   {murdu.oz | ucsvc.dn.mu.oz}!u3369429
Melbourne University		mb@munnari.oz.au
Parkville 3052, Phone : +61 3 344 5744
AUSTRALIA

"POST NO BILLS."

....................... Cut between dotted lines and save ......................
$!..............................................................................
$! VAX/VMS archive file created by VMS_SHAR V-3.06 30-Jun-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by U3369429 (Michael Bednarek)
$!      on Wednesday 1-JUL-1987 16:47:02.78
$!
$! It contains the following 1 file:
$! FKEYS.COM
$!==============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$!See what VMS version we have here:
$ Version=F$GetSYI("VERSION")
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
		", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ EDIT/EDT/NoJournal/Output='File_is' VMS_SHAR_DUMMY.DUMMY
Set Quiet; Change; 32000(D+C L)
Exit
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="FKEYS.COM"
$ Check_Sum_is=525020866
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X$ Verify='F$Verify(F$TRNLNM("COMMAND_DEBUG"))
X$!
X$! Procedure: FKEYS
X$! User Defined Keys on a VT220
X$! (C) 1987, Michael Bednarek
X$! Usage: FKEYS [file_name]
X$!
X$ Status=44	! Abort
X$ Say="Write SYS$OUTPUT"
X$ TT$_VT200_Series=%X0000006E
X$ Say "Procedure FKEYS V-1.20 Setting VT220 Shift Function Keys"
X$ Say ""
X$ If F$Mode().nes."BATCH" then goto Start
X$ Say "It doesn't make sense to run FKEYS in BATCH"
X$ Goto Exit
X$!
X$Start:	
X$ If F$GetDVI("TT:","DevType").eq.TT$_VT200_Series then goto Is_VT200
X$ Say "FKEYS works only on VT200 terminals"
X$ Say "Make sure that your terminal is configured as a VT220"
X$ Inquire/NoPunctuation n "Continue? "
X$ If .not.n then goto Exit
X$ Set Terminal/Inquire
X$ Goto Start
X$!
X$Is_VT200:
X$	ESC[0,8]==27		! Escape
X$ FK_String="F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 HELP F16 DO F17 F18 F19 F20 "
X$ lFK_String=F$Length(FK_String)
X$ FK_Code  ="17 18 19 20 21  23  24  25  26  28  28   29  29 31  32  33  34"
X$	CR[0,8]=13		! Carriage Return
X$	XCR="0D"		! Carriage Return
X$	Prolog=ESC+"P1;1|"	! add more keys
X$	FK_Erase=ESC+"P0;1|"	! clear keys
X$	String=""
X$!
X$	If P1.nes."" then Define SYS$Command 'P1
X$	Open/Read/Share Commands SYS$Command
X$	Read/End_of_File=Next_Key -
X	    /Prompt="Should all keys be cleared first? [ny] " -
X	     Commands Which_Key
X$	If Which_Key then Prolog=FK_Erase
X$	Goto Next_Key
X$Is_Comment:
X$	Say Which_Key
X$Next_Key:
X$	Read/End_of_File=Do_it -
X	    /Prompt="Which Key do you want to define? " -
X	     Commands Which_Key
X$	If Which_Key.eqs."" then goto Do_it
X$! Edit and add a trailing blank to remove ambiguities
X$	Which_Key=F$Edit(Which_Key,"Collapse,UpCase")+" "
X$	If F$Extract(0,1,Which_Key).eqs."!" then goto Is_Comment ! Skip comments
X$	FK_Pos=F$Locate(Which_Key,FK_String)
X$	If FK_Pos.lt.lFK_String then goto Get_Def
X$	Say "can't define ",Which_Key
X$	Say "Please use one of these"
X$	Say FK_String
X$	Goto Next_Key
X$!
X$Get_Def:
X$	Read/End_of_File=Parse_Def -
X	/Prompt="Enter your definition, indicating <CR> as ^M:''CR'" -
X	 Commands Definition
X$	If P1.nes."" then Say Which_Key,": ",Definition
X$!
X$Parse_Def:	! find and substitute <CR>s
X$	L=F$Length(Definition)
X$nx_CR:	pCR=F$Locate("^M",Definition)
X$	If pCR.eq.L then goto Tr_Def
X$	Definition=F$Extract(0,pCr,Definition) -
X		  +CR+F$Extract(pCR+2,L-pCR-2,Definition)
X$	L=L-1		! Definition is now one shorter
X$	Goto nx_CR	! search next <CR>
X$!
X$Tr_Def:	! Translate ASCII to ASCII-fied hex (e.g.: "DIR"->"444952")
X$	n=0	! bit position within "Definition"
X$	p=0	! Character position within "Definition"
X$	Y=""	! the translated string
X$n:	p=p+1	! increment character pointer
X$	X=0	! zeroise unsigned integer
X$	X[0,8]=F$CVUI(n,8,Definition)	! extract 8 bits
X$	Y=Y+F$String(F$FAO("!XB",X))	! convert them to hex characters
X$	n=n+8				! increment bit pointer
X$	If p.lt.L then goto n		! finished?
X$	Definition=Y			! copy the hex string
X$!
X$	String=String+F$Extract(FK_Pos,2,FK_Code)+"/"+Definition+";"
X$!
X$	Goto Next_Key
X$!
X$Do_it:
X$	Close Commands
X$	If P1.nes."" then DeAssign SYS$Command
X$	Say Prolog,String,ESC,"\"
X$	Status=1
X$	Verify=F$Verify(Verify)
X$Exit:	Exit Status
$ GoSub Convert_File
$ Exit