Developing TACL Programs
Accessing Terminals
2–28
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
#PUSH prompt
#PUSH rslt
#PUSH userinfo
#PUSH line
#SET rslt 0
== Define the clear screen escape sequence
[#DEF ascii STRUCT
BEGIN
BYTE byt0 (0:1) VALUE 27 73;
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
107365 Tandem Computers Incorporated
== password
== prompt variable
== result of #CHANGEUSER call
== result of USERS call
== Clear the screen
== decimal escape-I