Accessing Terminals
Developing TACL Programs
2–28 107365 Tandem Computers Incorporated
Use the macro in Figure 2-13, lock, to lock a terminal until the user types the
password.
Figure 2-13. Locking a Terminal
?SECTION lock MACRO
#FRAME
#PUSH pw == password
#PUSH prompt == prompt variable
#PUSH rslt == result of #CHANGEUSER call
#PUSH userinfo == result of USERS call
#PUSH line
#SET rslt 0
== Define the clear screen escape sequence
[#DEF ascii STRUCT == Clear the screen
BEGIN
BYTE byt0 (0:1) VALUE 27 73; == decimal escape-I
CHAR clear (0:1) REDEFINES byt0;
END;
]
#OUTPUT [ascii:clear(0:1)]
== Disable break mode
#SET #BREAKMODE DISABLE
== Obtain information about the current user
USERS /OUTV userinfo/
#EXTRACTV userinfo line
#EXTRACTV userinfo line
[#SET prompt Password for [#USERNAME
[#CHARGET userinfo 22 FOR 8]]: ]
== Read a password (no echo) and attempt to log on:
[#LOOP |DO|
#INPUTV /NOECHO/ pw prompt
#SET rslt [#CHANGEUSER [#USERNAME [#CHARGET userinfo &
22 FOR 8]] [pw]]
[#IF NOT [rslt] |THEN| == An error occurred
#OUTPUT Invalid password!
]
|UNTIL| rslt
]
== After a successful logon, enable break mode and exit the
== macro:
#SET #BREAKMODE ENABLE
#UNFRAME