From:	HENRY::IN%"JOHN%ukanvax.bitnet%wiscvm.wisc.edu%kl.sri.COM%relay.cs.net@RCA.COM" 25-APR-1987 16:51
To:	INFO-VAX@kl.sri.com
Subj:	TERMSET.COM (RE: typeahead)

Keywords:  Terminal, SET TERMINAL/INQUIRE
Warning:  Long message -- 143 lines (includes program) Sorry! :-)

Several people have asked how I get the terminal type in english after I do
a SET TERMINAL/INQUIRE.

Well, it's called BRUTE FORCE.

I have included my TERMSET.COM in this message for your enjoyment.

TERMSET first tries to do a SET TERMINAL/INQUIRE.  If you are on a DECish
terminal, this will work and a message will be diplayed telling you the
terminal type has been set.  If the SET TERMINAL/INQUIRE does not work,
TERMSET will ask you to enter the terminal type.  At this prompt you can
either:  1)  Type "?" to see a list of terminals TERMSET knows about
or       2)  Type just RETURN to not set the terminal type
or       3)  Type some letters that are unique to the name of one of the
             terminals TERMSET knows about.  (like 3A for "ADDS 3A+")
TERMSET not only sets the VMS terminal type, but also sets up EMACS$TERMINAL
for EMACS.

                                          John Thywissen

My "TERMSET.COM" follows:       (forgive the semi-legalistic mumbo-jumbo)
(more ramblings at end)
-----------------------Cut here for TERMSET.COM------------------------------
$ !
$ !  T E R M S E T   v1.1   Set terminal type
$ !
$ !  COPYRIGHT (C) 1987, John Adam Thywissen, Few Rights Reserved
$ !
$ GOTO START
$ !DATES:  Started:    02 Nov 86
$ !
$ !DESCRIPTION:  This command procedure sets the terminal type.  It sets both
$ !    the  SET TERMINAL DEVICE_TYPE and the EMACS "EMACS$TERMINAL" logical
$ !    name.
$ !
$ !METHOD OF SOLUTION:  It tries to to a SET TERMINAL/INQUIRE, but if that does
$ !    not work (meaning the terminal is not a DEC), it asks the user for the
$ !    terminal type.
$ !
$ !SIDE-EFFECT:  MESSAGE is set to the full message (F-S-I, text).  Needs to
$ !    be fixed someday.
$ !
$ !PROGRAMMING LANGUAGE:  VAX/VMS DCL
$ !OPERATING SYSTEM:  VAX/VMS  v4.4
$ !
$ !AUTHOR:  John A. Thywissen
$ !         Current UserID:  KUHUB::JOHN
$ !                          JOHN@UKANVAX.BITNET
$ !
$ !AVAILABILITY:  This program may be freely distributed and modified
$ !    under certain conditions:
$ !    1.  Proper credit must be given and all modifiers must insert
$ !    their name in the header.
$ !    2.  Modifications must be commented and a copy of the modified
$ !    code must be sent to the author.
$ !    3.  This program may not be used for any coursework.  Copying
$ !    this program, in part or in whole, for such purposes is plagiarism,
$ !    a violation of university regulations.
$ !
$ START:
$ TERMTYPES = "UNKNOWN/VT05/VK100/VT173/4/5/6/7/8/9/10/11/12/13/14/15/FT1/FT2"+-
"/FT3/FT4/FT5/FT6/FT7/FT8/24/25/26/27/28/29/30/31/LA36/LA120/LA34/LA38"+-
"/LA12/LA24orLA100/LQP02/LA84/LA210/LN03/LN01K/LA80/44/45/46/47/48/49/50/51"+-
"/52/53/54/55/56/57/58/59/60/61/62/63/VT52/VT55/66/67/68/69/7/71/72/73/74/75"+-
"/76/77/78/79/80/81/82/83/84/85/86/87/88/89/9/91/92/93/94/95/VT100/VT101"+-
"/VT102/VT105/VT125/VT131/VT132/VT80/104/105/106/107/108/109/VT200_Series"+-
"/PRO_Series/112/113"
$ SET NOON
$ SET MESSAGE/NOFACILITY/NOSEVERITY/NOIDENTIFICATION/NOTEXT
$ SET TERMINAL/INQUIRE
$ SAVSEV = $SEVERITY
$ SET ON
$ SET MESSAGE/FACILITY/SEVERITY/IDENTIFICATION/TEXT
$ IF SAVSEV THEN GOTO DECTERM
$ SET ON
$ SET MESSAGE/FACILITY/SEVERITY/IDENTIFICATION/TEXT
$ TERMLIST="MICROBEE /ADDS 3A+ /VIP 7200 /H19      /DEC VT52 /"
$ READIN:
$ INQUIRE TERMTYPE "Enter terminal type (? for list)"
$ TERMTYPE = F$EDIT(TERMTYPE, "TRIM, UPCASE")
$ IF TERMTYPE .EQS. "" THEN GOTO END
$ IF TERMTYPE .NES. "?" THEN GOTO BRCL
$ WRITE SYS$OUTPUT TERMLIST
$ GOTO READIN
$ BRCL:
$ N = F$LOCATE(TERMTYPE,TERMLIST)/10
$ GOTO T'N'
$ T0:
$ SET TERMINAL/DEVICE_TYPE=FT1
$ DEFINE EMACS$TERMINAL "MICROB"
$ GOTO END
$ T1:
$ SET TERMINAL/DEVICE_TYPE=FT2
$ DEFINE EMACS$TERMINAL "ADDS3A"
$ GOTO END
$ T2:
$ SET TERMINAL/DEVICE_TYPE=FT3
$ DEFINE EMACS$TERMINAL "VIP7200"
$ GOTO END
$ T3:
$ SET TERMINAL/DEVICE_TYPE=UNKNOWN
$ DEFINE EMACS$TERMINAL "H19"
$ GOTO END
$ T4:
$ SET TERMINAL/DEVICE_TYPE=VT52
$ DEFINE EMACS$TERMINAL "VT52"
$ GOTO END
$ T5:
$ WRITE SYS$OUTPUT "Unknown Terminal Type: ''TERMTYPE'"
$ GOTO READIN
$ END:
$ WRITE SYS$OUTPUT -
"Terminal type "+F$ELEMENT(F$GETDVI(F$GETJPI("","TERMINAL"),"DEVTYPE"),"/", -
TERMTYPES) + "  (EMACS " + F$TRNLNM("EMACS$TERMINAL") + ")"
$ EXIT
$ DECTERM:
$ DT = F$GETDVI(F$GETJPI("","TERMINAL"),"DEVTYPE")
$ IF DT .EQ. 33 THEN DEFINE EMACS$TERMINAL "LA120"
$ IF DT .EQ. 2 THEN DEFINE EMACS$TERMINAL "GIGI"
$ IF DT .EQ. 64 THEN DEFINE EMACS$TERMINAL "VT52"
$ IF DT .EQ. 96 .OR. DT .EQ. 97 .OR. DT .EQ. 98 .OR. DT .EQ. 99 THEN DEFINE -
 EMACS$TERMINAL "VT100"
$ IF DT .EQ. 100 THEN DEFINE EMACS$TERMINAL "VT125"
$ IF DT .EQ. 102 THEN DEFINE EMACS$TERMINAL "VT132"
$ IF DT .EQ. 110 .OR. DT .EQ. 111 THEN DEFINE EMACS$TERMINAL "VT2XX"
$ GOTO END
-----------------------End of TERMSET.COM------------------------------

TERMSET is set up for KU's system.  We have FT1, FT2, and FT3 set up for
MICROBEEs, ADDS 3A+s, and HONEYWELL VIP 7200s respectively.  Since it is
unlikely that anyone else has as cheap terminals as we do, you will need to
change this for your non-DEC terminals.  To do so, modify the TERMLIST=
line to have your terminal names seperated by slashes.  The spacing between
the slashed MUST NOT CHANGE.  9 characters between slashes exactly.  Then
the code after the "T0" to "Tn" labels should be changed to do the proper
things for each of your terminals.  Note that the T(n+1) lable should have the
error handling stuff.

                             Have fun,
                               John
