Google
 

Trailing-Edge - PDP-10 Archives - BB-W661B-BM_1984 - tools/x29pad.mac
There is 1 other file named x29pad.mac in the archive. Click here to see a list.
	TITLE	X29PAD
	SUBTTL	BY -ABDUL- AND THE DANCING BEAR


;
;		      COPYRIGHT (C) 1983, 1984  BY
;		DIGITAL EQUIPMENT CORPORATION, MAYNARD MASS.
;
; THIS SOFTWARE  IS FURNISHED UNDER A LICENSE  AND MAY BE USED  AND COPIED
; ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE INCLUSION
; OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR ANY OTHER COPIES THERE-
; OF  MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON.
; NO TITLE TO OR OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERRED.
;
; THE INFORMATION CONTAINED IN THIS SOFTWARE  IS SUBJECT TO CHANGE WITHOUT
; NOTICE AND SHOULD  NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
; CORPORATION.
;
; DIGITAL  ASSUMES NO RESPONSIBILITY  FOR THE  USE OR RELIABILITY  OF ITS
; SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
;
;

	SEARCH	MACSYM,MONSYM,X25SYM
	SALL
	.DIRECT	FLBLST

; VERSIONS

VWHO==0					; LAST EDITED BY...
VMAJOR==2				; MAJOR VERSION
VMINOR==0				; MINOR VERSION
VEDIT==303				; EDIT VERSION
	SUBTTL	SYMBOLS

S==0
T1==1
T2==2
T3==3
T4==4
P1==5
P2==6
P3==7
P4==10
P==17


; BIT DEFINITIONS FOR PAD PARAMETER #3

P03%AL==1				; FORWARD DATA ON ALPHANUMERICS
P03%CR==2				; FORWARD DATA ON CARRIAGE-RETURN
P03%ES==4				; FORWARD DATA ON ESCAPE
P03%ED==10				; FORWARD DATA ON EDITING CHARACTERS
P03%TR==20				; FORWARD DATA ON TERMINATORS
P03%FM==40				; FORWARD DATA ON FORMS EFFECTORS
P03%CT==100				; FORWARD DATA ON CONTROL CHARACTERS
P03%OT==200				; FORWARD DATA ON OTHER CHARACTERS

; BIT DEFINITIONS FOR PAD PARAMETER #7

P07%IT==1				; SEND INTERRUPT PACKET ON BREAK
P07%RE==2				; SEND RESET PACKET ON BREAK
P07%ID==4				; SEND INDICATION OF BREAK
P07%ES==10				; ESCAPE TO COMMAND MODE ON BREAK
P07%DO==20				; DISCARD OUTPUT ON BREAK


; BIT DEFINITIONS FOR PAD PARAMETER #8

P08%NO==0				; NORMAL DATA DELIVERY
P08%DO==1				; DISCARD OUTPUT


; BIT DEFINITIONS FOR PAD PARAMETER #13

P13%TD==1				; INSERT LF AFTER CR SENT TO DTE
P13%FD==2				; INSERT LF AFTER CR SENT FROM DTE
P13%EC==4				; INSERT LF AFTER ECHOED CR TO DTE


; INTERRUPT CHANNELS

CH.NET==0				; NETWORK IS ON CHANNEL 0
CH%NET==1B0				; BIT POSITION IN INTERRUPT WORD
LV.NET==2				; LEVEL 2 INTERRUPT

CH.TMR==1				; TIMER IS ON CHANNEL 1
CH%TMR==1B1				; BIT POSITION IN INTERRUPT WORD
LV.TMR==2				; LEVEL 2 INTERRUPT

CH.TTY==2				; TTY IS ON CHANNEL 2
CH%TTY==1B2				; BIT POSITION IN INTERRUPT WORD
LV.TTY==2				; LEVEL 2 INTERRUPT
; ASCIZ COPYRIGHT NOTICE AND MISC. TEXT

ASCIZ\
		      COPYRIGHT (C) 1983, 1984  BY
		DIGITAL EQUIPMENT CORPORATION, MAYNARD MASS.

 THIS SOFTWARE  IS FURNISHED UNDER A LICENSE  AND MAY BE USED  AND COPIED
 ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE INCLUSION
 OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR ANY OTHER COPIES THERE-
 OF  MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON.
 NO TITLE TO OR OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERRED.

 THE INFORMATION CONTAINED IN THIS SOFTWARE  IS SUBJECT TO CHANGE WITHOUT
 NOTICE AND SHOULD  NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
 CORPORATION.

 DIGITAL  ASSUMES NO RESPONSIBILITY  FOR THE  USE OR RELIABILITY  OF ITS
 SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.

\

; ERROR MESSAGES AND EXPANSIONS


NETETB:	-1,,[ASCIZ\%Reset seen by Gateway\]
	-1,,[ASCIZ\ NO EXTRA INFO AVAILABLE\]

	-1,,[ASCIZ\%PSI Gateway software are not compatible, version skew\]
	-1,,[ASCIZ\%The version numbers of the TOPS20 PSI Gateway Access Software
 and the TOPS20 PSI Gateway Software are not compatible. This
 could be caused by the use of an old version of X25GAM.REL
 when this program was loaded.\]

	-1,,[ASCIZ\%Buffer too short\]
	-1,,[ASCIZ\ NO EXTRA INFO AVAILABLE\]

	-1,,[ASCIZ\%Buffer too long\]
	-1,,[ASCIZ\ NO EXTRA INFO AVAILABLE\]

	-1,,[ASCIZ\%Source DTE Subaddress too long\]
	-1,,[ASCIZ\%The destination DTE Subaddress you have specified is too
 long. Please check to insure that the Subaddress you have
 specified is correct.\]

	-1,,[ASCIZ\%Destination DTE address to long\]
	-1,,[ASCIZ\%The destination DTE Address you have specified is too long.
 Please check to insure that the Address you have specified is
 correct.\]

	-1,,[ASCIZ\%No interrupt confirmation required\]
	-1,,[ASCIZ\ NO EXTRA INFO AVAILABLE\]

	-1,,[ASCIZ\%Awaiting interrupt confirmation\]
 	-1,,[ASCIZ\%X29PAD has attempted to send an interrupt message to the REMOTE-HOST
before a previously sent interrupt message has been acknowledged. This
 can happen when you type the BREAK-CHARACTER multiple times when the
 ACTION-ON-BREAK PAD Parameter is set to cause an interrupt message to
 be sent. This is not a fatal error and you should be able to continue
 the session.\]

	-1,,[ASCIZ\%No DTE address specified, or no destination\]
	-1,,[ASCIZ\%You have not specified a destination DTE address to which
 a call is to be made.\]

	-1,,[ASCIZ\%No Password or Password not valid\]
	-1,,[ASCIZ\%You have not specified a PASSWORD or you have specified an
 incorrect PASSWORD for gaining access to the network via
 the Gateway node. Please check to insure that you have given
 the correct PASSWORD.\]

	-1,,[ASCIZ\%Data-field truncation, field was to long\]
	-1,,[ASCIZ\%The call data-field was truncated because it
 was longer than the limit set by the PPSN.\]

	-1,,[ASCIZ\%Facilities data-field truncated\]
	-1,,[ASCIZ\%The facilities data-field was truncated because it
 was longer than the limit set by the PPSN.\]

	-1,,[ASCIZ\%Unknown Network name specified\]
	-1,,[ASCIZ\%The network name you have specified has not been defined
 in the DECnet-20 Network Management database. Please check
 to insure that you have supplied the correct network name.\]

	-1,,[ASCIZ\%No interrupt to read\]
	-1,,[ASCIZ\ NO EXTRA INFO AVAILABLE\]

	-1,,[ASCIZ\%No data to read\]
	-1,,[ASCIZ\ NO EXTRA INFO AVAILABLE\]

	-1,,[ASCIZ\%X25 Port failed, procedure error\]
	-1,,[ASCIZ\%The TOPS20 PSI Gateway Software encountered a procedure
 error while trying to execute a Gateway request. This
 could be caused by the Gateway node being inaccessable.\]

	-1,,[ASCIZ\%Insufficient resources\]
	-1,,[ASCIZ\%X29PAD could not obtain a circuit from the Network
 Management Software. This could be caused by insufficient
 DECnet Resources in the system the lack of a response by
 the Network Management Software in a reasonable amount of
 time. The lack of a timely response by the Network Management
 Software could be caused by another user requesting a service
 from the Network Management Software. You should try again.\]

	-1,,[ASCIZ\%Insufficient gateway resources\]
	-1,,[ASCIZ\ The PSI Gateway did not have sufficient resources to allocate a new
 switched circuit. This could happen when all the circuits are being
 used by others or by a problem in the Gateway. You should try again.\]

PORTST:
	-1,,[ASCIZ\UNDEFINED\]
	-1,,[ASCIZ\OPEN\]
	-1,,[ASCIZ\CALLING\]
	-1,,[ASCIZ\LISTENING\]
	-1,,[ASCIZ\CALLED\]
	-1,,[ASCIZ\RUNNING\]
	-1,,[ASCIZ\SYNC\]
	-1,,[ASCIZ\UNSYNC\]
	-1,,[ASCIZ\CLEARING\]
	-1,,[ASCIZ\CLEARED\]
	-1,,[ASCIZ\ERROR\]
	-1,,[ASCIZ\NO COMMUNICATION\]


; X.25 CLEARING CAUSE FIELD DIAGNOSTIC DATA DEFINITION

CCAUSE:
	^D1,,[ASCIZ\?Call not completed - Remote DTE number is busy\]
	^D3,,[ASCIZ\?Call not completed - Invalid facility request\]
	^D5,,[ASCIZ\?Call not completed - Network congestion\]
	^D9,,[ASCIZ\?Call not completed - Remote DTE number is out of order\]
	^D11,,[ASCIZ\?Call not completed - Access barred\]
	^D13,,[ASCIZ\?Call not completed - Not obtainable\]
	^D17,,[ASCIZ\?Call not completed - Remote procedure error\]
	^D19,,[ASCIZ\?Call not completed - Local procedure error\]
	^D21,,[ASCIZ\?Call not completed - RPOA out of order\]
	^D25,,[ASCIZ\?Call not completed - Reverse charging acceptance not subscribed to\]
	^D33,,[ASCIZ\?Call not completed - Incompatible destination\]
	^D41,,[ASCIZ\?Call not completed - Fast select acceptance not subscribed to\]
	0,,0			; END OF TABLE



; ASSEMBLY SWITCHES

IFNDEF	L.CNT%,L.CNT%==200		; COUNT OF CHARS BEFORE UPDATING LOG
IFNDEF	PDLEN,PDLEN==1000		; LENGTH OF PUSHDOWN STACK
IFNDEF	CMDBSZ,CMDBSZ==^D200		; LENGTH OF COMMAND TEXT BUFFER
IFNDEF	ATMBSZ,ATMBSZ==^D100		; LENGTH OF ATOM BUFFER
IFNDEF	DTENUM,DTENUM==200		; MAX NUMBER OF LOGICAL HOST NAMES
IFNDEF	PKTSIZ,PKTSIZ==^D128		; X.25  NETWORK PACKET SIZE
IFNDEF	TMPLEN,TMPLEN==1000		; LENGTH OF NETWORK ISR STACK
IFNDEF	TTPLEN,TTPLEN==1000		; LENGTH OF TERMINAL ISR STACK
IFNDEF	NTPLEN,NTPLEN==1000		; LENGTH OF NETWORK ISR STACK
	SUBTTL	USEFUL MACRO DEFINITIONS

; PARSE A STRING OF NOISE WORDS

DEFINE NOISE (STRING) <
	MOVEI	T2,[FLDDB. .CMNOI,,<-1,,[ASCIZ\STRING\]>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR	>		; DEFINITION OF NOISE


; OBTAIN CONFIRMATION, AN END OF LINE INDICATION. TIE OFF COMMAND LINE


DEFINE	CONFIRM <
	MOVEI	T2,[FLDDB. .CMCFM]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	SKIPE	LOGJFN
	CALL	LOG
	SKIPE	.TAKEF
	CALL	.TECC	>		; DEFINITION OF CONFIRM


; BUILD THE COMMAND TABLE

DEFINE	TBL (NAME,FLAGS,DISP) <
 IFNB <DISP>,<..DISP==DISP>		; ; IF A DISPATCH IS GIVEN, USE IT
 IFB  <DISP>,<..DISP==.'NAME>		; ; IF NONE, DEFAULT TO .NAME
 IFB  <FLAGS>,<[ASCIZ\NAME\],,..DISP>	; ; IF NO FLAGS, ASSEMBLE JUST THE NAME
 IFNB <FLAGS>,<[FLAGS!CM%FW		; ; IF FLAGS, USE THEM AND SET CM%FW
		ASCIZ\NAME\],,..DISP>	; ;
	PURGE	..DISP >		;  TBL MACRO
	SUBTTL	DATA STORAGE AREA

PDLIST:	BLOCK	PDLEN			; PUSHDOWN LIST
SAVPDL:	0				; SAVE PUSHDOWN POINTER IN CASE OF

NETPDL:	BLOCK	NTPLEN			; NETWORK ISR STACK
TMRPDL:	BLOCK	TMPLEN			; TIMER ISR STACK
TTYPDL:	BLOCK	TTPLEN			; TERMINAL ISR STACK

NETACS:	BLOCK	20			; NETWORK ISR AC STORAGE
TMRACS:	BLOCK	20			; TIMER ISR AC STORAGE
TTYACS:	BLOCK	20			; TERMINAL ISR AC STORAGE
					; REPARSE

CORBEG==.				; THIS STORAGE IS ZEROED AT START

; STORAGE USED BY COMND

CMDBUF:	BLOCK	CMDBSZ			; COMMAND BUFFER
ATMBUF:	BLOCK	ATMBSZ			; ATOM BUFFER
GTJBLK:	BLOCK	.GJATR+1		; GTJFN BLOCK

; STORAGE USED BY THE PUSH COMMAND

EXCJFN:	0				; JFN FOR PUSH
FKHAN:	0				; FORK HANDLE FOR PUSH

; TERMINAL MODE STORAGE

OMODE:	BLOCK	1			; ORIGINAL RFMOD WORD
OCCOC:	BLOCK	2			; ORIGINAL CCOC WORDS
OTIW:	BLOCK	1			; ORIGINAL TERMINAL INTERRUPT WORD

NMODE:	BLOCK	1			; CURRENT RFMOD WORD, STORED ON ESCAPE

NCOUNT:	BLOCK	1			; NUMBER OF MSGS TO READ BETWEEN CHECKS
					; FOR TTY ACTIVITY IN THE NETWORK 
					; ROUTINES

; NETWORK STORAGE

ACDBLK:	BLOCK	^D16/4+1		; STORAGE FOR CALL ACCEPT DATA

ACDCNT:	BLOCK	1			; COUNT OF BYTES IN ACCEPT DATA

CLDBLK:	BLOCK	4			; STORAGE FOR USER CLEAR DATA 

CUSGRP:	BLOCK	4			; 

CUGBLK:	BLOCK	4			; (16 CHARACTERS MAX)

CUGDEF:	BLOCK	4			; DEFAULT CLOSED-USER-GROUP

CUGFLG:	BLOCK	1			; CLOSED-USER-GROUP FLAG

; THE FOLLOWING THREE BLOCKS MUST REMAIN TOGETHER AND IN ORDER

DTENAM:	BLOCK	4			; DTE NAME BLOCK

DTEADR:	BLOCK	4			; DTE ADDRESS STRING BLOCK 

DTESUB:	BLOCK	4			; DTE SUBADDRESS STRING BLOCK 

DTESTR:	BLOCK	10			; BUFFER FOR FULL DTE ADDR/SUBADDR

ERRFLG:	BLOCK	1			; FLAG FOR LONG OR SHORT ERROR MSG

ESCFLG:	BLOCK	1			; INDICATION OF ESCAPE FLAG

FACBLK:	BLOCK	^D64/4+1		; FACILITIES-DATA BLOCK FOR X%ISC 

FACCNT:	BLOCK	1			; NUMBER OF BYTES IN FACILITIES DATA

FACFLG:	BLOCK	1			; FACILITIES-DATA SUBCMD FLAG

FACDEF:	BLOCK	^D64/4+1		; DEFAULT FACILITIES-DATA BLK

FACDCT:	BLOCK	1			; NUMBER OF BYTES IN DEFAULT FACILITIES
					; DATA BYTE STRING

LASTNE:	BLOCK	1			; LAST NETWORK ERROR

NETNAM:	BLOCK	4			; STORAGE FOR NETWORK NAME
					; (16 CHARACTERS MAX)

NETPSW:	BLOCK	4			; STORAGE FOR ACCESS PASSWORD
					; (16 CHARACTERS MAX)

NTOBUF:	BLOCK	<PKTSIZ/4>+1		; BUFFER FOR OUTGOING NETWORK MESSAGES

PRTBLK:	BLOCK	<PKTSIZ/4>+^D140	; PORT WORK SPACE

PORTNO:	BLOCK	1			; GATEWAY PORT NUMBER IN USE

RADFLG:	BLOCK	1			; NOTE THAT A CALL TO X%RAD WAS DONE

RCVSIZ==^D200

RCVBUF:	BLOCK	<RCVSIZ/4>+1		; RECEIVE BUFFER FOR X%RDM DATA

TTIBUF:	BLOCK	<PKTSIZ/4>+1		; TERMINAL INPUT BUFFER

TTICNT:	BLOCK	1			; COUNT OF CHARACTERS IN TTIBUF

TTIPTR:	POINT	8,TTIBUF		; CURRENT POINTER INTO TTIBUF

TTOBUF:	BLOCK	<RCVSIZ/5>+1		; TERMINAL OUTPUT HOLDING BUFFER

TTYFLG:	BLOCK	1			; INDICATE THAT THE TERMINAL ISR
					; HAS INDUCED THE INTERRUPT ON THE
					; TIMER CHANNEL

UCDBLK:	BLOCK	4			; USER-DATA 

UCDCNT:	BLOCK	1			; COUNT OF USER-DATA BYTES

UCDFLG:	BLOCK	1			; USER-DATA SUBCMD FLAG

UCDDEF:	BLOCK	4			; DEFAULT USER-DATA

UCDDCT:	BLOCK	1			; COUNT OF DEFAULT USER-DATA BYTES


; PROGRAM STATISTICS

XMTCHR:	0				; NUMBER OF CHARACTERS TRANSMITTED
RCVCHR:	0				; NUMBER OF CHARACTERS RECEIVED

XMTPKT:	0				; NUMBER OF PACKETS TRANSMITTED
RCVPKT:	0				; NUMBER OF PACKETS RECEIVED

SESTIM:	BLOCK	2			; SESSION START TIME

CALLCT:	0				; CALL/CLEAR INTERLOCK

EDTFLG:	BLOCK	1			; EDITING MODE FLAG

SNDFLG:	0				; SEND COMMAND IN PROGRESS
SNDJFN:	0				; JFN OF FILE TO SEND

.DECHO:	0				; DEFAULT ECHO ENABLE
.DERRE:	0				; DEFAULT ERROR ENABLE

.TPNT:	0				; STRING POINTER FOR TAKE
.TERRE:	0				; TEMP ERROR ENA
.TECHO:	0				; TEMP ECHO ENA
.TIJFN:	0				; TEMP TAKE STORAGE
.TOJFN:	0				; TEMP TAKE OUTPUT JFN

ERRCNT:	0				; ERROR FLAG
ERRENA:	0				; ERROR ENABLE FLAG
ECHOEN:	0				; ECHO ENA FLAG
.TAKEF:	0				; TAKE FLAG
.TPSAV:	0				; SAVE P FOR TAKE

CDBUF:	BLOCK	^D64/4			; TEMP BUFFER FOR FACILITIES-DATA AND
					; USER-DATA STRING BUILDING

DTEDAT:	BLOCK	DTENUM*^D12		; RESERVE DTENUM ^D12 WORD BLOCKS

DTEEND==.

; DEFINE COMMAND TEMPORARY STROAGE

DFHOST:	BLOCK	4			; HOLDING BUFFER FOR REMOTE HOST NAME
DFDTEA:	BLOCK	4			; HOLDING BUFFER FOR DTE ADDRESS
DFDTES:	BLOCK	4			; HOLDING BUFFER FOR DTE SUBADDRESS


COREND==.-1				; END OF CORE TO ZERO AT START-UP


GENRIC:	FLDDB. .CMCFM			; GENERIC CONFIRM .FLDDB

INJFN:	.PRIIN				; INPUT JFN
OUTJFN:	.PRIOU				; OUTPUT JFN


USRDAT:	BYTE	(8)1,0,0,0		; PROTOCOL ID. == X.29 REQUEST
USRDSZ==4				; SIZE OF FIELD

BRKCHR:	"X"-100				; CHARACTER USER TO INITIATE A BREAK

ESCCHR:	"\"-100				; CHARACTER USED TO ESCAPE TO COMMAND
					; MODE
STSCHR:	"A"-100				; CHARACTER USED TO DISPLAY LINK STATUS

INIPTR:	POINT	8,TTIBUF		; INITIAL POINTER INTO TTIBUF
; ARGUMENT BLOCKS FOR X.25 SUBROUTINE CALLS


; ARGUMENT BLOCK FOR THE X%CIM CALL

CIMBLK:	0				; PORT NUMBER
	0				; ERROR CODE RETURN

; ARGUMENT BLOCK FOR THE X%CSC CALL

CSCBLK:	0				; PORT NUMBER
	0				; ERROR CODE RETURN
	0				; DTE CLEAR CAUSE
	POINT	7,CUGBLK		; POINTER TO CLOSED USER GROUP
	0,,FACBLK			; LENGTH,,ADDR OF FACILITIES BLOCK
	0,,CLDBLK			; LENGTH,,ADDR OF USER CLEAR DATA BLOCK


; ARGUMENT BLOCK FOR THE X%ISC CALL

ISCBLK:	CH.NET,,PRTBLK			; NETWORK PSI CHN,,PORT BLOCK
	0				; ERROR CODE RETURN
	POINT	7,NETNAM		; POINTER TO NETWORK NAME STRING
	POINT	7,NETPSW		; POINTER TO NETWORK PASSWORD
	POINT	7,DTEADR		; POINTER TO DTE ADDRESS
	POINT	7,DTESUB		; POINTER TO THE DTE SUBADDRESS
	POINT	7,CUGBLK		; POINTER TO USER GROUP
	0,,FACBLK			; LENGTH,,ADDR OF FACILITIES BLOCK
	0,,UCDBLK			; LENGTH,,ADDR OF USER CALL DATA BLOCK

; ARGUMENT BLOCK FOR THE X%RAD CALL

RADBLK:	0				; PORT NUMBER
	0				; RETURN CODE
	POINT	7,CUSGRP		; POINTER TO CLOSED USER GROUP
	0				; LENGTH,,ADDR OF BLK TO PUT FACILITIES
					;          DATA IN
	0				; LENGTH,,ADDR OF BLK TO PUT DATA FROM
					;          REMOTE DTE IN
; ARGUMENT BLOCK FOR THE X%RCD CALL

RCDBLK:	0				; PORT NUMBER
	0				; ERROR CODE RETURN
	0				; DTE CLEAR CAUSE
	POINT	7,CUGBLK		; POINTER TO CLOSED USER GROUP
	0,,FACBLK			; LENGTH,,ADDR OF FACILITIES BLOCK
	0,,CLDBLK			; LENGTH,,ADDR OF USER CLEAR DATA BLOCK


; ARGUMENT BLOCK FOR THE X%RDM CALL

RDMBLK:	0				; PORT NUMBER
	0				; RETURN CODE
	0				; MORE-DATA BITS,,BYTES RECEIVED
	0				; DESTINATION OUTPUT DESIGNATOR


; ARGUMENT BLOCK FOR THE X%RIM CALL

RIMBLK:	0				; PORT NUMBER
	0				; RETURN CODE
	0				; ADDR OF WORD WHERE INTERRUPT BYTE IS
					; RETURNED


; ARGUMENT BLOCK FOR THE X%RPS CALL

RPSBLK:	0				; PORT NUMBER
	0				; RETURN CODE
	0				; LAST FATAL ERROR,,CURRENT PORT STATE
	0				; INTERRUPT BIT MASK,,PACKET SIZE


; ARGUMENT BLOCK FOR THE X%RRD CALL

RRDBLK:	0				; PORT NUMBER
	0				; RETURN CODE
	0				; RESET CAUSE,,DIAGNOSTIC BYTE


; ARGUMENT BLOCK FOR THE X%RVC CALL

RVCBLK:	0				; PORT NUMBER
	0				; RETURN CODE
	0				; DIAGNOSTIC BYTE


; ARGUMENT BLOCK FOR THE X%SDM CALL

SDMBLK:	0				; PORT NUMBER
	0				; RETURN CODE
	0				; MORE-DATA BITS,,NUMBER OF DATA BYTES
	0				; SOURCE DESIGNATOR


; ARGUMENT BLOCK FOR THE X%SIM CALL

SIMBLK:	0				; PORT NUMBER
	0				; RETURN CODE
	0				; INTERRUPT DATA BYTE


; ARGUMENT BLOCK FOR THE X%TPA CALL

TPABLK:	0				; PORT NUMBER
	0				; RETURN CODE
; PAD PARAMETER BLOCK
;
; FORMAT: LH = FLAGS
;	  RH = VALUE

PF%WRT==1B0				; BIT INDICATING WHO SET THIS PARAMETER
					; 0 IF SET BY X29PAD
					; 1 IF SET BY REMOTE HOST
PF%SET==1B1				; 0 IF NEVER SET
					; 1 IF SET BY SOMEONE


PADBLK:	PADLEN				; LENGTH OF PAD TABLE
PAD.1:	0				; ESCAPE TO COMMAND LEVEL
PAD.2:	0				; ECHO MODE
PAD.3:	0				; DATA FORWARDING
PAD.4:	0				; IDLE TIMER DELAY
PAD.5:	0				; ANCILLARY DEVICE CONTROL
PAD.6:	0				; CNTRL. OF PAD CONTROL SIGNALS
PAD.7:	0				; ACTION ON BREAK
PAD.8:	0				; DISCARD OUTPUT
PAD.9:	0				; CARRIAGE RETURN PADDING
PAD.10:	0				; LINE FOLDING
PAD.11:	0				; LINE SPEED
PAD.12:	0				; FLOW CONTROL
PAD.13:	0				; LF INSERTION AFTER CR
PAD.14:	0				; LINE-FEED PADDING
PAD.15:	0				; EDITING
PAD.16:	0				; CHARACTER DELETE
PAD.17:	0				; LINE DELETE
PAD.18:	0				; LINE DISPLAY 
PADLEN==<.-PADBLK>-1


; INITIAL PAD VALUES
; NOTE THAT THESE ARE THE X.28 SIMPLE STANDARD PROFILE PARAMETERS

IPD.1:	^D1				; ESCAPE IS POSSIBLE
IPD.2:	^D1				; ECHO IS DONE LOCALLY
IPD.3:	^D126				; DATA-FORWARDING IS ON ALL CHARS
IPD.4:	^D0				; IDLE-TIMER IS DISABLED
IPD.5:	^D1				; FLOW-CONTROL IS ENABLED
IPD.6:	^D1				; CNTRL. OF PAD CONTROL SIGNALS
IPD.7:	^D2				; ACTION-ON-BREAK IS RESET
IPD.8:	^D0				; NORMAL DATA DELIVERY
IPD.9:	^D0				; <CR> PADDING IS DISABLED
IPD.10:	^D0				; LINE WIDTH IS 0
IPD.11:	^D2				; RATE IS 9600 BAUD
IPD.12:	^D1				; FLOW-CONTROL IS ENABLED
IPD.13:	^D0				; NO <LF> INSERTION
IPD.14:	^D0				; <LF> PADDING IS DISABLED
IPD.15:	^D0				; LOCAL EDITING IS DISABLED
IPD.16:	177				; DELETE CHAR IS <DEL>
IPD.17:	025				; LINE DELETE CHAR IS <^U>
IPD.18:	022				; LINE DISPLAY CHARACTER IS <^R>
; TERMINAL CHARACTER SET TABLE USED FOR LOCAL ECHOING

.ASCII:
	P03%CT,,$TOCTL			; CONTROL-@
	P03%CT,,$TOCTL			; CONTROL-A
	P03%CT,,$TOCTL			; CONTROL-B
	P03%TR,,$TOCTL			; CONTROL-C
	P03%TR,,$TOCTL			; CONTROL-D
	P03%ES,,$TOCTL			; CONTROL-E
	P03%ES,,$TOCTL			; CONTROL-F
	P03%ES,,$TOCHR			; CONTROL-G
	P03%CT,,$TOCTL			; CONTROL-H
	P03%FM,,$TOCHR			; CONTROL-I
	P03%FM,,$TOCHR			; <LF>
	P03%FM,,$TOCTL			; CONTROL-K
	P03%FM,,$TOCTL			; CONTROL-L
	P03%CR,,$TOCAR			; <CR>
	P03%CT,,$TOCTL			; CONTROL-N
	P03%CT,,$TOCTL			; CONTROL-O
	P03%CT,,$TOCTL			; CONTROL-P
	P03%CT,,$TOCTL			; CONTROL-Q
	P03%ED,,$TOCTL			; CONTROL-R
	P03%CT,,$TOCTL			; CONTROL-S
	P03%CT,,$TOCTL			; CONTROL-T
	P03%CT,,$TOCTL			; CONTROL-U
	P03%CT,,$TOCTL			; CONTROL-V
	P03%CT,,$TOCTL			; CONTROL-W
	P03%ED,,$TOCTL			; CONTROL-X
	P03%CT,,$TOCTL			; CONTROL-Y
	P03%CT,,$TOCTL			; CONTROL-Z
	P03%ES,,$TOESC			; <ESC>
	P03%CT,,$TOCTL			; CONTROL-\
	P03%CT,,$TOCTL			; CONTROL-]
	P03%CT,,$TOCTL			; CONTROL-^
	P03%CT,,$TOCTL			; CONTROL-_
	P03%OT,,$TOCHR			; <SP>
	P03%OT,,$TOCHR			; !
	P03%OT,,$TOCHR			; "
	P03%OT,,$TOCHR			; #
	P03%OT,,$TOCHR			; $
	P03%OT,,$TOCHR			; %
	P03%OT,,$TOCHR			; &
	P03%OT,,$TOCHR			; '
	P03%OT,,$TOCHR			; (
	P03%OT,,$TOCHR			; )
	P03%OT,,$TOCHR			; *
	P03%OT,,$TOCHR			; +
	P03%OT,,$TOCHR			; ,
	P03%OT,,$TOCHR			; -
	P03%OT,,$TOCHR			; .
	P03%OT,,$TOCHR			; /
	P03%AL,,$TOCHR			; 0
	P03%AL,,$TOCHR			; 1
	P03%AL,,$TOCHR			; 2
	P03%AL,,$TOCHR			; 3
	P03%AL,,$TOCHR			; 4
	P03%AL,,$TOCHR			; 5
	P03%AL,,$TOCHR			; 6
	P03%AL,,$TOCHR			; 7
	P03%AL,,$TOCHR			; 8
	P03%AL,,$TOCHR			; 9
	P03%OT,,$TOCHR			; :
	P03%OT,,$TOCHR			; ;
	P03%OT,,$TOCHR			; <
	P03%OT,,$TOCHR			; =
	P03%OT,,$TOCHR			; >
	P03%OT,,$TOCHR			; ?
	P03%OT,,$TOCHR			; @
	P03%AL,,$TOCHR			; A
	P03%AL,,$TOCHR			; B
	P03%AL,,$TOCHR			; C
	P03%AL,,$TOCHR			; D
	P03%AL,,$TOCHR			; E
	P03%AL,,$TOCHR			; F
	P03%AL,,$TOCHR			; G
	P03%AL,,$TOCHR			; H
	P03%AL,,$TOCHR			; I
	P03%AL,,$TOCHR			; J
	P03%AL,,$TOCHR			; K
	P03%AL,,$TOCHR			; L
	P03%AL,,$TOCHR			; M
	P03%AL,,$TOCHR			; N
	P03%AL,,$TOCHR			; O
	P03%AL,,$TOCHR			; P
	P03%AL,,$TOCHR			; Q
	P03%AL,,$TOCHR			; R
	P03%AL,,$TOCHR			; S
	P03%AL,,$TOCHR			; T
	P03%AL,,$TOCHR			; U
	P03%AL,,$TOCHR			; V
	P03%AL,,$TOCHR			; W
	P03%AL,,$TOCHR			; X
	P03%AL,,$TOCHR			; Y
	P03%AL,,$TOCHR			; Z
	P03%OT,,$TOCHR			; [
	P03%OT,,$TOCHR			; \
	P03%OT,,$TOCHR			; ]
	P03%OT,,$TOCHR			; ^
	P03%OT,,$TOCHR			; _
	P03%OT,,$TOCHR			; /
	P03%AL,,$TOCHR			; a
	P03%AL,,$TOCHR			; b
	P03%AL,,$TOCHR			; c
	P03%AL,,$TOCHR			; d
	P03%AL,,$TOCHR			; e
	P03%AL,,$TOCHR			; f
	P03%AL,,$TOCHR			; g
	P03%AL,,$TOCHR			; h
	P03%AL,,$TOCHR			; i
	P03%AL,,$TOCHR			; j
	P03%AL,,$TOCHR			; k
	P03%AL,,$TOCHR			; l
	P03%AL,,$TOCHR			; m
	P03%AL,,$TOCHR			; n
	P03%AL,,$TOCHR			; o
	P03%AL,,$TOCHR			; p
	P03%AL,,$TOCHR			; q
	P03%AL,,$TOCHR			; r
	P03%AL,,$TOCHR			; s
	P03%AL,,$TOCHR			; t
	P03%AL,,$TOCHR			; u
	P03%AL,,$TOCHR			; v
	P03%AL,,$TOCHR			; w
	P03%AL,,$TOCHR			; x
	P03%AL,,$TOCHR			; y
	P03%AL,,$TOCHR			; z
	P03%OT,,$TOCHR			; {
	P03%OT,,$TOCHR			; }
	P03%OT,,$TOCHR			; |
	P03%OT,,$TOCHR			; ~
	P03%ED,,$TODEL			; <del>
; DTE ADDRESS TABLE FOR COMND

DTETAB:	0,,DTENUM			; EMPTY TABLE,,MAX TABLE SIZE
	BLOCK	DTENUM			; RESERVE TABLE SPACE


;SOFTWARE INTERUPT TABLES AND STORAGE

CHNTAB:	LV.NET,,$NETIN			; X25 INTERUPT POINTER
	LV.TMR,,$TIMER			; TIMERS INTERUPT CHANEL
	LV.TTY,,$TTYIN			; TTY's INPUT CHANNEL
	CH.CNT==.-CHNTAB		; RESERVE THE REST OF THE CHANNELS
	CH.FRE==^D36-CH.CNT
	BLOCK	CH.FRE

LEVTAB:	PCWORD
	PCWORD+1
	PCWORD+2

PCWORD:	BLOCK	3


; COMMAND STATE BLOCK

CMDBLK:	0
	0
	0
	-1,,CMDBUF			; POINTER TO START OF TEXT BUFFER
	-1,,CMDBUF			; POINTER TO START OF NEXT INPUT
	CMDBSZ*5-1			; SIZE OF COMMAND BUFFER IN BYTES
	0				; NUMBER OF UNPARSED CHARACTERS
	-1,,ATMBUF			; POINTER TO START OF ATOM BUFFER
	ATMBSZ*5-1			; SIZE OF ATOM BUFFER IN BYTES
	GTJBLK				; POINTER TO GTJFN BLOCK
	SUBTTL	COMMAND DISPATCH AND COMMAND TABLE

START:	SETZM	REENF			; CLEAR REENTER FLAG
	RESET				; INITIALIZE ALL I/O
	MOVE	P,[IOWD PDLEN,PDLIST]	; INITIALIZE STACK POINTER
	SETZM	CORBEG			; INITIALIZE DATA AREA
	MOVE	T1,[CORBEG,,CORBEG+1]
	BLT	T1,COREND
	MOVEI	T1,USRDSZ		; GET SIZE OF MANDATORY USER-DATA
	MOVEM	T1,UCDDCT		; AND STORE IT
	MOVE	T1,USRDAT		; GET MANDATORY USER-DATA STRING
	MOVEM	T1,UCDDEF		; AND STORE IT
	HRRZI	T1,DTENUM		; GET MAX DTETAB TABLE SIZE
	MOVEM	T1,DTETAB		; AND STORE IT
	MOVEI	T1,CMRPRS		; FLAGS AND ADDRESS OF REPARSE ROUTINE
	MOVEM	T1,CMDBLK		; RESTORE COMAND BLOCK REPARSE
	MOVE	T1,[.PRIIN,,.PRIOU]	; JFNS FOR COMMAND I/O
	MOVEM	T1,CMDBLK+1		; RESTORE INPUT OUTPUT POINTERS
	HRRZM	T1,OUTJFN		; UPDATE OUTPUT JFN
	HLRZM	T1,INJFN		; UPDATE INPUT JFN
	HRROI	T1,[ASCIZ\X29PAD>\]	; CTRL/R BUFFER
	MOVEM	T1,CMDBLK+2		; UPDATE CTRL/R BUFFER
	SETZM	.TAKEF			; CLEAR TAKE FLAG
	SKIPE	REENF			; DID WE REENTER
	JRST	XLOOP			; YES, GO DIRECTLY TO LOOP
	SETZM	.DECHO			; CLEAR DEFAULT ECHO
	SETZM	.DERRE			; CLEAR DEFAULT ERROR
	SETZM	LOGJFN			; CLEAR LOG JFN
	SETOM	L.SUPP			; DEFAULT SUPPRESS NULLS
	MOVX	GJ%FOU!GJ%MSG		; GET JFN TYPE
	MOVEM	.LJBLK			; LOG SUPERSEDE AS DEFAULT
	MOVEI	T1,.FHSLF
	MOVE	T2,[LEVTAB,,CHNTAB]
	SIR				; SET ADDRESSES OF TABLES
	CIS				; CLEAR INT SYSTEM
	EIR				; ENABLE IT
	CALL	INIPAD			; INIT THE PAD PARAMETER BLOCK
	CALL	TAKER			; TAKE PS:<DIRECTORY>X29PAD.INIT
	CALL	.IVERH			; PRINT VERSION NUMBER

XLOOP:
	CALL	GETCMD			; GET A COMMAND AND RUN IT
	JRST	XLOOP			; GO BACK TO GO

GETCMD:
	MOVEI	T1,CMDBLK		; POINT TO STATE BLOCK
	MOVEI	T2,[FLDDB. .CMINI]	; INITIALIZE STATE BLOCK, WATCH FOR
	COMND				; CTRL/H, DO OUTPUT PROMPT
	ERCAL	FATAL			; THIS SHOULD NEVER HAPPEN
	MOVEM	P,SAVPDL		; SAVE STACK POINTER FOR REPARSE
CMRPRS:	MOVE	P,SAVPDL		; RESTORE STACK POINTER FOR REPARSE
	PUSH	P,T1			; SAVE T1
	SETO	T1,			; CLEAR ANY UNOPENED FORKS
	RLJFN
	SKIP				; IGNORE ANY ERRORS
	POP	P,T1			; RETORE T1
	MOVEI	T2,[FLDDB. .CMKEY,,CMDTAB,<a command,>,,.CMFRD]
	COMND
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	HRRZ	T3,T3			; GET FDB USED
	HRRZ	T2,T2			; CLEAR LEFT HALF OF T2
	HRRZ	T2,(T2)			; GET THE COMMAND DISPATCH
	CAIE	T3,.CMFRD		; DID HE JUST TYPE A CRLF
	JRST	(T2)			; NO, AND GO DO IT
	SKIPE	LOGJFN
	CALL	LOG
	SKIPE	.TAKEF			; ARE WE DOING A TAKE
	JRST	.TECC			; YES, GO ECHO
	RET				; NO


; COMMAND TABLE

CMDTAB:	CMDTBL,,CMDTBL			; ACTUAL,,MAXIMUM NUMBER OF ENTRIES
	TBL (ABORT)
	TBL (BREAK)
	TBL (CALL)
	TBL (CLEAR)
	TBL (CLOSE)
	TBL (CONTINUE)
	TBL (DEFINE)
	TBL (EXIT)
	TBL (HELP)
	TBL (INFORMATION)
	TBL (LOG)
	TBL (PUSH)
	TBL (SEND)
	TBL (SET)
	TBL (TAKE)
CMDTBL==<.-CMDTAB>-1			; NUMBER OF ENTRIES IN THE TABLE
; HERE TO INITIALIZE THE PAD PARAMETERS TO A KNOWN STATE

INIPAD:
	MOVE	T1,[IPD.1,,PAD.1]
	BLT	T1,PAD.18		; MOVE IPD.* TO PAD.*
	RET
	SUBTTL	ABORT COMMAND

; HERE TO ABORT THE SENDING OF A FILE TO A REMOTE-HOST

.ABORT:
	NOISE (the transmition of the file currently being sent)
	CONFIRM
	SKIPN	SNDFLG			; SKIP IF A SEND IS IN PROGRESS
	JRST	.ABOR1			; NO SEND IN PROGRESS
	MOVE	T1,SNDJFN		; GET THE INPUT FILE'S JFN
	CLOSF				; CLOSE THE SNDJFN
	  ERCAL	FATAL			; SHOULD NEVER HAPPEN
	SETZM	SNDFLG			; CLEAR THE SEND FLAG
	SETZM	SNDINT			; CLEAR THE INTERRUPT FLAG
	SETZM	SNDJFN			; CLEAR THE FILE JFN
	RET				; AND RETURN

.ABOR1:	HRROI	T1,[ASCIZ\%There is no file currently being sent\]
	CALL	.SOUTR
	RET
	SUBTTL	BREAK COMMAND

; HERE TO PROCESS THE BREAK COMMAND

.BREAK:
	NOISE (and continue the call)
	CONFIRM
	SKIPE	ESCFLG			; IS THERE A CALL TO CONTINUE?
	JRST	.BREA0			; YES, CONTINUE ON
	HRROI	T1,[ASCIZ\?There is no call to continue\]
	CALL	.SOUTR
	RET
.BREA0:	HRRZ	T2,PAD.7		; GET ACTION-ON-BREAK PARAMETER
	JUMPE	T2,.BREA1		; NO ACTION, IGNORE
	TXNE	T2,P07%ES		; ESCAPE TO COMMAND MODE?
	RET				; YES, JUST RETURN
	TXNE	T2,P07%IT		; SEND INTERRUPT MESSAGE?
	CALL	.BRINT			; YES
	TXNE	T2,P07%ID		; SEND INDICATION OF BREAK?
	CALL	.BRIDB			; YES
	TXNE	T2,P07%DO		; DISCARD OUTPUT?
	CALL	.BRDIS			; YES
	TXNE	T2,P07%RE		; SEND RESET?
	CALL	.BRRES			; YES

.BREA1:	JRST	.CONT1			; NOW CONTINUE THE CALL
; HERE TO SEND AN INTERRUPT MESSAGE TO THE REMOTE-HOST

.BRINT:
	HRRZ	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,SIMBLK		; STORE IT
	SETZM	SIMBLK+1		; CLEAR RETURN STATUS
	SETZM	SIMBLK+2		; SEND A NULL BYTE
	MOVEI	T1,SIMBLK		; POINT TO ARG BLOCK
	CALL	X%SIM##			; AND SEND INTERRUPT
	HRRZ	T1,SIMBLK+1		; GET RETURN STATUS
	CAIN	T1,XC%SUC		; SUCCESS?
	RET				; YES, RETURN
	MOVEM	T1,LASTNE		; NO, SAVE THE RETURN CODE
	CALL	NETERR			; REPORT THE ERROR
	RET				; AND RETURN
; HERE TO DISCARD OUTPUT

.BRDIS:
	MOVE	T1,[PF%WRT!P08%DO]	; GET THE DISCARD OUTPUT BIT
	MOVEM	T1,PAD.8		; AND STORE IT
	MOVEI	T1,.PRIOU		; GET OUTPUT DESIGNATOR
	CFOBF				; CLEAR OUTPUT BUFFER
	ERCAL	FATAL
	RET				; AND RETURN
; HERE TO SEND INDICATION OF BREAK TO THE REMOTE-HOST

.BRIDB:
	PUSH	P,T1
	PUSH	P,T2
	PUSH	P,T3
	SETZ	T3,
	MOVE	T1,[POINT 8,NTOBUF]	; GET POINTER TO MESSAGE BUFFER
	MOVEI	T2,3			; INDICATION OF BREAK MSG #
	IDPB	T2,T1			; STORE IT
	AOS	T3			; COUNT IT
	HRRZ	T2,PAD.7		; GET ACTION-ON-BREAK PARAMETER
	TXNN	T2,P07%DO		; DISCARD OUTPUT?
	JRST	.BRID1			; NO, JUST SEND INDICATION OF BREAK
	MOVEI	T2,^D8			; GET PARAMETER #8
	IDPB	T2,T1			; STORE IT
	AOS	T3			; COUNT IT
	MOVEI	T2,P08%DO		; DISCARDING OUTPUT
	IDPB	T2,T1			; STORE IT
	AOS	T3			; COUNT IT
.BRID1:	HRRZ	T2,PORTNO		; GET THE PORT NUMBER
	MOVEM	T2,SDMBLK		; STORE IT
	SETZM	SDMBLK+1		; CLEAR THE RETURN STATUS
	TXO	T3,XM%QUA		; SET QUALIFIED DATA BIT
	MOVEM	T3,SDMBLK+2		; STORE COUNT AND BITS
	MOVE	T2,[POINT 8,NTOBUF]	; POINT TO MESSAGE
	MOVEM	T2,SDMBLK+3		; STORE IT
	MOVEI	T1,SDMBLK		; POINT TO ARG BLOCK
	CALL	X%SDM
	HRRZ	T1,SDMBLK+1		; GET RETURNED STATUS
	CAIN	T1,XC%SUC		; SUCCESSFUL?
	JRST	.BRID2			; YES
	MOVEM	T1,LASTNE		; NO, STORE THE ERROR
	CALL	NETERR			; REPORT IT
.BRID2:	POP	P,T3
	POP	P,T2
	POP	P,T1
	RET				; AND RETURN
; HERE TO RESET THE CIRCUIT

.BRRES:
	PUSH	P,T1
	HRRZ	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,RPSBLK		; STORE IT
	SETZM	RPSBLK+1		; ZERO THE STATUS RETURN WORD
	SETZM	RPSBLK+2		; ZERO THE ERROR CONDITION,,PORT STATE
	SETZM	RPSBLK+3		; ZERO THE INTERRUPT/BIT MASK
	MOVEI	T1,RPSBLK		; POINT TO THE ARG BLOCK
	CALL	X%RPS##			; AND READ THE PORT STATUS
	HRRZ	T1,RPSBLK+1		; GET THE RETURN CODE
	CAIE	T1,XC%SUC		; SUCCESSFUL?
	JRST	.BRRE1			; NO, JUST DISMISS
	HRRZ	T1,RPSBLK+2		; YES, GET THE PORT STATE
	CAIE	T1,XS%RUN		; IS THE PORT RUNNING?
	JRST	.BRRE1			; NO, JUST DISMISS
	HRRZ	T1,PORTNO		; YES, GET THE PORT NUMBER
	MOVEM	T1,RVCBLK		; STORE IT
	SETZM	RVCBLK+1		; CLEAR THE RETURN CODE
	SETZM	RVCBLK+2		; CLEAR THE DIAGNOSTIC BYTE
	MOVEI	T1,RVCBLK		; POINT AT THE ARG BLICK
	CALL	X%RVC##			; AND RESET THE CIRCUIT
	HRRZ	T1,RVCBLK+1		; GET THE RETURN CODE
	CAIN	T1,XC%SUC		; SUCCESSFUL?
	JRST	.BRRE1			; YES
	MOVEM	T1,LASTNE		; NO, STORE THE ERROR
	CALL	NETERR			; REPORT IT
.BRRE1:	POP	P,T1
	RET
	SUBTTL	CALL COMMAND

; HERE TO PROCESS A CALL COMMAND AND CONNECT TO A REMOTE HOST

.CALL:
	SETZM	RCVCHR			; CLEAR RECEIVE CHARACTER COUNT
	SETZM	RCVPKT			; CLEAR RECEIVE PACKET COUNT
	SETZM	XMTCHR			; CLEAR TRANSMIT CHARACTER COUNT
	SETZM	XMTPKT			; CLEAR	TRANSMIT CHARACTER COUNT
	SETZM	CUGBLK			; CLEAR CLOSED-USER-GROUP
	SETZM	CUGFLG			; CLEAR THE CLOSED-USER-GROUP FLAG
	SETZM	FACFLG			; CLEAR THE FACILITIES SUBCMD FLAG
	SETZM	FACCNT			; ZERO FACILITIES-DATA BYTE COUNT
	SETZM	UCDFLG			; CLEAR THE USER-DATA SUBCMD FLAG
	SETZM	UCDCNT			; ZERO USER-DATA BYTE COUNT
	HLRZ	P1,DTETAB		; GET THE NUMBER OF DEFINED HOSTS
	JUMPE	P1,.CALLA		; IF NOTHING USE ALTERNATE PROMPTING
	MOVEI	T2,[FLDDB. .CMKEY,,DTETAB,<>,,CONFLD]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; GET THE ADDRESS OF THE FLD USED
	CAIE	T3,CONFLD		; PARSE A LOGICAL NAME?
	JRST	PARLOG			; YES, GET THE DTE ADDR STRING
	JRST	PARSTR			; NO, PARSE THE STRING

.CALLA:	MOVEI	T2,CONFLD		; HERE IF THERE ARE NO DEFINED HOSTS
	COMND
	ERCAL	FATAL
	JRST	PARSTR			; GO PARSE THE STRING


CONFLD:	FLDDB. .CMFLD,CM%SDH,,<a remote DTE address>

CALFLD:	FLDDB. .CMCFM,,,<Comma to enter subcommands, or>,,CALCMA

CALCMA:	FLDDB. .CMCMA,CM%SDH
; HERE TO TRANSLATE A LOGICAL HOST NAME TO A DTE ADDRESS STRING

PARLOG:
	HLRZ	P1,(T2)			; POINT TO THE DTEDAT BLOCK
	MOVEI	T2,CALFLD		; POINT TO COMND DESCRIPTOR
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; GET THE DESCRIPTOR BLOCK WE USED
	CAIN	T3,CALFLD		; WAS THIS JUST A CONFIRM?
	JRST	PARLG1			; YES, CONTINUE ON
	CALL	.CALSB			; NO, ENTER SUBCOMMAND MODE

PARLG1:	ADDI	P1,4			; POINT TO THE DTE ADDRESS FOR THIS HOST
	HRLZ	T1,P1			; PUT SOURCE IN LH OF P1
	HRRI	T1,DTEADR		; PUT DESTINATION IN RH OF P1
	BLT	T1,DTEADR+3		; AND MOVE THE DTE ADDRESS
	ADDI	P1,4			; POINT TO THE DTE SUBADDRESS
	HRLZ	T1,P1			; PUT SOURCE IN LH OF P1
	HRRI	T1,DTESUB		; PUT DESTINATION IN RH OF P1
	BLT	T1,DTESUB+3		; AND MOVE THE DTE ADDRESS
	JRST	.CALL0			; AND GO PLACE CALL
; HERE TO PARSE A DTE ADDRESS STRING

PARSTR:
	MOVE	P1,[POINT 7,ATMBUF,6]	; POINT TO THE FIRST CHARACTER
	MOVE	P2,[POINT 7,DTEADR,6]	; POINT TO THE DESTINATION
	SETZ	P3,			; ZERO A CHARACTER COUNTER
	LDB	P4,P1			; GET A CHARACTER
PARST1:	CAIE	P4,040			; A SPACE?
	JRST	PARST2			; NO, GO ON
	ILDB	P4,P1			; GET ANOTHER CHARACTER
	JRST	PARST1			; AND CHECK FOR ANOTHER LEADING SPACE
PARST2:	CAIN	P4,0			; A NUL?
	JRST	PARSTE			; YES, COMPLAIN
	CAIG	P4,"9"			; SKIP IF GREATER THAN THE CHAR "9"
	CAIGE	P4,"0"			; SKIP IF LESS THAN THE CHAR "0"
	JRST	PARERR			; COMPLAIN ABOUT NON-NUMERIC CHARACTER
	DPB	P4,P2			; STORE IT
	AOS	P3			; COUNT IT
PARST3:	ILDB	P4,P1			; GET A CHARACTER
	CAIN	P4,0			; A NUL?
	JRST	PAREOS			; YES, END OF STRING
	CAIG	P4,"9"			; SKIP IF GREATER THAN THE CHAR "9"
	CAIGE	P4,"0"			; SKIP IF LESS THAN THE CHAR "0"
	JRST	PARERR			; COMPLAIN ABOUT NON-NUMERIC CHARACTER
	IDPB	P4,P2			; DEPOSIT IT
	AOS	P3			; COUNT IT
	CAIG	P3,^D15			; MORE THAN ^D15 CHARACTERS?
	JRST	PARST3			; NO, MOVE ANOTHER CHARACTER
	HRROI	T1,[ASCIZ\?Address string cannot exceed 15 characters\]
	CALL	.SOUTR
	RET

PARERR:	HRROI	T1,[ASCIZ\?Address string must be numeric\]
	CALL	.SOUTR
	RET

PAREOS:	IDPB	P4,P2			; FINISH UP THE DTE ADDRESS STRING
	MOVEI	T2,PARFLD
	COMND
	ERCAL	FATAL
	SETZM	DTESUB			; <CR> SO ZERO THE SUB-ADDRESS STRING
	HRRZ	T3,T3			; GET THE FLD USED TO PARSE
	CAIN	T3,PARFLD		; WHICH FLD WAS USED TO PARSE?
	JRST	PRSSTR			; GO PARSE THE SUB-ADDRESS STRING
	CAIE	T3,CALCMA		; ENTER SUBCOMMAND MODE?
	CALL	.CALSB			; YES, ENTER SUBCOMMAND MODE
	SKIPE	LOGJFN
	CALL	LOG
	JRST	.CALL0			; AND GO PLACE THE CALL


PARFLD:	FLDDB. .CMFLD,CM%SDH,,<a remote DTE sub-address>,,CALFLD

; HERE ON AN INVALID (OR NULL) STRING

PARSTE:	HRROI	T1,[ASCIZ\?Illegal null string specified\]
	CALL	.SOUTR
	RET
; HERE TO PARSE THE DTE SUB-ADDRESS STRING

PRSSTR:
	MOVE	P1,[POINT 7,ATMBUF,6]	; POINT TO THE FIRST CHARACTER
	MOVE	P2,[POINT 7,DTESUB,6]	; POINT TO THE DESTINATION
	SETZ	P3,			; ZERO A CHARACTER COUNTER
	LDB	P4,P1			; GET A CHARACTER
PRSST1:	CAIE	P4,040			; A SPACE?
	JRST	PRSST2			; NO, GO ON
	ILDB	P4,P1			; GET ANOTHER CHARACTER
	JRST	PRSST1			; AND CHECK FOR ANOTHER LEADING SPACE
PRSST2:	CAIN	P4,0			; A NUL?
	JRST	PRSEOS			; YES, NO SUBADDRESS STRING GIVEN
	CAIG	P4,"9"			; SKIP IF GREATER THAN THE CHAR "9"
	CAIGE	P4,"0"			; SKIP IF LESS THAN THE CHAR "0"
	JRST	PRSERR			; COMPLAIN ABOUT NON-NUMERIC CHARACTER
	DPB	P4,P2			; STORE IT
	AOS	P3			; COUNT IT
PRSST3:	ILDB	P4,P1			; GET A CHARACTER
	CAIN	P4,0			; A NUL?
	JRST	PRSEOS			; YES, END OF STRING
	CAIG	P4,"9"			; SKIP IF GREATER THAN THE CHAR "9"
	CAIGE	P4,"0"			; SKIP IF LESS THAN THE CHAR "0"
	JRST	PRSERR			; COMPLAIN ABOUT NON-NUMERIC CHARACTER
	IDPB	P4,P2			; DEPOSIT IT
	AOS	P3			; COUNT IT
	CAIG	P3,^D15			; MORE THAN ^D15 CHARACTERS?
	JRST	PRSST3			; NO, MOVE ANOTHER CHARACTER
	HRROI	T1,[ASCIZ\?Subaddress string cannot exceed 15 characters\]
	CALL	.SOUTR
	RET

PRSERR:	HRROI	T1,[ASCIZ\?Subaddress string must be numeric\]
	CALL	.SOUTR
	RET

PRSEOS:	IDPB	P4,P2			; FINISH OFF STRING
	MOVEI	T2,CALFLD		; POINT TO COMND DESCRIPTOR
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; GET THE DESCRIPTOR BLOCK WE USED
	CAIN	T3,CALCMA		; SHOULD WE ENTER SUBCOMMAND MODE?
	CALL	.CALSB			; YES, ENTER SUBCOMMAND MODE
	JRST	.CALL0			; AND CONTINUE
; CALL SUBCOMMAND MODE ROUTINE

.CALSB:
	CONFIRM
	PUSH	P,CMDBLK		; SAVE REPARSE ADDRESS
	PUSH	P,CMDBLK+2		; SAVE CTRL/R BUFFER
	PUSH	P,P1
	PUSH	P,P2
	HRROI	T2,[ASCIZ\X29PAD-CALL>\]
	MOVEM	T2,CMDBLK+2		; UPDATE COMND BLOCK
	MOVEI	T2,.CSUB1		; NEW REPARSE ADDRESS
	MOVEM	T2,CMDBLK		; UPDATE COMND BLOCK
	CALL	.CSUB0			; GET SUBCOMMANDS
	POP	P,P2
	POP	P,P1
	POP	P,CMDBLK+2		; RESTORE CTRL/R BUFFER
	POP	P,CMDBLK		; RESTORE REPARSE ADDRESS
	RET


; THIS ROUTINE PARSES A SUBCOMMAND FOR THE CALL COMMAND

.CSUB0:	MOVEI	T1,CMDBLK		; POINT TO CMDBLK
	MOVEI	T2,[FLDDB. .CMINI]	; INITIALIZE STATE BLOCK
	COMND				; CTRL/H, DO OUTPUT PROMPT
	ERCAL	FATAL			; THIS SHOULD NEVER HAPPEN
	MOVEM	P,SAVPDL		; SAVE STACK POINTER FOR REPARSE
.CSUB1:	MOVE	P,SAVPDL		; RESTORE STACK POINTER FOR REPARSE
	MOVEI	T2,[FLDDB. .CMCFM,,,,,CSBFLD]	; CONFIRM OR GET SUB COMMAND
	COMND
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	[ CALL	ERROR		; YES, REPORT THE ERROR
		  JRST	.CSUB0 ]	; AND CONTINUE PROCESSING
	HRRZ	T3,T3			; GET FDB USED
	HRRZ	T2,T2			; CLEAR LEFT OF T2
	HRRZ	T2,(T2)			; IF SUBCOMMAND GET DISPATCH
	CAIE	T3,CSBFLD		; WAS IT A SUBCOMMAND
	RET				; NO, JUST RETURN
	CALL	(T2)			; YES, GO DO IT
	JRST	.CSUB0			; AND GO LOOKING FOR MORE

CSBFLD:	FLDDB. .CMKEY,,CSBTAB

CSBTAB:	CSBTBL,,CSBTBL
	TBL (ABORT,,.CSABO)
	TBL (CLOSED-USER-GROUP,,.CSCUG)
	TBL (FACILITIES-DATA,,.CSFAC)
	TBL (HELP,,.CSHLP)
	TBL (INFORMATION,,.CSINF)
	TBL (USER-DATA,,.CSUSD)
CSBTBL==<.-CSBTAB>-1
; HERE TO PROCESS AN ABORT SUBCOMMAND

.CSABO:	NOISE (this attempt to place a call)
	CONFIRM
	POP	P,			; POP OFF CALL .CSABO RETURN
	POP	P,			; POP OFF CALL .CSUB0 RETURN
	POP	P,P2			; RESTORE P2
	POP	P,P1			; RESTORE P1
	POP	P,CMDBLK+2		; RESTORE CMDBLK+2
	POP	P,CMDBLK		; RESTORE CMDBLK
	POP	P,			; POP OFF CALL .CALSB RETURN
	RET				; AND RETURN TO COMMAND MODE
; HERE TO PARSE A CLOSED-USER-GROUP SUBCOMMAND

.CSCUG:	NOISE (is)
	MOVEI	P1,^D16			; GET MAX NUMBER OF DATA BYTES LEGAL
	MOVE	P2,[POINT 7,CDBUF]	; POINT AT THE DEST DATA BUFFER
	CALL	.CUGPR
	  RET				; THE USER MADE AN ERROR, JUST RETURN
	MOVE	P1,[CDBUF,,CUGBLK]	; LOAD SOURCE,,DESTINATION
	BLT	P1,CUGBLK+3		; AND MOVE THEM
	SETOM	CUGFLG			; INDICATE FACILITIES-DATA VIA SUBCMD
	RET
; HERE TO PROCESS A HELP SUB COMMAND

.CSHLP:	NOISE (with)
	MOVEI	T2,[FLDDB. .CMKEY,,CSHTAB,<>,,GENRIC]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; WHO PARSED THIS FIELD?
	CAIN	T3,GENRIC		; JUST CONFIRMED?
	JRST	.CSHL1			; YES, GIVE GENERAL HELP MESSAGE
	HRRZ	T2,(T2)
	JRST	(T2)

.CSHL1:	HRROI	T1,.CSHLM
	CALL	.SOUT
	RET

.CSHLM:	ASCIZ\ The CALL command has the following subcommands:

  ABORT			Aborts the current call and returns to command mode.

  CLOSED-USER-GROUP	Allows you to supply a CLOSED-USER-GROUP name for
			the current call (or override the default). The
			CLOSED-USER-GROUP has a maximum length of 16 characters.

  FACILITIES-DATA	Allows you to supply FACILITIES-DATA for this call
			(or override the default). The maximum length of the
			FACILITIES-DATA is 63 bytes.

  HELP			Gives help with the CALL subcommands.

  INFORMATION		Displays the current call parameters (either as
			supplied or defaults that will be used).

  USER-DATA		Allows you to supply USER-DATA for the outgoing call
			(or override the default). The maximum length of the
			USER-DATA is 12 bytes.

 For information on the format of these commands type:

	X29PAD-CALL>HELP (with) argument

 Where argument is one of the above subcommands.
\


CSHTAB:	CSHTBL,,CSHTBL
	TBL (ABORT,,.CSHAB)
	TBL (CLOSED-USER-GROUP,,.CSHCL)
	TBL (FACILITIES-DATA,,.CSHFA)
	TBL (HELP,,.CSHHE)
	TBL (INFORMATION,,.CSHIN)
	TBL (USER-DATA,,.CSHUS)
CSHTBL==<.-CSHTAB>-1
; HERE TO PROCESS HELP ABORT

.CSHAB:	NOISE (subcommand)
	CONFIRM
	HRROI	T1,.HMCAS		; USE HELP MESSAGE FROM TOP LEVEL HELP
	CALL	.SOUT
	RET
; HERE TO PROCESS HELP CLOSED-USER-GROUP

.CSHCL:	NOISE (subcommand)
	CONFIRM
	HRROI	T1,.HMCCS		; USE HELP MESSAGE FROM TOP LEVEL HELP
	CALL	.SOUT
	RET


; HERE TO PROCESS HELP FACILITIES-DATA

.CSHFA:	NOISE (subcommand)
	CONFIRM
	HRROI	T1,.HMCFS		; USE HELP MESSAGE FROM TOP LEVEL HELP
	CALL	.SOUT
	RET
; HERE TO PROCESS HELP HELP

.CSHHE:	NOISE (subcommand)
	CONFIRM
	HRROI	T1,.HMCHS		 ; USE HELP MESSAGE FROM TOP LEVEL HELP
	CALL	.SOUT
	RET
; HERE TO PROCESS HELP INFORMATION

.CSHIN:	NOISE (subcommand)
	CONFIRM
	HRROI	T1,.HMCIS		; USE MESSAGE FROM TOP LEVEL HELP
	CALL	.SOUT
	RET
; HERE TO PROCESS HELP USER-DATA

.CSHUS:	NOISE (subcommand)
	CONFIRM
	HRROI	T1,.HMCUS		; USE HELP MESSAGE FROM TOP LEVEL HELP
	CALL	.SOUT
	RET
; HERE TO PARSE AN INFORMATION SUBCOMMAND

.CSINF:	NOISE (about current CALL parameters)
	CONFIRM
	SKIPN	CUGFLG			; HAS THE USER SPECIFIED A CUG?
	JRST	.CSIN1			; NO, GO PRINT THE DEFAULT STRING
	HRROI	T1,[ASCIZ\ CLOSED-USER-GROUP (is) \]
	CALL	.SOUT
	MOVE	T1,[POINT 7,CUGBLK]	; POINT AT CLOSED-USER-GROUP
	ILDB	P1,T1			; GET THE FIRST CHARACTER
	JUMPE	P1,.CSIN0		; JUMP IF NO DEFAULT SPECIFIED
	HRROI	T1,CUGBLK		; POINT TO STRING
	CALL	.SOUTR
	JRST	.CSIN3			; GO ON TO FACILITIES-DATA
.CSIN0:	HRROI	T1,[ASCIZ\%Nothing\]
	CALL	.SOUTR
	JRST	.CSIN3			; GO ON TO FACILITIES-DATA

.CSIN1:	HRROI	T1,[ASCIZ\ DEFAULT CLOSED-USER-GROUP (is) \]
	CALL	.SOUT
	MOVE	T1,[POINT 7,CUGDEF]	; POINT AT DEFAULT CLOSED-USER-GROUP
	ILDB	P1,T1			; GET THE FIRST CHARACTER
	JUMPE	P1,.CSIN2		; JUMP IF NO DEFAULT SPECIFIED
	HRROI	T1,CUGDEF		; POINT TO DEFAULT STRING
	CALL	.SOUTR
	JRST	.CSIN3			; GO ON TO FACILITIES-DATA
.CSIN2:	HRROI	T1,[ASCIZ\%Nothing\]
	CALL	.SOUTR

.CSIN3:	SKIPN	FACFLG			; HAS THE USER SPECIFIED FACILITIES-DATA
	JRST	.CSIN5			; JUMP IF NOT
	HRROI	T1,[ASCIZ\ FACILITIES-DATA (are) \]
	CALL	.SOUT
	SKIPE	FACCNT			; ANY FACILITIES-DATA?
	JRST	.CSIN4			; YES, DISPLAY IT
	HRROI	T1,[ASCIZ\%Nothing\]	; INDICATE NO DEFAULT DATA
	CALL	.SOUTR			; AND PRINT IT
	JRST	.CSIN7			; NO GO ON TO USER-DATA
.CSIN4:	HRRZ	S,FACCNT		; LOAD THE COUNT AND
	MOVE	P1,[POINT 8,FACBLK]	; POINT TO FACILITIES-DATA BLK	
	CALL	.CDPNT			; PRINT DATA
	CALL	OCRLF
	JRST	.CSIN7			; NOW GO DO USER-DATA

.CSIN5:	HRROI	T1,[ASCIZ\ DEFAULT FACILITIES-DATA (are) \]
	CALL	.SOUT
	SKIPE	FACDCT			; ANY FACILITIES-DATA?
	JRST	.CSIN6			; YES, DISPLAY IT
	HRROI	T1,[ASCIZ\%Nothing\]	; INDICATE NO DEFAULT DATA
	CALL	.SOUTR			; AND PRINT IT
	JRST	.CSIN7			; NO GO ON TO USER-DATA
.CSIN6:	HRRZ	S,FACDCT		; LOAD THE COUNT AND
	MOVE	P1,[POINT 8,FACDEF]	; POINT TO DEFAULT FACILITIES-DATA BLK	
	CALL	.CDPNT			; PRINT DATA
	CALL	OCRLF


.CSIN7:	SKIPN	UCDFLG			; HAS THE USER SPECIFIED USER-CALL-DATA
	JRST	.CSIN8			; JUMP IF NOT
	HRROI	T1,[ASCIZ\ USER-DATA (are) \]
	CALL	.SOUT
	HRRZ	S,UCDCNT		; LOAD THE COUNT AND
	MOVE	P1,[POINT 8,UCDBLK]	; THE USER-DATA BLK
	CALL	.CDPNT			; PRINT DATA
	CALL	OCRLF
	RET

.CSIN8:	HRROI	T1,[ASCIZ\ DEFAULT USER-DATA (are) \]
	CALL	.SOUT
	HRRZ	S,UCDDCT		; LOAD THE COUNT AND
	MOVE	P1,[POINT 8,UCDDEF]	; THE DEFAULT USER-DATA BLK
	CALL	.CDPNT			; PRINT DATA
	CALL	OCRLF
	RET
; HERE TO PARSE A FACILITIES-DATA SUBCOMMAND

.CSFAC:	NOISE (are)
	MOVEI	P1,^D63			; GET MAX NUMBER OF DATA BYTES LEGAL
	MOVE	P2,[POINT 8,CDBUF]	; POINT AT THE DEST DATA BUFFER
	CALL	.CDPAR
	  RET				; HMMMM... THE TOAD MISTYPED
	MOVEM	S,FACCNT		; SET THE COUNT OF BYTES IN FACILITIES
					; DATA STRING
	MOVE	P1,[CDBUF,,FACBLK]	; LOAD SOURCE,,DESTINATION
	BLT	P1,FACBLK+17		; AND MOVE THEM
	SETOM	FACFLG			; INDICATE FACILITIES-DATA VIA SUBCMD
	RET
; HERE TO PARSE A USER-DATA SUBCOMMAND

.CSUSD:	NOISE (are)
	MOVEI	P1,^D12			; GET MAX NUMBER OF DATA BYTES LEGAL
	MOVE	P2,[POINT 8,CDBUF]	; POINT AT THE DEST DATA BUFFER
	CALL	.CDPAR
	  RET				; HMMMM... THE TOAD MISTYPED
	ADDI	S,4			; ACCOUNT FOR THE PROTOCOL BYTES
	MOVEM	S,UCDCNT		; SET COUNT OF BYTES IN USER-DATA STRING
	MOVE	S,USRDAT		; GET THE PROTOCOL STRING
	MOVEM	S,UCDBLK		; AND STORE IT
	MOVE	P1,[CDBUF,,UCDBLK+1]	; LOAD SOURCE,,DESTINATION
	BLT	P1,UCDBLK+3		; AND MOVE THEM
	SETOM	UCDFLG			; INDICATE USER-DATA VIA SUBCMD
	RET

.CALL0:	SKIPN	CALLCT			; IS THERE AN OUTSTANDING CALL?
	JRST	.CALL1			; NO, GO PLACE THE CALL
	HRROI	T1,[ASCIZ\?A connection to a Remote DTE already exists\]
	CALL	.SOUTR
	RET
; HERE TO PLACE THE CALL

.CALL1:
	SETOM	CALLCT			; SET THE INTERLOCK
	MOVE	P1,[CH.NET,,PRTBLK]	; FIRST THING IS TO SET UP ISCBLK
	MOVEM	P1,ISCBLK+0		; SET PSI CHANNEL,,POINTER TO PORT BLOCK
	SETZM	ISCBLK+1		; CLEAR RETURN CODE WORD
	MOVE	P1,NETNAM		; GET THE NETWORK NAME
	JUMPN	P1,.CALL2		; WAS A NETWORK ALREADY SPECIFIED?

; GET NETWORK NAME HERE (IF NECESSARY)

	PUSH	P,CMDBLK		; SAVE COMMAND BLOCK REPARSE
	MOVEI	T1,NAMPRS		; FLAGS,,ADDRESS OF REPARSE ROUTINE
	MOVEM	T1,CMDBLK		; UPDATE COMAND BLOCK
	PUSH	P,CMDBLK+2		; SAVE CTRL/R BUFFER
	HRROI	T1,[ASCIZ\Network Name: \]	; CONTROL-R BUFFER
	MOVEM	T1,CMDBLK+2		; NEW CTRL/R BUFFER
	CALL	NAMPRS			; WE MUST RETURN TO HERE TO RESTORE
	POP	P,CMDBLK+2		; RESTORE CTRL/R BUFFER
	POP	P,CMDBLK		; RESTORE REPARSE ADDRESS
	RET

NAMPRS:	MOVEI	T1,CMDBLK		; POINT TO COMMAND BLOCK
	MOVEI	T2,[FLDDB. .CMINI]	; INIT STATE BLOCK
	COMND
	ERCAL	FATAL
	MOVEI	T2,[FLDDB. .CMFLD,CM%SDH,,<network you wish to access (maximum of 16 characters)>]
	COMND
	ERCAL	FATAL
	MOVE	P1,[POINT 7,ATMBUF,6]	; POINT TO THE FIRST CHARACTER
	MOVE	P2,[POINT 7,NETNAM,6]	; POINT TO THE DESTINATION
	SETZ	P3,			; ZERO A CHARACTER COUNTER
	LDB	P4,P1			; GET A CHARACTER
NAMPR1:	CAIE	P4,040			; A SPACE?
	JRST	NAMPR2			; NO, GO ON
	ILDB	P4,P1			; GET ANOTHER CHARACTER
	JRST	NAMPR1			; AND CHECK FOR ANOTHER LEADING SPACE
NAMPR2:	DPB	P4,P2			; STORE IT
	AOS	P3			; COUNT IT
NAMPR3:	ILDB	P4,P1			; GET A CHARACTER
	CAIN	P4,0			; A NUL?
	JRST	NAMEOS			; YES, END OF STRING
	IDPB	P4,P2			; DEPOSIT IT
	AOS	P3			; COUNT IT
	CAIG	P3,^D16			; MORE THAN ^D16 CHARACTERS?
	JRST	NAMPR3			; NO, MOVE ANOTHER CHARACTER
	HRROI	T1,[ASCIZ\?Network name cannot exceed 16 characters\]
	CALL	.SOUTR
	JRST NAMPRS			; TRY AGAIN

NAMEOS:	IDPB	P4,P2			; FINISH OFF STRING
	CONFIRM
	POP	P,CMDBLK		; CLEAR RETURN, SUCCESS
	POP	P,CMDBLK+2		; RESTORE CTRL/R BUFFER
	POP	P,CMDBLK		; RESTORE REPARSE ADDRESS
	JRST	.CALL2			; CONTINUE

.CALL2:
	MOVE	P1,[POINT 7,NETNAM]	; GET A POINTER TO THE NETWORK NAME
	MOVEM	P1,ISCBLK+2		; AND STORE IT
	MOVE	P1,[POINT 7,NETPSW]	; POINT AT NETWORK PASSWORD
	ILDB	P1,P1			; GET THE FIRST CHARACTER
	JUMPN	P1,.CALL3		; WAS A PASSWORD ALREADY SPECIFIED?
	PUSH	P,CMDBLK		; SAVE COMMAND BLOCK REPARSE
	MOVEI	T1,PSWRPR		; FLAGS,,ADDRESS OF REPARSE ROUTINE
	MOVEM	T1,CMDBLK		; UPDATE COMAND BLOCK
	PUSH	P,CMDBLK+2		; SAVE CTRL/R BUFFER
	HRROI	T1,[ASCIZ\Network Password: \]	; CONTROL-R BUFFER
	MOVEM	T1,CMDBLK+2		; NEW CTRL/R BUFFER
	MOVX	T1,.CTTRM		; POINT TO OUT TTY:
	RFMOD
	ERCAL	FATAL
	TXZ	T2,TT%ECO		; TURN OFF ECHO
	SFMOD
	ERCAL	FATAL
PSWPRS:	MOVEI	T1,CMDBLK		; POINT TO COMMAND BLOCK
	MOVEI	T2,[FLDDB. .CMINI]	; INIT STATE BLOCK
	COMND
	ERCAL	FATAL
PSWRPR:	MOVEI	T2,[FLDDB. .CMTXT,CM%SDH,,<network access password (maximum of 16 characters)>,,GENRIC]
	COMND
	ERCAL	FATAL
	HRRZ	T3,T3			; GET WHO PARSED
	CAIN	T3,GENRIC		; CONFIRM?
	JRST	PSWPR5			; YES
	MOVE	P1,[POINT 7,ATMBUF,6]	; POINT TO THE FIRST CHARACTER
	MOVE	P2,[POINT 7,NETPSW,6]	; POINT TO THE DESTINATION
	SETZ	P3,			; ZERO A CHARACTER COUNTER
	LDB	P4,P1			; GET A CHARACTER
PSWPR1:	CAIE	P4,040			; A SPACE?
	JRST	PSWPR2			; NO, GO ON
	ILDB	P4,P1			; GET ANOTHER CHARACTER
	JRST	PSWPR1			; AND CHECK FOR ANOTHER LEADING SPACE
PSWPR2:	DPB	P4,P2			; STORE IT
	AOS	P3			; COUNT IT
PSWPR3:	ILDB	P4,P1			; GET A CHARACTER
	CAIN	P4,0			; A NUL?
	JRST	PSWEOS			; YES, END OF STRING
	IDPB	P4,P2			; DEPOSIT IT
	AOS	P3			; COUNT IT
	CAIG	P3,^D16			; MORE THAN ^D16 CHARACTERS?
	JRST	PSWPR3			; NO, MOVE ANOTHER CHARACTER
	HRROI	T1,[ASCIZ\?Network password cannot exceed 16 characters\]
	CALL	.SOUTR
	JRST	PSWPRS			; TRY AGAIN

PSWPR5:	SETZM	NETPSW			; ZERO THE PASSWORD
	JRST	PSWEOX

PSWEOS:	IDPB	P4,P2			; FINISH OFF STRING
	CONFIRM

PSWEOX:	MOVX	T1,.CTTRM		; POINT TO OUT TTY:
	RFMOD
	ERCAL	FATAL
	TXO	T2,TT%ECO		; TURN ON ECHO
	SFMOD
	ERCAL	FATAL
	CALL	OCRLF
	POP	P,CMDBLK+2		; RESTORE CTRL/R BUFFER
	POP	P,CMDBLK		; RESTORE REPARSE ADDRESS
	JRST	.CALL3			; CONTINUE

.CALL3:
	MOVE	P1,[POINT 7,NETPSW]	; GET A POINTER TO THE PASSWORD
	MOVEM	P1,ISCBLK+3		; AND STORE IT
	MOVE	P1,[POINT 7,DTEADR]	; POINT AT ADDRESS STRING
	MOVE	P2,[POINT 7,DTESTR]	; POINT AT ADDRESS BUFFER
.CAL3A:	ILDB	T1,P1			; GET A BYTE
	JUMPE	T1,.CAL3B		; END OF STRING?
	IDPB	T1,P2			; NO, STORE BYTE
	JRST	.CAL3A			; BACK FOR MORE
.CAL3B:	MOVE	P1,[POINT 7,DTESUB]	; POINT AT SUBADDRESS STRING
.CAL3C:	ILDB	T1,P1			; GET A BYTE
	JUMPE	T1,.CAL3D		; END OF STRING
	IDPB	T1,P2			; NO, STORE BYTE
	JRST	.CAL3C			; BACK FOR MORE
.CAL3D:	IDPB	T1,P2			; FINISH STRING WITH A ZERO BYTE
	MOVE	P1,[POINT 7,DTESTR]	; GET A POINTER TO THE DTE ADDRESS
	MOVEM	P1,ISCBLK+4		; AND STORE IT
	SETZM	ISCBLK+5		; NO SOURCE DTE SUBADDRESS
	SKIPN	CUGFLG			; DID THE USER SET A CLOSED-USER-GROUP
	JRST	.CAL3E			; VIA SUBCMD? JUMP IF NOT
	MOVE	P1,[POINT 7,CUGBLK]	; POINT TO THE CLOSED-USER-GROUP
	ILDB	T1,P1			; GET FIRST CHARACTER
	JUMPE	T1,.CAL3F		; JUMP IF A NULL STRING WAS ENTERED
	MOVE	P1,[POINT 7,CUGBLK]	; POINT AT THE CLOSED-USER-GROUP AGAIN
	MOVEM	P1,ISCBLK+6		; AND STORE IN ISCBLK
	JRST	.CAL3G			; NOW GO PROCESS FACILITIES-DATA

.CAL3E:	MOVE	P1,[POINT 7,CUGDEF]	; POINT TO DEFAULT CLOSED-USER-GROUP
	ILDB	T1,P1			; GET THE FIRST CHARACTER
	JUMPE	T1,.CAL3F		; JUMP IF NO DEFAULT CLOSED-USER-GROUP
	MOVE	P1,[POINT 7,CUGDEF]	; POINT AT DEFAULT CLOSED-USER-GROUP
	MOVEM	P1,ISCBLK+6		; STORE THE POINTER
	JRST	.CAL3G			; NOW GO PROCESS FACILITIES-DATA

.CAL3F:	SETZM	ISCBLK+6		; NO CLOSED-USER-GROUP

.CAL3G:	SKIPN	FACFLG			; DID THE USER SET ANY FACILITIES-DATA
	JRST	.CAL3H			; VIA SUBCMD? JUMP IF NOT
	SKIPN	FACCNT			; ANY FACILITIES-DATA ENTERED VIA SUBCMD
	JRST	.CAL3I			; NO, GO INDICATE NO FACILITIES-DATA
	HRLZ	P1,FACCNT		; GET COUNT
	HRRI	P1,FACBLK		; AND BUFFER
	MOVEM	P1,ISCBLK+7		; AND STORE IT
	JRST	.CAL3J			; NOW GO ON TO CHECK FOR USER-DATA

.CAL3H:	SKIPN	FACDCT			; AND DEFAULT FACILITIES-DATA?
	JRST	.CAL3I			; NO, GO ON
	HRLZ	P1,FACDCT		; GET THE COUNT
	HRRI	P1,FACDEF		; AND THE BUFFER
	MOVEM	P1,ISCBLK+7		; AND STORE IT
	JRST	.CAL3J			; NOW GO CHECK FOR USER DATA

.CAL3I:	SETZM	ISCBLK+7		; NO FACILITIES-DATA

.CAL3J:	SKIPN	UCDFLG			; ANY USER-DATA VIA SUBCMD?
	JRST	.CAL3K			; NO, CHECK FOR DEFAULT DATA
	SKIPN	UCDCNT			; ANY USER-DATA ENTERED VIA SUBCMD
	JRST	.CAL3L			; NO, GO SET UP MANDATORY STRING
	HRLZ	P1,UCDCNT		; GET THE COUNT
	HRRI	P1,UCDBLK		; AND THE BUFFER
	MOVEM	P1,ISCBLK+10		; AND STORE IT
	JRST	.CALL4			; CONTINUE ON

.CAL3K:	SKIPN	UCDDCT			; ANY DEFAULT DATA?
	JRST	.CAL3L			; NO, GO SET UP MANDATORY STRING
	HRLZ	P1,UCDDCT		; GET THE COUNT
	HRRI	P1,UCDDEF		; AND THE BUFFER
	MOVEM	P1,ISCBLK+10		; AND STORE IT
	JRST	.CALL4			; NOW GO ON

.CAL3L:	HRLZI	P1,USRDSZ		; SIZE OF MANDATORY USER DATA
	HRRI	P1,USRDAT		; ADDR OF MANDATORY USER DATA
	MOVEM	P1,ISCBLK+10		; AND STORE IT
.CALL4:
	HRROI	T1,[ASCIZ\ BREAK-CHARACTER (is) \]
	CALL	.SOUT
	MOVE	T2,BRKCHR		; GET BREAK CHARACTER
	CAIG	T2,177			; 
	CAIGE	T2,1			; BETWEEN 1 AND 177?
	JRST	.CAL4C			; NO, SIGH
	CAIE	T2,40			; A SPACE?
	JRST	.CAL4A			; NO
	HRROI	T1,[ASCIZ\A SPACE\]
	CALL	.SOUT
	JRST	.CAL4D
.CAL4A:	CAILE	T2,37			; A CONTROL CHARACTER?
	JRST	.CAL4B			; NO
	HRROI	T1,[ASCIZ\CONTROL-\]
	CALL	.SOUT
	ADDI	T2,100			; CONVERT TO A PRINTABLE CHARACTER
.CAL4B:	CALL	.BOUT
	JRST	.CAL4D
.CAL4C:	HRROI	T1,[ASCIZ\DISABLED\]
	CALL	.SOUT
.CAL4D:	CALL	OCRLF			; FINISH LINE
	HRROI	T1,[ASCIZ\ ESCAPE-CHARACTER (is) \]
	CALL	.SOUT
	MOVE	T2,ESCCHR		; GET ESCAPE CHARACTER
	CAIG	T2,177			; 
	CAIGE	T2,1			; BETWEEN 1 AND 177?
	JRST	.CAL4G			; NO, SIGH
	CAIE	T2,40			; A SPACE?
	JRST	.CAL4E			; NO
	HRROI	T1,[ASCIZ\A SPACE\]
	CALL	.SOUT
	JRST	.CAL4H
.CAL4E:	CAILE	T2,37			; A CONTROL CHARACTER?
	JRST	.CAL4F			; NO
	HRROI	T1,[ASCIZ\CONTROL-\]
	CALL	.SOUT
	ADDI	T2,100			; CONVERT TO A PRINTABLE CHARACTER
.CAL4F:	CALL	.BOUT
	JRST	.CAL4H
.CAL4G:	HRROI	T1,[ASCIZ\DISABLED\]
	CALL	.SOUT
.CAL4H:	CALL	.SOUTR
	HRROI	T1,[ASCIZ\ Calling Remote DTE \]
	CALL	.SOUT
	HRROI	T1,DTEADR
	CALL	.SOUT
	MOVE	T1,[POINT 7,DTESUB,6]	; POINT TO FIRST BYTE OF THE SUBADDRESS
	LDB	T1,T1			; GET IT
	JUMPE	T1,.CAL4I		; NO SUBADDRESS
	HRROI	T1,[ASCIZ\ (\]
	CALL	.SOUT
	HRROI	T1,DTESUB		; POINT TO SUBADDRESS
	CALL	.SOUT
	HRROI	T1,[ASCIZ\)\]
	CALL	.SOUT
.CAL4I:	MOVEI	T1,ISCBLK		; LOAD POINTER TO ARGUMENT BLOCK
	CALL	X%ISC##			; AND INITIATE A SWITCHED CIRCUIT
	HRRZ	P1,ISCBLK		; GET RETURNED PORT NUMBER
	MOVEM	P1,PORTNO		; AND SAVE IT FOR FUTURE USE
	MOVE	P1,ISCBLK+1		; GET THE RETURN CODE
	CAIN	P1,XC%SUC		; SUCCESS?
	JRST	.CALL5			; YES CONTINUE
	MOVEM	P1,LASTNE		; NO, SAVE THE ERROR
	HRROI	T1,[ASCIZ\ [FAILED]\]
	CALL	.SOUTR
	CALL	NETERR			; CALL ERROR ROUTINE
	SETZM	CALLCT			; CLEAR THE CALL INTERLOCK
	RET				; AND RETURN



.CALL5:	MOVEI	T1,^D500		; SET UP TO WAIT 1/2 A SECOND
	DISMS				; AND DISMISS
	HRRZ	P1,PORTNO		; GET THE PORT NUMBER
	MOVEM	P1,RPSBLK		; AND STORE IT
	SETZM	RPSBLK+1		; ZERO THE STATUS RETURN WORD
	SETZM	RPSBLK+2		; ZERO THE ERROR CONDITION,,PORT STATE
	SETZM	RPSBLK+3		; ZERO THE INTERRUPT/BIT MASK
	MOVEI	T1,RPSBLK		; POINT TO THE ARGUMENT BLOCK
	CALL	X%RPS##			; AND READ THE PORT STATUS
	MOVE	P1,RPSBLK+1		; GET THE RETURNED STATUS
	CAIN	P1,XC%SUC		; SUCCESSFUL RETURN?
	JRST	.CALL6			; YES, GO ON
	MOVEM	P1,LASTNE		; SAVE THE ERROR CODES
	HRROI	T1,[ASCIZ\ [FAILED]\]
	CALL	.SOUTR
	CALL	NETERR			; AND REPORT THE ERROR
	SETZM	CALLCT			; CLEAR THE INTERLOCK
	RET

.CALL6:	HRRZ	P1,RPSBLK+2		; GET THE PORT STATE
	CAIN	P1,XS%CAG		; STILL CALLING?
	JRST	.CALL5			; YES, WAIT SOME MORE
	CAIN	P1,XS%RUN		; RUNNING?
	JRST	.CALL8			; YES, GO ON
	CAIN	P1,XS%ERR		; ERROR?
	JRST	.CAL7H			; YES...GO REPORT THE PROBLEM
	CAIN	P1,XS%CLD		; CLEARED?
	JRST	.CALL7			; YES...REJECTION
.CAL6A:	HRROI	T1,[ASCIZ\ [FAILED]\]
	CALL	.SOUTR
	HRROI	T1,[ASCIZ\?The port entered an illegal state while waiting for call completion\]
	CALL	.SOUTR
	HRROI	T1,[ASCIZ\ Current Port State is \]
	CALL	.SOUT
	MOVE	T1,PORTST(P1)		; POINT TO PORT STATE
	CALL	.SOUTR
	SETZM	CALLCT			; CLEAR THE INTERLOCK
	RET

.CALL7:	HRRZ	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,RCDBLK		; STORE IT
	SETZM	RCDBLK+1		; CLEAR THE RETURN CODE
	SETZM	RCDBLK+2		; CLEAR THE CAUSE BYTES
	MOVE	T1,[POINT 7,CUGBLK]
	MOVEM	T1,RCDBLK+3		; STORE IT
	MOVE	T1,[ ^D63,,FACBLK ]	; POINT TO FACILITIES BLOCK
	MOVEM	T1,RCDBLK+4		; STORE IT
	MOVE	T1,[ ^D16,,CLDBLK ]	; POINT TO CLEAR DATA BLOCK
	MOVEM	T1,RCDBLK+5
	MOVEI	T1,RCDBLK		; POINT AT ARG BLOCK
	CALL	X%RCD##
	HRRZ	T1,RCDBLK+1		; GET RETURN CODE
	TXNN	T1,<0,,-1>-XC%NDA	; SUCCESS?
	JRST	.CAL7A			; YES, GO ON
	MOVEM	T1,LASTNE		; SAVE THE ERROR CODES
	HRROI	T1,[ASCIZ\ [FAILED]\]
	CALL	.SOUTR
	CALL	NETERR			; AND REPORT THE ERROR
	CALL	NETTRM			; TERMINATE THE PORT
	SETZM	CALLCT			; CLEAR THE INTERLOCK
	RET

.CAL7A:
	HLRZ	T1,RCDBLK+2		; GET NETWORK CLEAR CODE
	JUMPN	T1,.CAL7B		; JUMP IF THE NETWORK DID THE CLEARING
	HRROI	T1,[ASCIZ\ [FAILED]\]	; HMMMM, THE REMOTE HOST DID THIS
	CALL	.SOUTR
	HRROI	T1,[ASCIZ\?The remote host has refused connection\]
	CALL	.SOUTR
	HRROI	T1,[ASCIZ\ User clear diagnostic #\]
	CALL	.SOUT
	HRRZ	T2,RCDBLK+2		; GET THE USER DIAGNOSTIC CODE
	MOVEI	T3,^D10			; PRINT IT IN DECIMAL
	CALL	.NOUT
	CALL	ERROR
	CALL	OCRLF
	CALL	.ACCNT			; LOG THE CALL
	CALL	NETTRM
	SETZM	CALLCT			; CLEAR THE INTERLOCK
	RET

.CAL7B:	MOVEI	T2,CCAUSE		; POINT TO THE CAUSE TABLE
.CAL7C:	HLRZ	T3,(T2)			; GET DIAG VALUE FROM TABLE
	CAMN	T1,T3			; IS THIS THE CAUSE OF THE CLEAR?
	JRST	.CAL7D			; YES, GO PRINT REASON
	JUMPE	T3,.CAL7E		; JUMP IF AT END OF TABLE
	AOJA	T2,.CAL7C		; INCREMENT TABLE POINTER AND TRY AGAIN

.CAL7D:	HRROI	T1,[ASCIZ\ [FAILED]\]
	CALL	.SOUTR
	HRRO	T1,(T2)			; BUILD POINTER TO STRING
	CALL	.SOUTR			; AND PRINT IT
	HRROI	T1,[ASCIZ\ Network clear code #\]
	CALL	.SOUT
	HLRZ	T2,RCDBLK+2		; GET CLEAR CODE (AGAIN)
	MOVEI	T3,^D10			; PRINT IT IN DECIMAL
	CALL	.NOUT
	CALL	ERROR
	HRROI	T1,[ASCIZ\, diagnostic code #\]
	CALL	.SOUT
	HRRZ	T2,RCDBLK+2		; GET THE DIAGNOSTIC CODE
	MOVEI	T3,^D10			; PRINT IT IN DECIMAL
	CALL	.NOUT
	CALL	ERROR
	CALL	OCRLF
	JRST	.CAL7F			; GO CLEAN UP

.CAL7E:	HRROI	T1,[ASCIZ\ [FAILED]\]
	CALL	.SOUTR
	HRROI	T1,[ASCIZ\?Call not completed - Unknown clear code #\]
	CALL	.SOUT
	HLRZ	T2,RCDBLK+2		; GET CLEAR CODE (AGAIN)
	MOVEI	T3,^D10			; PRINT IT IN DECIMAL
	CALL	.NOUT
	CALL	ERROR
	HRROI	T1,[ASCIZ\, diagnostic code #\]
	CALL	.SOUT
	HRRZ	T2,RCDBLK+2		; GET THE DIAGNOSTIC CODE
	MOVEI	T3,^D10			; PRINT IT IN DECIMAL
	CALL	.NOUT
	CALL	ERROR
	CALL	OCRLF

.CAL7F:	CALL	NETTRM
	SETZM	CALLCT			; CLEAR THE INTERLOCK
	RET


.CAL7H:
	MOVE	T1,RPSBLK+2		; GET THE ERROR BITS
	TXNN	T1,XE%NCM		; IS THE PPSN UP AND TALKING?
	JRST	.CAL6A			; HMMM, PROBABLY...JUST REPORT THE ERROR
	HRROI	T1,[ASCIZ\ [FAILED]\]
	CALL	.SOUTR
	HRROI	T1,[ASCIZ\?The public data network is not running\]
	CALL	.SOUTR
	JRST	.CAL7F			; NOW CLEAN-UP AND RETURN
; HERE TO ADD A RECORD TO THE ACCOUNTING LOG INDICATING DATE, TIME, USER,
; DTE ADDRESS, AND SUCCESS (OR FAILURE)

.ACCNT:
	PUSH	P,T1
	PUSH	P,T2
	PUSH	P,T3
	PUSH	P,T4
	SETO	T1,			; THIS JOB
	HRROI	T2,.TDEFS		; PLACE TO SAVE TTY #
	MOVX	T3,.JITNO		; WE WANT TTY #
	GETJI
	ERJMP	ERROR			; SHOULD NEVER HAPPEN
	HRROI	T2,.TDEFS+1		; PLACE TO SAVE DIR #
	MOVX	T3,.JILNO		; WE WANT LOGED IN DIR #
	GETJI
	ERJMP	ERROR			; SHOULD NEVER HAPPEN
	HRROI	T1,.TDEFS+1		; STORE THE STRING @.TDEFS+1
	MOVE	T2,.TDEFS+1		; GET DIR #
	DIRST
	ERJMP	ERROR			; SHOULD NEVER HAPPEN
	MOVE	T2,[440700,,.TDEFS+1]	; STRING POINT TO DIRECTORY
	MOVE	T2			; COPY IT TO ZERO
.ACCN1:	ILDB	T3,T2			; GET BYTE
	CAIE	T3,"<"			; IS IT A <
	JUMPN	T3,.ACCN1		; NO, TRY NEXT
	SKIPE	T3
.ACCN2:	ILDB	T3,T2			; GET NEXT BYTE
	IDPB	T3,			; SAVE THIS BYTE
	CAIE	T3,">"			; IS IT A >
	JUMPN	T3,.ACCN2
	SETZ	T3,
	DPB	T3,			; TERMINATE STRING HERE
	MOVX	T1,GJ%SHT		; SHORT FORM
	HRROI	T2,[ASCIZ\PS:<SYSTEM>X29PAD-ACCOUNTING.ACT\] ; PNTR TO FILE NAME
	GTJFN
	JRST	.ACCN5			; IF NO FILE EXISTS NO LOGGING IS DONE
	PUSH	P,T1			; SAVE JFN ON STACK
.ACCN3:	MOVE	T1,(P)			; GET JFN
	MOVE	T2,[FLD(7,OF%BSZ)!OF%APP] ; OPENF FLAGS
	OPENF
	JRST	.ACCN3			; LOOP UNTIL FILE IS AVAILIBLE
	SETO	T2,			; CURRENT DATE AND TIME
	SETZ	T3,
	ODTIM
	MOVEI	T2," "			; SPACE
	BOUT
	MOVE	T2,[440700,,.TDEFS+1]	; STRING POINT TO DIRECTORY
	SOUT
	HRROI	T2,[ASCIZ\ (on) \]
	SOUT
	HRROI	T2,[ASCIZ\TTY\]
	SKIPGE	.TDEFS			; IS JOB DETACHED?
	HRROI	T2,[ASCIZ\DET\]		; YES
	SOUT
	MOVE	T2,.TDEFS		; GET TTY #
	MOVEI	T3,10			; OUTPUT OCTAL
	SKIPL	T2			; DONT OUTPUT NEGATIVE NUMBER
	NOUT
	SKIP				; IGNORE ERROR RETURN
	HRROI	T2,[ASCIZ\ CALLED DTE \]
	SOUT
	MOVE	T1,(P)			; OUTPUT JFN
	HRROI	T2,DTEADR		; ADRESS OF DTE
	SETZ	T3,
	SOUT
	LDB	[POINT 7,DTESUB,6]	; GET SUB ADRESS
	JUMPE	.ACCN4			; JUMP AROUND IF ALL DONE
	HRROI	T2,[ASCIZ\ (\]
	SOUT
	HRROI	T2,DTESUB		; POINT TO SUB STRING
	SOUT
	MOVEI	T2,")"
	BOUT
.ACCN4:	HRROI	T2,CRLF			; POINT TO CRLF
	SOUT
	POP	P,T1			; GET THE OUTPUT JFN
	CLOSF
	ERJMP	ERROR			; SHOULD NEVER HAPPEN
.ACCN5:	POP	P,T4
	POP	P,T3
	POP	P,T2
	POP	P,T1
	RET				; AND RETURN
; IF WE GOT HERE THEN THE SWITCHED CIRCUIT IS RUNNING

.CALL8:	HRROI	T1,[ASCIZ\ [OK]\]	; TELL THE USER THE CALL WENT THROUGH
	CALL	.SOUTR
	CALL	.ACCNT			; LOG THE CALL
	SETOM	RADFLG			; NOTE THAT WE HAVE TO CALL X%RAD
	MOVE	T1,INIPTR		; GET THE INITIAL TTY INPUT POINTER
	MOVEM	T1,TTIPTR		; AND STORE IT
	SETZM	TTICNT			; ZERO THE TTIBUF CHAR COUNT

; HERE TO (RE)START COMMUNICATIONS ON THE CIRCUIT TO THE REMOTE-HOST

.CAL8A:
	MOVEI	T1,.CTTRM		; POINT TO THE CONTROLING TERMINAL
	RFCOC				; READ CCOC WORDS
	MOVEM	T2,OCCOC		; SAVE AWAY THE ORIGINAL WORD #1
	MOVEM	T3,OCCOC+1		; AND ORIGINAL WORD #2
	MOVE	T2,[525252,,525252]	; MAKE UP NEW CCOC WORDS TO MAKE ALL
	MOVE	T3,T2			; CONTROL CHARACTERS GIVE THEIR CODE
	SFCOC
	MOVEI	T1,.PRIIN		; READ MODE WORD
	RFMOD
	MOVEM	T2,OMODE		; SAVE AWAY THE ORIGINAL MODE WORD
	TDZ	T2,[37777,,4020]	; ZERO PAGE LENGTH, WIDTH; NO ECHO
	TDO	T2,[200000,,300]	; TURN ON FORMF, NO-TRANS-OUTP BITS
	SFMOD
	STPAR
	MOVEI	T1,-5			; ENABLE TTY INTERUPTS FOR JOB
	RTIW				; READ THE TERMINAL INTERRUPT WORD
	ERCAL	FATAL
	MOVEM	T2,OTIW			; AND SAVE IT
	MOVX	T2,1B<.TICTI>		; AND NOW SET IT FOR TYPE IN
	STIW
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	MOVE	T1,[.TICTI,,CH.TTY]	; ACTIVATE TTY's CHANNEL
	ATI
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	MOVX	T1,.FHSLF		; CAUSE A INTERUPT
	MOVX	T2,CH%TTY		; ON TTY's CHANNEL
	AIC
	ERCAL	FATAL
	IIC				; CAUSE AN INTERRUPT
	MOVX	T2,CH%TMR		; ACTIVATE TIMER's CHANNEL
	AIC
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	IIC				; CAUSE A INTERUPT
	MOVX	T2,CH%NET		; ACTIVATE NET's CHANNEL
	AIC
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	IIC				; CAUSE A INTERUPT
	SKIPE	SNDFLG			; SENDING A FILE?
	JRST	SNDDAT			; YES, GO SEND THE DATA

	HRLZI	T1,400			; DISMIS FOR MAXIMUM
	DISMS
	JRST	.-2			; GOOD RUN TIME FOR THIS SYSTEM

.CALL9:					; HERE WHEN CONTROL IT RETURNED TO US
	MOVEI	T1,-5			; NOW PUT THE TERMINAL BACK TO ITS
	MOVE	T2,OTIW			; ORIGINAL STATE
	STIW				; SET THE INTERRUPT WORD
	ERCAL	FATAL
	MOVEI	T1,.CTTRM		; POINT AT CONTROLLING TERMINAL
	MOVE	T2,OCCOC		; GET ORIGINAL CCOC WORD #1
	MOVE	T3,OCCOC+1		; GET ORIGINAL CCOC WORD #2
	SFCOC				; AND SET THEM
	ERCAL	FATAL
	MOVEI	T1,.PRIIN		; 
	MOVE	T2,OMODE		; GET THE ORIGINAL MODE WORD
	SFMOD
	ERCAL	FATAL
	STPAR
	ERCAL	FATAL
	RET				; NOW RETURN TO PARSE MORE COMMANDS
; HERE TO HANDLE NETWORK INTERRUPTS


$NETIN:
	MOVEM	P,NETACS+17		; LETS SAVE THE ACS
	MOVEI	P,NETACS		; OF WHATEVER PROCESS WE INTERRUPTED
	BLT	P,NETACS+16		; 
	MOVE	P,[IOWD NTPLEN,NETPDL]	; USE OUR OWN STACK
	HRRZ	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,RPSBLK		; AND STORE IT
	SETZM	RPSBLK+1		; ZERO STATUS RETURN WORD
	SETZM	RPSBLK+2		; ZERO ERROR CONDITION,,PORT STATE
	SETZM	RPSBLK+3		; ZERO THE INTERRUPT/BIT MASK
	MOVEI	T1,RPSBLK		; POINT TO THE ARG BLOCK
	CALL	X%RPS##			; AND READ THE PORT STATUS
	MOVE	T1,RPSBLK+1		; GET THE RETURN CODE
	CAIN	T1,XC%SUC		; SUCCESSFUL RETURN?
	JRST	$NETI1			; YES, GO ON

$NETI0:	MOVEM	T1,LASTNE		; SAVE THE ERROR CODES
	CALL	NETERR			; AND REPORT THE ERROR
	MOVX	T1,.FHSLF		; NO, ERROR...POINT AT OURSELF
	MOVX	T2,CH%TTY		; POINT AT THE TTY CHANNEL
	DIC				; AND DISABLE HIM
	ERCAL	FATAL
	MOVX	T2,CH%TMR		; NOW THE TIMER CHANNEL
	DIC
	ERCAL	FATAL
	MOVX	T2,CH%NET		; AND THE NETWORK CHANNEL
	DIC
	ERCAL	FATAL
	HRROI	T1,[ASCIZ\?Aborting the call and clearing the circuit\]
	CALL	.SOUTR
	CALL	NETTRM			; TERMINATE PORT ACCESS
	MOVEI	T1,.CALL9		; GET RETURN ADDRESS
	MOVEM	T1,@LEVTAB+LV.NET-1	; STORE IT FOR DEBRK TO FIND
	JRST	$NETI3			; AND DISMISS

$NETI1:	HRRZ	T1,RPSBLK+2		; GET THE STATE OF THE PORT
	CAIN	T1,XS%RUN		; STILL RUNNING?
	JRST	$NETI2			; YES, CONTINUE
	CAIN	T1,XS%SYN		; SYNCHING?
	JRST	$NETI3			; YES, JUST DISMISS FOR NOW...
	CAIN	T1,XS%UNS		; UNSYNCH? (HAS THE NET BEEN RESET?)
	JRST	$NRES			; YES, GO ISSUE A RESET AND DISMISS
	MOVX	T1,.FHSLF		; NO, ERROR...POINT AT OURSELF
	MOVX	T2,CH%TTY		; POINT AT THE TTY CHANNEL
	DIC				; AND DISABLE HIM
	ERCAL	FATAL
	MOVX	T2,CH%TMR		; NOW THE TIMER CHANNEL
	DIC
	ERCAL	FATAL
	MOVX	T2,CH%NET		; AND THE NETWORK CHANNEL
	DIC
	ERCAL	FATAL
	HRROI	T1,[ASCIZ\?The PORT is not RUNNING! The current PORT state is \]
	CALL	.SOUT
	HRRZ	T1,RPSBLK+2		; GET THE PORT STATE
	MOVE	T1,PORTST(T1)		; GET THE POINTER TO THE STRING
	CALL	.SOUTR
	HRROI	T1,[ASCIZ\?Aborting and clearing the circuit!\]
	CALL	.SOUTR
	CALL	NETTRM			; TERMINATE PORT ACCESS
	MOVEI	T1,.CALL9		; GET RETURN ADDRESS
	MOVEM	T1,@LEVTAB+LV.NET-1	; STORE IT FOR DEBRK TO FIND
	JRST	$NETI3			; AND DISMISS
	
$NETI2:	MOVE	T1,RPSBLK+3		; GET PORT BITS
	TXNE	T1,XM%IIC		; INCOMING INTERRUPT CONFIRM?
	CALL	$NIIC			; YES, PROCESS IT
	TXNE	T1,XM%OIC		; OUTGOING INTERRUPT CONFIRM?
	CALL	$NOIC			; YES, PROCESS IT
	TXNE	T1,XM%DAT		; INCOMING DATA?
	CALL	$NDAT			; YES, PROCESS IT
	TXNE	T1,XM%INT		; INCOMING INTERRUPT DATA?
	CALL	$NINT			; YES, PROCESS IT

$NETI3:	MOVSI	P,NETACS		; RESTORE ALL OF THE ACS
	BLT	P,P
	DEBRK
	ERCAL	FATAL


IICCNT:	BLOCK	1
OICCNT:	BLOCK	1
DATCNT:	BLOCK	1
INTCNT:	BLOCK	1
; HERE TO ACKNOWLEDGE A NETWORK RESET

$NRES:
	HRRZ	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,RVCBLK		; STORE IT
	SETZM	RVCBLK+1		; CLEAR THE RETURN CODE
	SETZM	RVCBLK+2		; CLEAR THE DIAG DATA BYTE
	MOVEI	T1,RVCBLK		; POINT TO THE ARG BLOCK
	CALL	X%RVC##
	HRRZ	T1,RVCBLK+1		; GET THE RETURN CODE
	CAIN	T1,XC%SUC		; SUCCESS???
	JRST	$NETI3			; YES, JUST DISMISS
	JRST	$NETI0			; NO, GO ABORT THE CIRCUIT
; HERE TO PROCESS AN INCOMING INTERRUPT CONFIRM

$NIIC:
	AOS	IICCNT
	RET
; HERE TO PROCESS AN OUTGOING INTERRUPT CONFIRM

$NOIC:
	AOS	OICCNT
	RET
; HERE TO PROCESS INCOMING DATA

$NDAT:
	PUSH	P,T1
	PUSH	P,T2
	PUSH	P,T3
	PUSH	P,T4
	MOVE	T1,5			; LOAD T1 WITH 5
	MOVEM	T1,NCOUNT		; AND SET THE NUMBER OF MSGS WE'LL READ
					; BEFORE WE CHECK FOR TTY INTERRUPTS

$NDAT0:	SKIPE	RADFLG			; HAVE WE'VE DONE A CALL TO X%RAD
	CALL	$NRAD			; NO, GO DO ONE
	HRRZ	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,RDMBLK		; STORE IT
	SETZM	RDMBLK+1		; ZERO THE STATUS RETURN WORD
	MOVEI	T1,RCVSIZ		; GET THE RECEIVE BUFFER SIZE
	MOVEM	T1,RDMBLK+2		; STORE IT
	MOVE	T1,[POINT 8,RCVBUF]	; GET BYTE POINTER TO RECEIVER BUFFER
	MOVEM	T1,RDMBLK+3		; STORE IT
	MOVEI	T1,RDMBLK		; POINT TO THE ARG BLOCK
	CALL	X%RDM##			; AND READ DATA MESSAGE
	HRRZ	T1,RDMBLK+1		; GET RETURN STATUS
	TXNN	T1,<0,,-1>-XC%NDA	; SUCCESS?
	JRST	$NDAT1			; YES, CONTINUE
	MOVEM	T1,LASTNE		; SAVE THE ERROR STATE
	MOVX	T1,.FHSLF		; NO, ERROR...POINT AT OURSELF
	MOVX	T2,CH%TTY		; POINT AT THE TTY CHANNEL
	DIC				; AND DISABLE HIM
	ERCAL	FATAL
	MOVX	T2,CH%TMR		; NOW THE TIMER CHANNEL
	DIC
	ERCAL	FATAL
	MOVX	T2,CH%NET		; AND THE NETWORK CHANNEL
	DIC
	ERCAL	FATAL
	CALL	NETERR			; DISPLAY THE ERROR
	HRROI	T1,[ASCIZ\?Aborting and clearing the circuit!\]
	CALL	.SOUTR
	CALL	NETTRM			; TERMINATE PORT ACCESS
	MOVEI	T1,.CALL9		; GET RETURN ADDRESS
	MOVEM	T1,@LEVTAB+LV.NET-1	; STORE IT FOR DEBRK TO FIND
	JRST	$NETI3			; AND DISMISS

$NDAT1:	TXNE	T1,XC%NDA		; ANY DATA?
	JRST	$NDAT6			; NO MORE, EXIT
	AOS	RCVPKT			; INCREMENT THE PACKET COUNT
	HRRZ	T1,RDMBLK+2		; GET THE NUMBER OF BYTES RECEIVED
	JUMPE	T1,$NDAT5		; IF ZERO BYTE COUNT, GO TRY NEXT MSG
	ADDM	T1,RCVCHR		; AND ADD TO THE TOTAL COUNT
	MOVE	T2,RDMBLK+2		; GET FLAGS,,COUNT
	TXNE	T2,XM%QUA		; QUALIFIED DATA?
	JRST	$NQDT			; YES, GO PROCESS IT
	HRRZ	T2,PAD.8		; GET DISPOSITION OF OUTPUT PARAMETER
	TXNE	T2,P08%DO		; DISCARD OUTPUT?
	JRST	$NDAT5			; YES...
	MOVE	T2,[POINT 8,RCVBUF]	; POINTER TO RECEIVED DATA
	MOVE	T3,[POINT 7,TTOBUF]	; POINTER TO TTY OUTPUT BUFFER
$NDAT2:	ILDB	T4,T2			; GET A BYTE
	IDPB	T4,T3			; PUT A BYTE
	CAIE	T4,215			; IS THIS A <CR>
	CAIN	T4,015			; (ALTERNATE VALUE FOR <CR>)
	CALL	[	HRRZ	T4,PAD.13	; GET LINEFEED-INSERTION VALUE
			TXNN	T4,P13%TD	; DO LINEFEED-INSERTION?
			RET			; NO, JUST RETURN
			MOVEI	T4,012		; LOAD A <LF>
			IDPB	T4,T3		; STORE IT IN THE OUTPUT BUFFER
			AOS	RDMBLK+2	; ACCOUNT FOR NEW CHARACTER
			RET	]		; AND RETURN
	SOJG	T1,$NDAT2		; DECREMENT COUNT AND JUMP IF MORE DATA
	SETZ	T4,			; CREATE A ZERO BYTE
	IDPB	T4,T3			; AND FINISH BUFFER WITH A NULL CHAR
	MOVE	T1,OUTJFN		; POINT TO THE OUTPUT DEVICE
	MOVE	T2,[POINT 7,TTOBUF]	; POINT AT OUTPUT STRING
	HRRZ	T3,RDMBLK+2		; GET THE COUNT
	MOVN	T3,T3			; NEGATE IT
	SOUT				; AND PRINT IT
	SKIPN	LOGJFN			; ARE WE LOGGING
	JRST	$NDAT5			; NO, GO BACK FOR ANOTHER DATA MSG
	HRRZ	T3,RDMBLK+2		; GET THE COUNT
	SKIPN	L.SUPP			; ARE WE STRIPPING NULLS?
	JRST	$NDAT4			; NO, GO PRINT IT
	MOVE	T1,[POINT 7,TTOBUF]	; YES, POINT TO OUTPUT STRING
	MOVE	T2,T1			; COPY IT TO T2
$NDAT3:	ILDB	T4,T1			; GET BYTE
	SKIPE	T4			; IF NUL, SKIP
	IDPB	T4,T2			; SAVE BYTE
	SOJG	T3,$NDAT3		; LOOP THROUGH ALL
	IDPB	T3,T2			; SAVE NULL TERMINATION BYTE
$NDAT4:	MOVE	T1,LOGJFN		; GET LOG JFN
	MOVE	T2,[POINT 7,TTOBUF]	; POINT AT OUTPUT STRING
	MOVN	T3,T3			; NEGATE COUNT
	CALL	LSOUT			; GO OUTPUT TO LOG
	JRST	$NDAT5			; NOW GO BACK FOR ANOTHER DATA MSG

; HERE TO DECIDE WHETHER TO GO BACK FOR MORE NETWORK DATA OR TO DISMISS
; AND GIVE THE TTY CHANNEL A CHANCE

$NDAT5:
	SOSLE	NCOUNT			; DECREMENT MSG COUNT
	JRST	$NDAT0			; NOT ZERO SO DON'T CHECK TTY CHANNEL
	MOVEI	T1,^D10			; COUNT 10 MSGS BEFORE WE CHECK AGAIN
	MOVEM	T1,NCOUNT		; AND STORE THE COUNT
	MOVX	T1,.FHSLF		; POINT AT OURSELF
	RWM				; GET PENDING INTERRUPTS
	ERCAL	FATAL
	TXNN	T1,CH%TTY		; IS THERE AN INTERRUPT PENDING ON TTY?
	JRST	$NDAT0			; NO, GO BACK FOR ANOTHER DATA MSG
	MOVX	T1,.FHSLF		; POINT AT OURSELF
	MOVX	T2,CH%NET		; INDICATE THE NETWORK CHANNEL
	IIC				; AND CAUSE AN INTERRUPT FOR LATER
	ERCAL	FATAL

$NDAT6:					; AND GO AWAY TILL NEXT INTERRUPT
	POP	P,T4
	POP	P,T3
	POP	P,T2
	POP	P,T1
	RET
; HERE TO DO A READ ACCEPT DATA

$NRAD:
	PUSH	P,T1
	PUSH	P,T2
	PUSH	P,T3
	PUSH	P,T4
	SETZM	RADFLG			; SAY THAT WE'VE BEEN HERE ONCE
	HRRZ	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,RADBLK		; STORE IT
	SETZM	RADBLK+1		; ZERO THE RETURN STATUS
	MOVE	T1,[POINT 7,CUSGRP]	; POINT TO CLOSED USER GROUP DATA BUFFER
	MOVEM	T1,RADBLK+2		; STORE IT
	MOVE	T1,[^D63,,FACBLK]	; SIZE,,ADDR OF FACILITIES DATA BUFFER
	MOVEM	T1,RADBLK+3
	MOVE	T1,[^D16,,ACDBLK]	; SIZE,,ADDR OF CALL ACCEPT DATA
	MOVEM	T1,RADBLK+4
	MOVEI	T1,RADBLK		; POINT TO ARG BLOCK
	CALL	X%RAD##			; AND READ CALL ACCEPT DATA
	HRRZ	T1,RADBLK+1		; GET THE RETURN STATUS
	TXNN	T1,<0,,-1>-XC%NDA	; SUCCESS?
	JRST	$NRAD1			; YES, CONTINUE
	MOVEM	T1,LASTNE		; SAVE THE ERROR STATE
	MOVX	T1,.FHSLF		; NO, ERROR...POINT AT OURSELF
	MOVX	T2,CH%TTY		; POINT AT THE TTY CHANNEL
	DIC				; AND DISABLE HIM
	ERCAL	FATAL
	MOVX	T2,CH%TMR		; NOW THE TIMER CHANNEL
	DIC
	ERCAL	FATAL
	MOVX	T2,CH%NET		; AND THE NETWORK CHANNEL
	DIC
	ERCAL	FATAL
	CALL	NETERR			; DISPLAY THE ERROR
	HRROI	T1,[ASCIZ\?Aborting and clearing the circuit!\]
	CALL	.SOUTR
	CALL	NETTRM			; TERMINATE PORT ACCESS
	MOVEI	T1,.CALL9		; GET RETURN ADDRESS
	MOVEM	T1,@LEVTAB+LV.NET-1	; STORE IT FOR DEBRK TO FIND
	JRST	$NETI3			; AND DISMISS

$NRAD1:	TXNE	T1,XC%NDA		; ANY DATA?
	JRST	$NRAD2			; NO, JUST RETURN
	HLRZ	T1,RADBLK+3		; GET FACILITIES DATA COUNT
	MOVEM	T1,FACCNT		; SAVE IT
	ADDM	T1,RCVCHR
	HLRZ	T1,RADBLK+4		; GET THE CALL ACCEPT DATA COUNT
	MOVEM	T1,ACDCNT		; SAVE IT
	ADDM	T1,RCVCHR
	AOS	RCVPKT
$NRAD2:	POP	P,T4
	POP	P,T3
	POP	P,T2
	POP	P,T1
	RET
; HERE TO PROCESS INCOMING INTERRUPT DATA

$NINT:
	AOS	INTCNT
	RET
; HERE TO PROCESS QUALIFIED DATA

$NQDT:
	PUSH	P,T1
	PUSH	P,T2
	PUSH	P,T3
	PUSH	P,T4
	MOVE	T1,[POINT 8,RCVBUF]	; POINTER TO DATA IN THE RECEIVE BUFFER
	ILDB	T2,T1			; GET THE FIRST BYTE
	TRZE	T2,370			; MASK OFF ALL BUT THE MESSAGE TYPE
	JFCL				; IGNORE ANY EXTRANIOUS BITS
	AOS	PADFCT(T2)		; INCREMENT TYPE FOR TRACE PURPOSES
	CALL	@PADFCN(T2)		; AND GO PROCESS THE MESSAGE
	POP	P,T4
	POP	P,T3
	POP	P,T2
	POP	P,T1
	JRST	$NDAT5

PADFCN:	EXP	PADPIM			; PARAMETER INDICATION
	EXP	PADICM			; INVITATION TO CLEAR
	EXP	PADSPM			; SET PARAMETERS
	EXP	PADIBM			; INDICATION OF BREAK
	EXP	PADRPM			; READ PARAMETERS
	EXP	PADERM			; ERROR MESSAGE
	EXP	PADSRM			; SET AND READ PARAMETERS
	EXP	PADILL			; UNDEFINED MESSAGE TYPE


PADFCT:	BLOCK	^D8
; HERE TO PROCESS A PARAMETER INDICATION MESSAGE

PADPIM:
	RET
; HERE TO PROCESS AN INVITATION TO CLEAR MESSAGE

PADICM:
	MOVX	T1,.FHSLF		; POINT AT OURSELF
	MOVX	T2,CH%TTY		; POINT AT THE TTY CHANNEL
	DIC				; AND DISABLE HIM
	ERCAL	FATAL
	MOVX	T2,CH%TMR		; NOW THE TIMER CHANNEL
	DIC
	ERCAL	FATAL
	MOVX	T2,CH%NET		; AND THE NETWORK CHANNEL
	DIC
	ERCAL	FATAL
	MOVE	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,CSCBLK		; STORE IT
	SETZM	CSCBLK+1		; ZERO THE RETURN STATUS
	SETZM	CSCBLK+2		; 
	SETZM	CSCBLK+3		; 
	SETZM	CSCBLK+4
	SETZM	CSCBLK+5		; 
	MOVEI	T1,CSCBLK		; POINT TO THE ARG BLOCK
	CALL	X%CSC##			; AND TRY TO CLEAR THE SWITCHED CIRCUIT
	HRRZ	T1,CSCBLK		; GET THE RETURN STATUS
	CAIN	T1,XC%SUC		; SUCCESSFUL?
	JRST	PADIC1			; YES, CONTINUE
	MOVE	T1,LASTNE		; SAVE THE ERROR
	CALL	NETERR

PADIC1:
	HRROI	T1,[ASCIZ\

%Circuit cleared at the request of the REMOTE-HOST

\]
	CALL	.SOUT
	CALL	NETTRM			; TERMINATE PORT ACCESS
	MOVEI	T1,.CALL9		; POINT TO MAIN COMMAND LOOP
	MOVEM	T1,@LEVTAB+LV.NET-1	; STORE IT IN THE PC WORD WE WILL USE
	MOVSI	P,NETACS
	BLT	P,P
	DEBRK				; ON THIS DEBRK
	ERCAL	FATAL
; HERE TO PROCESS A SET PARAMETERS MESSAGE
; NEED TO ADD CODE TO DO RIGOROUS VALUE CHECKING SOMEDAY

PADSPM:
	HRRZ	T2,RDMBLK+2		; GET THE NUMBER OF BYTES IN THE MSG
	SOS	T2			; DON'T COUNT THE MSG TYPE BYTE
PADSP1:	ILDB	T3,T1			; GET A PAD-PARAMETER NUMBER
	ILDB	T4,T1			; GET THE VALUE
	JUMPE	T3,PADSP3		; IF ZERO, AT END OF X.3 PARAMETERS
	CAIG	T3,PADLEN		; GREATER THAN HIGHEST PAD #
	CAIG	T3,0			; NO, NEGITIVE?
	JRST	PADSP2			; YES, OUT OF RANGE
	TXO	T4,PF%WRT!PF%SET	; INDICATE THAT REMOTE SET THIS PARAM
	MOVEM	T4,PADBLK(T3)		; AND STORE THE VALUE
PADSP2:	SOS	T2			; COUNT DOWN PARAM NUMBER BYTE
	SOJG	T2,PADSP1		; AND VALUE BYTE, CONTINUE IF MORE DATA
PADSP3:	RET				; NOW THAT WE ARE DONE, GO BACK FOR
					; ANOTHER DATA MSG (IF THERE IS ONE)
; HERE TO PROCESS AN INDICATION OF BREAK MESSAGE

PADIBM:
	RET
; HERE TO PROCESS A READ PARAMETERS MESSAGE

PADRPM:
	PUSH	P,P1
	SETZ	T3,			; SET BYTE COUNT TO ZERO
	MOVE	T1,[POINT 8,NTOBUF]	; GET POINTER TO OUTPUT BUFFER
	MOVEI	T2,0			; ZERO T2
	IDPB	T2,T1			; STORE MESSAGE TYPE (INDICATION OF PAD)
	AOS	T3			; COUNT THE BYTE
	SETZ	P1,			; ZERO THE PAD PARAMETER NUMBER/INDEX
PADRP1:	AOS	P1			; INCREMENT THE NUMBER/INDEX
	IDPB	P1,T1			; STORE THE PARAMETER NUMBER
	AOS	T3			; COUNT IT
	HRRZ	T2,PADBLK(P1)		; GET THE PARAMETER VALUE
	IDPB	T2,T1			; STORE IT
	AOS	T3			; COUNT IT
	CAIGE	P1,PADLEN		; IS THIS THE LAST X.3 PARAMETER?
	JRST	PADRP1			; NO, CONTINUE BUILDING THE MESSAGE
	HRRZ	T1,PORTNO		; YES, GET THE PORT NUMBER
	MOVEM	T1,SDMBLK		; STORE IT
	SETZM	SDMBLK+1		; ZERO THE RETURN CODE
	TXO	T3,XM%QUA		; TURN ON THE QUALIFIED DATA BIT
	MOVEM	T3,SDMBLK+2		; STORE COUNT AND BITS
	MOVE	T1,[POINT 8,NTOBUF]	; GET A POINTER TO THE MESSAGE
	MOVEM	T1,SDMBLK+3		; STORE IT
	MOVEI	T1,SDMBLK		; POINT TO ARG BLOCK
	CALL	X%SDM##			; AND SEND THE MESSAGE
	HRRZ	T1,SDMBLK+1		; GET THE RETURNED STATUS
	CAIN	T1,XC%SUC		; SUCCESS?
	JRST	PADRP2			; YES, GO ON
	MOVEM	T1,LASTNE		; NO, STORE THE RETURN CODE
	CALL	NETERR			; REPORT IT
PADRP2:	POP	P,P1			; RESTORE P1
	RET				; AND RETURN
; HERE TO PROCESS AN ERROR MESSAGE

PADERM:
	RET
; HERE TO PROCESS A SET AND READ PARAMETERS MESSAGE
; T1 HAS BYTE POINTER TO RECEIVED MESSAGE

PADSRM:
	PUSH	P,P1
	PUSH	P,P2
	PUSH	P,P3
	PUSH	P,P4
	HRRZ	T2,RDMBLK+2		; GET THE NUMBER OF BYTES IN MSG
	SOS	T2			; ACCOUNT FOR THE MESSAGE TYPE
	MOVE	P1,[POINT 8,NTOBUF]	; POINT TO THE OUTPUT BUFFER
	SETZ	P2,			; ZERO OUTPUT MESSAGE BYTE COUNT
	IDPB	P2,P1			; SET PARAMETER INDICATION MSG TYPE
	AOS	P2			; COUNT THE BYTE
PADSR1:	ILDB	T3,T1			; GET THE PARAMETER NUMBER
	ILDB	T4,T1			; GET THE VALUE
	JUMPE	T3,PADSR3		; IF ZERO, END OF X.3 PARAMETERS
	CAIG	T3,PADLEN		; GREATER THAN THE HIGHEST PAD #
	CAIG	T3,0			; NO, NEGITIVE?
	JRST	PADSR2			; YES, OUT OF RANGE
	TXO	T4,PF%WRT!PF%SET	; INDICATE THAT REMOTE SET THIS PARAM
	MOVEM	T4,PADBLK(T3)		; AND STORE IT
PADSR2:	IDPB	T3,P1			; STORE THE PARAM IN THE RETURN MESSAGE
	AOS	P2			; COUNT IT
	HRRZ	T4,T4			; CLEAR LEFT HALF OF T4
	IDPB	T4,P1			; STORE IT IN RETURN MESSAGE
	AOS	P2			; COUNT IT
	SOS	T2			; COUNT DOWN THE RECEIVED MESSAGE COUNT
	SOJG	T2,PADSR1		; BY TWO AND CONTINUE IF MORE
PADSR3:	HRRZ	T1,PORTNO		; NO MORE, GET THE PORT NUMBER
	MOVEM	T1,SDMBLK		; STORE IT
	SETZM	SDMBLK+1		; ZERO THE RETURN CODE
	TXO	P2,XM%QUA		; TURN ON THE QUALIFIED DATA BIT
	MOVEM	P2,SDMBLK+2		; STORE COUNT AND BITS
	MOVE	T1,[POINT 8,NTOBUF]	; GET A POINTER TO THE MESSAGE
	MOVEM	T1,SDMBLK+3		; STORE IT
	MOVEI	T1,SDMBLK		; POINT TO ARG BLOCK
	CALL	X%SDM##			; AND SEND THE MESSAGE
	HRRZ	T1,SDMBLK+1		; GET THE RETURNED STATUS
	CAIN	T1,XC%SUC		; SUCCESS?
	JRST	PADSR4			; YES, GO ON
	MOVEM	T1,LASTNE		; NO, STORE THE RETURN CODE
	CALL	NETERR			; REPORT IT
PADSR4:	POP	P,P4
	POP	P,P3
	POP	P,P2
	POP	P,P1
	RET
; HERE ON THE RECEIPT OF AN UNKNOWN MESSAGE TYPE

PADILL:
	RET
; HERE TO HANDLE TIMER INTERRUPTS AND PSEUDO TIMER INTERRUPTS INDUCED
; BY THE NETWORK

$TIMER:
	MOVEM	P,TMRACS+17		; LETS SAVE THE ACS
	MOVEI	P,TMRACS		; OF WHATEVER PROCESS WE INTERRUPTED
	BLT	P,TMRACS+16		; 
	MOVE	P,[IOWD TMPLEN,TMRPDL]	; USE OUR OWN STACK
	MOVE	T1,[.FHSLF,,.TIMAL]	; SETUP TO CLEAR ALL PENDING TIMERS
	SETZB	T2,T3			; GOOD HOUSEKEEPING
	TIMER
	ERCAL	FATAL
	SKIPE	TTYFLG			; SKIP IF THE TERMINAL DIDN'T POKE US
	JRST	$TIME9			; THE TERMINAL POKED US...JUST DISMISS
	SKIPE	SNDFLG			; SKIP IF NO SEND IS IN PROGRESS
	JRST	$TIME9			; A SEND IN PROGRESS...DO NOTHING
	HRRZ	T2,PAD.4		; GET THE IDLE-TIMER
	JUMPE	T2,$TIME9		; THE TIMER IS DISABLED SO JUST DISMISS
	HRRZ	T2,PAD.15		; GET LOCAL-EDITING PARAMETER
	CAIN	T2,1			; LOCAL EDITING ENABLED?
	JRST	$TIME9			; YES, IGNORE TIMER TICK
	SKIPN	TTICNT			; ANY CHARACTERS TO FORWARD?
	JRST	$TIME9			; NO, JUST DISMISS
	HRRZ	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,SDMBLK		; STORE IT
	SETZM	SDMBLK+1		; ZERO RETURN STATUS
	HRRZ	T1,TTICNT		; GET THE COUNT OF CHARACTERS
	MOVEM	T1,SDMBLK+2		; STORE IT
	MOVE	T1,INIPTR		; GET THE INITIAL POINTER TO THE BUFFER
	MOVEM	T1,SDMBLK+3		; STORE IT
	MOVEI	T1,SDMBLK		; POINT AT THE ARG BLOCK
	CALL	X%SDM##
	HRRZ	T1,SDMBLK+1		; GET RETURN STATUS
	CAIN	T1,XC%SUC		; SUCCESS?
	JRST	$TIME3			; YES
	MOVEM	T1,LASTNE		; SAVE THE ERROR CODE
	CALL	NETERR			; NO, COMPLAIN

$TIME3:	HRRZ	T1,TTICNT		; GET THE COUNT
	ADDM	T1,XMTCHR		; ADD IT INTO THE TOTAL
	AOS	XMTPKT			; COUNT THE PACKET
	SETZM	TTICNT			; ZERO THE BUFFER COUNT
	MOVE	T1,INIPTR		; GET THE INITIAL POINTER INTO TTIBUF
	MOVEM	T1,TTIPTR		; STORE IT

$TIME9:	MOVE	T1,[.FHSLF,,.TIMEL]	; SETUP TO REQUEST A TIMER INTERRUPT
	HRRZ	T2,PAD.4		; GET THE IDLE-TIMER VALUE
	CAIN	T2,0			; IS IT DISABLED?
	MOVEI	T2,^D100		; YES, SETUP FOR A 5 SECOND WAIT
	IMULI	T2,^D50			; MULTIPLY BY ^D50 TO GET MILLISECONDS
	MOVEI	T3,CH.TMR		; CHANNEL TO INTERRUPT ON
	TIMER
	ERCAL	FATAL			; WHOOPS...
	SETZM	TTYFLG			; CLEAR THE TERMINAL FLAG
	MOVSI	P,TMRACS		; RESTORE ALL OF THE ACS
	BLT	P,P
	DEBRK
	ERCAL	FATAL
; INTERRUPT ROUTINE CALLED WHEN THE INPUT BUFFER BECOMES NON-EMPTY
; THIS ROUTINE READS INPUT FROM THE TERMINAL AND STORES IT IN TTYBUF
; THE LF THAT THE MONITOR SUPPLIES AFTER A CR IS THROWN AWAY


$TTYIN:
	MOVEM	P,TTYACS+17		; LETS SAVE THE ACS
	MOVEI	P,TTYACS		; OF WHATEVER PROCESS WE INTERRUPTED
	BLT	P,TTYACS+16		; 
	MOVE	P,[IOWD TTPLEN,TTYPDL]	; USE OUR OWN STACK
$TTYI0:	MOVEI	T1,.PRIIN		; 
	SIBE				; SKIP IF INPUT BUFFER IS EMPTY
	JRST	$TTYI1			; HAVE SOMETHING IN THE BUFFER
	MOVSI	P,TTYACS		; RESTORE ALL OF THE ACS
	BLT	P,P
	DEBRK				; ALL DONE
	ERCAL	FATAL

; HERE WHEN WE KNOW THAT THERE IS A CHARACTER IN THE BUFFER

$TTYI1:	PBIN				; READ THE USER'S CHARACTER
	ANDI	T1,177			; STRIP OFF PARITY (IF ANY)
	HRRZ	T2,ESCCHR		; GET THE ESCAPE-CHARACTER
	JUMPE	T2,$TTXI1		; SKIP THIS TEST IF ESCAPE CHAR IS 0
	CAMN	T1,T2			; IS THIS THE ESCAPE CHARACTER?
	JRST	$ESCAP			; YES, GO PROCESS THE ESCAPE
$TTXI1:	HRRZ	T2,BRKCHR		; GET THE BREAK-CHARACTER
	JUMPE	T2,$TTXI2		; SKIP TEST IF BREAK CHAR IS 0
	CAMN	T1,T2			; IS THIS THE BREAK-CHARACTER?
	JRST	$BREAK			; YES, GO DO BREAK STUFF
$TTXI2:	HRRZ	T2,STSCHR		; GET THE STATUS-DISPLAY-CHARACTER
	JUMPE	T2,$TTXI3		; SKIP TEST IF STATUS CHAR IS 0
	CAMN	T1,T2			; IS THIS THE STATUS-DISPLAY CHARACTER?
	JRST	$STATD			; YES, GO DISPLAY THE CURRENT STATUS
$TTXI3:	SKIPE	SNDFLG			; ARE WE SENDING A FILE?
	JRST	$TTYI0			; YES, IGNORE THE CHARACTER
	CAIN	T1,015			; IS IT A <CR>?
	CALL	[	HRRZ	T2,PAD.13 ; GET LINEFEED-INSERTION PARAMETER
			TXNE	T2,P13%FD ; SHOULD WE INSERT A <LF>?
			RET		; YES, LEAVE T20'S <LF> IN THE BUFFER
			PBIN		; NO, STRIP THE <LF> THAT FOLLOWS
			MOVEI	T1,015	; PUT BACK THE <CR>
			RET ]		; AND CONTINUE
	HRRZ	T2,PAD.2		; GET ECHO PAD PARAMETER
	CAIE	T2,0			; SKIP IF REMOTE ECHO
	JRST	$TTECH			; LOCAL, GO ECHO THE CHARACTER
$TTYI2:	IDPB	T1,TTIPTR		; PUT THE CHARACTER IN THE BUFFER
	AOS	TTICNT			; COUNT IT
	HRRZ	T2,TTICNT		; GET THE COUNT
	CAIL	T2,PKTSIZ		; HAVE WE REACHED THE MAX PACKET SIZE?
	JRST	[ MOVE	T2,PAD.15	; YES, GET THE LOCAL EDITING PARAMETER
		  CAIE	T2,1		; ARE WE DOING LOCAL-EDITING?
		  JRST	$TTYI3		; NO, JUST CONTINUE
		  CAIN	T1,015		; IS THIS A <CR>?
		  JRST	$TTYI3		; YES, NO NEED TO WAIT
		  MOVEI	T2,2		; LOAD A 2 INTO T2
		  MOVEM	T2,EDTFLG	; INDICATE A <CR> WAIT
		  JRST	$TTYI3 ]	; AND CONTINUE
	HLRZ	T2,.ASCII(T1)		; GET DATA-FORWARDING BIT FOR THIS CHAR
	TDNE	T2,PAD.3		; DO DATA-FORWARDING?
	JRST	$TTYI3			; YES
	JRST	$TTYI0			; NO, GO GET ANOTHER CHARACTER


$TTYI3:
	HRRZ	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,SDMBLK		; STORE IT
	SETZM	SDMBLK+1		; ZERO RETURN STATUS
	HRRZ	T1,TTICNT		; GET THE COUNT OF CHARACTERS
	MOVEM	T1,SDMBLK+2		; STORE IT
	MOVE	T1,INIPTR		; GET THE INITIAL POINTER TO THE BUFFER
	MOVEM	T1,SDMBLK+3		; STORE IT
	MOVEI	T1,SDMBLK		; POINT AT THE ARG BLOCK
	CALL	X%SDM##
	HRRZ	T1,SDMBLK+1		; GET RETURN STATUS
	CAIN	T1,XC%SUC		; SUCCESS?
	JRST	$TTYI4			; YES
	MOVEM	T1,LASTNE		; SAVE THE ERROR CODE
	CALL	NETERR			; NO, COMPLAIN

$TTYI4:	HRRZ	T1,TTICNT		; GET THE COUNT
	ADDM	T1,XMTCHR		; ADD IT INTO THE TOTAL
	AOS	XMTPKT			; COUNT THE PACKET
	SETZM	TTICNT			; ZERO THE BUFFER COUNT
	MOVE	T1,INIPTR		; GET THE INITIAL POINTER INTO TTIBUF
	MOVEM	T1,TTIPTR		; STORE IT
	SETOM	TTYFLG			; INDICATE THAT WE CAUSED THE INTERRUPT
	MOVX	T1,.FHSLF		; POINT TO OURSELF
	MOVX	T2,CH%TMR		; POINT TO THE TIMER CHANNEL
	IIC				; AND CAUSE AN INTERRUPT SO THE IDLE
	ERCAL	FATAL			; TIMER GETS RESET
	JRST	$TTYI0			; AND GO LOOK FOR ANOTHER CHARACTER
; HERE TO HANDLE THE TYPING OF A ESCAPE CHARACTER

$ESCAP:	SKIPE	SNDFLG			; IN THE MIDDLE OF A SEND COMMAND?
	JRST	$ESCA1			; YES, DO OTHER STUFF
	MOVX	T1,.FHSLF		; POINT AT OURSELF
	MOVX	T2,CH%TTY		; POINT AT THE TTY CHANNEL
	DIC				; AND DISABLE HIM
	ERCAL	FATAL
	MOVX	T2,CH%TMR		; NOW THE TIMER CHANNEL
	DIC
	ERCAL	FATAL
	MOVX	T2,CH%NET		; AND THE NETWORK CHANNEL
	DIC
	ERCAL	FATAL
	SETOM	ESCFLG			; INDICATE ESCAPE
	MOVEI	T1,.PRIIN
	RFMOD				; READ CURRENT TERMINAL STATE
	ERCAL	FATAL
	MOVEM	T2,NMODE		; AND SAVE IT
	CALL	OCRLF			; PRINT A CR/LF
	MOVEI	T1,.CALL9		; POINT TO MAIN COMMAND LOOP
	MOVEM	T1,@LEVTAB+LV.TTY-1	; STORE IT IN THE PC WORD WE WILL USE
	MOVSI	P,TTYACS
	BLT	P,P
	DEBRK				; ON THIS DEBRK
	ERCAL	FATAL

$ESCA1:	SETOM	SNDINT			; NOTIFY THE SEND THAT THE USER WANTS
					; TO TYPE COMMANDS
	JRST	$TTYI0			; AND CONTINUE TO CLEAR OUT THE BUFFER
; HERE TO HANDLE THE TYPING OF THE STATUS-DISPLAY CHARACTER

$STATD:
	CALL	OCRLF			; START DISPLAY ON A NEW LINE
	HRROI	T1,ODBUF		; POINT TO DESTINATION
	SETOM	T2			; OUTPUT CURRENT DATE/TIME
	MOVE	T3,[OT%NDA!OT%TMZ]	; DON'T PRINT THE DATE
	ODTIM				; JUST THE TIME OF DAY
	ERCAL	FATAL
	SETZ	T2,			; CLEAR T2
	IDPB	T2,T1			; TERMENATE WITH A "NULL"
	HRROI	T1,ODBUF		; POINT TO STRING
	CALL	.SOUT			; OUTPUT IT
	HRROI	T1,[ASCIZ\  Port is \]
	CALL	.SOUT
	HRRZ	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,RPSBLK		; AND STORE IT
	SETZM	RPSBLK+1		; ZERO THE STATUS RETURN WORD
	SETZM	RPSBLK+2		; ZERO THE ERROR CONDITION,,PORT STATE
	SETZM	RPSBLK+3		; ZERO THE INTERRUPT/BIT MASK
	MOVEI	T1,RPSBLK		; POINT TO THE ARGUMENT BLOCK
	CALL	X%RPS##			; AND READ THE PORT STATUS
	HRRZ	T1,RPSBLK+1		; GET THE RETURNED STATUS
	CAIN	T1,XC%SUC		; SUCCESSFUL RETURN?
	JRST	$STAT1			; YES, GO ON
	MOVEM	T1,LASTNE		; SAVE THE ERROR CODES
	CALL	NETERR			; AND REPORT THE ERROR

$STAT1:	HRRZ	T1,RPSBLK+2		; GET THE PORT STATE
	MOVE	T1,PORTST(T1)		; POINT TO STRING
	CALL	.SOUT			; AND PRINT IT
	HRROI	T1,[ASCIZ\  XMT:\]
	CALL	.SOUT
	MOVE	T2,XMTPKT		; GET THE NUMBER OF TRANSMITTED PACKETS
	MOVEI	T3,^D10			; PRINT IT IN DECIMAL
	CALL	.NOUT
	CALL	ERROR
	HRROI	T1,[ASCIZ\ PKT, \]
	CALL	.SOUT
	MOVE	T2,XMTCHR		; NUMBER OF CHARACTERS TRANSMITTED
	MOVEI	T3,^D10			; DECIMAL
	CALL	.NOUT
	CALL	ERROR
	HRROI	T1,[ASCIZ\ CHAR  RCV:\]
	CALL	.SOUT
	MOVE	T2,RCVPKT		; NUMBER OF PACKETS RECEIVED
	MOVEI	T3,^D10			; IN DECIMAL
	CALL	.NOUT
	CALL	ERROR
	HRROI	T1,[ASCIZ\ PKT, \]
	CALL	.SOUT
	MOVE	T2,RCVCHR		; NUMBER OF CHARACTERS RECEIVED
	MOVEI	T3,^D10			; IN DECIMAL
	CALL	.NOUT
	CALL	ERROR
	HRROI	T1,[ASCIZ\ CHAR\]
	CALL	.SOUTR
	JRST	$TTYI0			; AND BACK FOR MORE INPUT (IF ANY)

ODBUF:	BLOCK 4
; HERE TO HANDLE THE TYPING OF THE BREAK-CHARACTER

$BREAK:
	HRRZ	T2,PAD.7		; GET ACTION-ON-BREAK PARAMETER
	JUMPE	T2,$TTYI0		; NO ACTION, IGNORE
	TXNE	T2,P07%ES		; ESCAPE TO COMMAND MODE?
	JRST	$ESCAP			; YES
	TXNE	T2,P07%IT		; SEND INTERRUPT MESSAGE?
	CALL	$BRINT			; YES
	TXNE	T2,P07%ID		; SEND INDICATION OF BREAK?
	CALL	$BRIDB			; YES
	TXNE	T2,P07%DO		; DISCARD OUTPUT?
	CALL	$BRDIS			; YES
	TXNE	T2,P07%RE		; SEND RESET?
	CALL	$BRRES			; YES
	JRST	$TTYI0			; AND BACK FOR MORE
; HERE TO SEND AN INTERRUPT MESSAGE TO THE REMOTE-HOST

$BRINT:
	HRRZ	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,SIMBLK		; STORE IT
	SETZM	SIMBLK+1		; CLEAR RETURN STATUS
	SETZM	SIMBLK+2		; SEND A NULL BYTE
	MOVEI	T1,SIMBLK		; POINT TO ARG BLOCK
	CALL	X%SIM##			; AND SEND INTERRUPT
	HRRZ	T1,SIMBLK+1		; GET RETURN STATUS
	CAIN	T1,XC%SUC		; SUCCESS?
	RET				; YES, RETURN
	MOVEM	T1,LASTNE		; NO, SAVE THE RETURN CODE
	CALL	NETERR			; REPORT THE ERROR
	RET				; AND RETURN
; HERE TO DISCARD OUTPUT

$BRDIS:
	MOVE	T1,[PF%WRT!P08%DO]	; GET THE DISCARD OUTPUT BIT
	MOVEM	T1,PAD.8		; AND STORE IT
	MOVEI	T1,.PRIOU		; GET OUTPUT DESIGNATOR
	CFOBF				; CLEAR OUTPUT BUFFER
	ERCAL	FATAL
	RET				; AND RETURN
; HERE TO SEND INDICATION OF BREAK TO THE REMOTE-HOST

$BRIDB:
	PUSH	P,T1
	PUSH	P,T2
	PUSH	P,T3
	SETZ	T3,
	MOVE	T1,[POINT 8,NTOBUF]	; GET POINTER TO MESSAGE BUFFER
	MOVEI	T2,3			; INDICATION OF BREAK MSG #
	IDPB	T2,T1			; STORE IT
	AOS	T3			; COUNT IT
	HRRZ	T2,PAD.7		; GET ACTION-ON-BREAK PARAMETER
	TXNN	T2,P07%DO		; DISCARD OUTPUT?
	JRST	$BRID1			; NO, JUST SEND INDICATION OF BREAK
	MOVEI	T2,^D8			; GET PARAMETER #8
	IDPB	T2,T1			; STORE IT
	AOS	T3			; COUNT IT
	MOVEI	T2,P08%DO		; DISCARDING OUTPUT
	IDPB	T2,T1			; STORE IT
	AOS	T3			; COUNT IT
$BRID1:	HRRZ	T2,PORTNO		; GET THE PORT NUMBER
	MOVEM	T2,SDMBLK		; STORE IT
	SETZM	SDMBLK+1		; CLEAR THE RETURN STATUS
	TXO	T3,XM%QUA		; SET QUALIFIED DATA BIT
	MOVEM	T3,SDMBLK+2		; STORE COUNT AND BITS
	MOVE	T2,[POINT 8,NTOBUF]	; POINT TO MESSAGE
	MOVEM	T2,SDMBLK+3		; STORE IT
	MOVEI	T1,SDMBLK		; POINT TO ARG BLOCK
	CALL	X%SDM
	HRRZ	T1,SDMBLK+1		; GET RETURNED STATUS
	CAIN	T1,XC%SUC		; SUCCESSFUL?
	JRST	$BRID2			; YES
	MOVEM	T1,LASTNE		; NO, STORE THE ERROR
	CALL	NETERR			; REPORT IT
$BRID2:	POP	P,T3
	POP	P,T2
	POP	P,T1
	RET				; AND RETURN
; HERE TO RESET THE CIRCUIT

$BRRES:
	PUSH	P,T1
	HRRZ	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,RPSBLK		; STORE IT
	SETZM	RPSBLK+1		; ZERO THE STATUS RETURN WORD
	SETZM	RPSBLK+2		; ZERO THE ERROR CONDITION,,PORT STATE
	SETZM	RPSBLK+3		; ZERO THE INTERRUPT/BIT MASK
	MOVEI	T1,RPSBLK		; POINT TO THE ARG BLOCK
	CALL	X%RPS##			; AND READ THE PORT STATUS
	HRRZ	T1,RPSBLK+1		; GET THE RETURN CODE
	CAIE	T1,XC%SUC		; SUCCESSFUL?
	JRST	$BRRE1			; NO, JUST DISMISS
	HRRZ	T1,RPSBLK+2		; YES, GET THE PORT STATE
	CAIE	T1,XS%RUN		; IS THE PORT RUNNING?
	JRST	$BRRE1			; NO, JUST DISMISS
	HRRZ	T1,PORTNO		; YES, GET THE PORT NUMBER
	MOVEM	T1,RVCBLK		; STORE IT
	SETZM	RVCBLK+1		; CLEAR THE RETURN CODE
	SETZM	RVCBLK+2		; CLEAR THE DIAGNOSTIC BYTE
	MOVEI	T1,RVCBLK		; POINT AT THE ARG BLICK
	CALL	X%RVC##			; AND RESET THE CIRCUIT
	HRRZ	T1,RVCBLK+1		; GET THE RETURN CODE
	CAIN	T1,XC%SUC		; SUCCESSFUL?
	JRST	$BRRE1			; YES
	MOVEM	T1,LASTNE		; NO, STORE THE ERROR
	CALL	NETERR			; REPORT IT
$BRRE1:	POP	P,T1
	RET
; HERE TO DO LOCAL ECHOING

$TTECH:
	MOVE	T2,OMODE		; GET THE ORIGINAL MODE WORD
	TXNE	T2,FLD(.TTHDX,TT%DUM)	; ORIGINALLY IN HALFDUPLEX MODE?
	JRST	$TTYI2			; YES, DON'T DO ANY ECHOING HERE
	HRRZ	T2,PAD.15		; GET THE LOCAL EDITING PARAMETER
	CAIN	T2,1			; DO LOCAL EDITING?
	JRST	$TTED			; YES, GO DO IT
	HRRZ	T2,.ASCII(T1)		; NO, JUST ECHO THE CHARACTER
	CALL	@T2
	JRST	$TTYI2			; NOW STICK IT IN THE INPUT BUFFER
; HERE TO DO LOCAL EDITING

$TTED:
	MOVE	T2,EDTFLG		; GET THE EDITING FLAG
	CAIE	T2,2			; WAITING FOR <CR>?
	JRST	$TTED3			; NO, GO ON
	CAIN	T1,015			; YES, IS THIS THE <CR> WE WANT?
	JRST	$TTED2			; YES
$TTED1:	MOVEI	T2,7			; NO, JUST ECHO A BELL
	CALL	.BOUT
	JRST	$TTYI0			; FORGET THE TYPED CHAR, GO LOOK FOR CR
$TTED2:	SETZM	EDTFLG			; CLEAR THE EDITING FLAG
	HRRZ	T2,.ASCII(T1)		; GET THE ECHO ROUTINE ADDRESS
	CALL	@T2			; AND ECHO THE CHARACTER
	JRST	$TTYI2			; AND CONTINUE
$TTED3:	HRRZ	T2,PAD.16		; GET THE DELETE CHARACTER
	CAME	T1,T2			; IS THIS THE DELETE CHARACTER?
	JRST	$TED10			; NO, GO ON
	MOVE	T2,EDTFLG		; GET THE EDIT FLAG
	CAIE	T2,1			; ARE WE DELETING?
	JRST	$TTED4			; NO, GO ON
	MOVE	T2,TTICNT		; GET INPUT BUFFER COUNT
	JUMPE	T2,$TTED1		; IF EMPTY, SEND A BELL TO THE USER
	LDB	T1,TTIPTR		; GET THE LAST CHARACTER IN THE BUFFER
	HRRZ	T2,.ASCII(T1)		; GET THE ECHO ROUTINE ADDRESS
	CALL	@T2			; ECHO THE CHARACTER
	SETOM	T2			; LOAD T2 WITH -1
	ADJBP	T2,TTIPTR		; BACK UP THE INPUT POINTER BY 1
	MOVEM	T2,TTIPTR		; AND STORE IT
	SOS	TTICNT			; DECREMENT
	JRST	$TTED5			; GO ON

$TTED4:	MOVE	T2,TTICNT		; GET INPUT BUFFER CHAR COUNT
	JUMPE	T2,$TTED1		; IF EMPTY, SEND A BELL
	MOVEI	T2,1			; LOAD A 1
	MOVEM	T2,EDTFLG		; AND INDICATE A DELETE IN PROGRESS
	MOVEI	T2,"\"			; LOAD A BACKSLASH
	CALL	.BOUT			; AND PRINT IT
	LDB	T1,TTIPTR		; GET THE LAST CHARACTER IN THE BUFFER
	HRRZ	T2,.ASCII(T1)		; GET THE ECHO ROUTINE ADDRESS
	CALL	@T2			; AND PRINT IT
	SETOM	T2			; LOAD T2 WITH -1
	ADJBP	T2,TTIPTR		; BACK UP INPUT BUFFER POINTER BY 1
	MOVEM	T2,TTIPTR		; AND STORE IT
	SOS	TTICNT			; DECREMENT CHARACTER COUNT
$TTED5:	SKIPE	TTICNT			; SKIP IF INPUT BUFFER NOW EMPTY
	JRST	$TTYI0			; NOT EMPTY, GO ON
	HRROI	T1,[ASCIZ/\/]		; EMPTY SO PRINT A CLOSING \
	CALL	.SOUTR			; AND A CRLF
	SETZM	EDTFLG			; CLEAR THE EDITING FLAG
	JRST	$TTYI0			; CONTINUE LOOKING FOR INPUT

$TED10:
	HRRZ	T2,PAD.17		; GET THE LINE DELETE CHARACTER
	CAME	T1,T2			; IS THIS THE LINE-DELETE CHAR?
	JRST	$TED20			; NO, GO ON
	MOVE	T2,EDTFLG		; GET THE EDIT FLAG
	CAIE	T2,1			; ARE WE DELETING?
	JRST	$TED11			; NO, GO ON
	MOVEI	T2,"\"			; YES, FINISH WITH A BACKSLASH
	CALL	.BOUT
$TED11:	HRRZ	T2,.ASCII(T1)		; GET ECHO ROUTINE ADDRESS
	CALL	@T2			; ECHO THE CHARACTER
	CALL	OCRLF			; PRINT A CRLF
	MOVE	T2,INIPTR		; GET THE POINTER TO BEGINNING OF BUFFER
	MOVEM	T2,TTIPTR		; STORE IT
	SETZM	TTICNT			; ZERO THE BUFFER CHARACTER COUNT
	SETZM	EDTFLG			; CLEAR THE EDITING FLAG
	JRST	$TTYI0			; AND GO BACK FOR MORE

$TED20:
	HRRZ	T2,PAD.18		; GET THE LINE DISPLAY CHARACTER
	CAME	T1,T2			; IS THIS THE LINE DISPLAY CHARACTER?
	JRST	$TED30			; NO, GO ON
	MOVE	T2,EDTFLG		; GET THE EDIT FLAG
	CAIE	T2,1			; ARE WE DELETING?
	JRST	$TED21			; NO, GO ON
	MOVEI	T2,"\"			; YES, FINISH WITH BACKSLASH
	CALL	.BOUT			; PRINT IT
	SETZM	EDTFLG			; CLEAR THE EDITING FLAG
$TED21:	HRRZ	T2,.ASCII(T1)		; GET THE ECHO ROUTINE ADDRESS
	CALL	@T2			; ECHO IT
	CALL	OCRLF			; PRINT A CRLF
	MOVE	T3,TTICNT		; GET NUMBER OF CHARACTERS IN THE BUFFER
	JUMPE	T3,$TTYI0		; IF NO CHARACTERS, DO NOTHING ELSE
	MOVE	T4,INIPTR		; GET INITIAL POINTER TO INPUT BUFFER
$TED22:	ILDB	T1,T4			; GET A CHARACTER
	HRRZ	T2,.ASCII(T1)		; GET THE ECHO ROUTINE
	CALL	@T2			; PRINT THE CHARACTER
	SOJG	T3,$TED22		; DECREMENT COUNT AND GO BACK IF MORE
	JRST	$TTYI0			; ALL DONE, BACK FOR MORE

$TED30:
	MOVE	T2,EDTFLG		; GET THE EDIT FLAG
	CAIE	T2,1			; ARE WE DELETING?
	JRST	$TED31			; NO, GO ON
	MOVEI	T2,"\"			; YES, FINISH WITH A BACKSLASH
	CALL	.BOUT
	SETZM	EDTFLG			; CLEAR THE EDITING FLAG
$TED31:	HRRZ	T2,.ASCII(T1)		; GET ECHO ROUTINE ADDRESS
	CALL	@T2			; ECHO THE CHARACTER
	JRST	$TTYI2			; NOW PUT IT IN THE BUFFER
; HERE TO PRINT CONTROL CHARACTERS

$TOCTL:
	HRRZ	T2,PAD.15		; GET THE LOCAL-EDITING PARAMETER
	CAIE	T2,1			; ARE WE DOING LOCAL-EDITING?
	RET				; JUST RETURN IF NOT
	HLRZ	T2,.ASCII(T1)		; GET DATA-FORWARDING BIT FOR THIS CHAR
	TDNE	T2,PAD.3		; IS THIS A DATA-FORWARDING CHAR?
	RET				; YES, LET REMOTE-HOST WORRY ABOUT ECHO
	MOVEI	T2,"^"			; GET AN UP-ARROW
	CALL	.BOUT			; PRINT IT
	MOVE	T2,T1			; GET THE CHARACTER
	ADDI	T2,100			; ADD 100 TO GET A PRINTABLE CHARACTER
	CALL	.BOUT			; PRINT IT
	RET				; AND RETURN
; HERE TO PRINT CARRIAGE RETURNS

$TOCAR:
	MOVE	T2,T1			; LOAD THE CHARACTER INTO T2
	CALL	.BOUT			; AND PRINT IT
	HRRZ	T2,PAD.13		; GET LINEFEED INSERTION PARAMETER
	TXNN	T2,P13%EC		; ADD A LINEFEED?
	RET				; NO
	MOVEI	T2,012			; LOAD A LINEFEED
	CALL	.BOUT			; AND PRINT IT
	RET
; HERE TO PRINT REGULAR CHARACTERS

$TOCHR:
	MOVE	T2,T1			; LOAD THE CHARACTER INTO T2
	CALL	.BOUT			; AND PRINT IT
	RET
; HERE TO PRINT THE <DEL> CHARACTER

$TODEL:
	RET				; JUST RETURN, NOTHING TO PRINT
; HERE TO HANDLE THE <ESC> CHARACTER

$TOESC:
	HRRZ	T2,PAD.15		; GET THE LOCAL-EDITING PARAMETER
	CAIE	T2,1			; ARE WE EDITING?
	RET				; NO, JUST RETURN
	HLRZ	T2,.ASCII(T1)		; GET DATA-FORWARDING BIT FOR THIS CHAR
	TDNE	T2,PAD.3		; IS THIS A DATA-FORWARDING CHAR?
	RET				; YES, LET REMOTE-HOST WORRY ABOUT ECHO
	MOVEI	T2,"$"			; YES, PRINT IT AS A $
	CALL	.BOUT
	RET				; AND RETURN
	SUBTTL	CLEAR COMMAND

.CLEAR:
	NOISE (current call)
	CONFIRM
	SKIPE	CALLCT			; IS THERE CURRENTLY AN OPEN CALL?
	JRST	.CLEA1			; YES GO CLEAR IT
	HRROI	T1,[ASCIZ\%There is no call to clear\]
	CALL	.SOUTR
	CALL	INIPAD			; RE-INIT THE PAD PARAMETERS (ANYWAY)
	RET

.CLEA1:	CALL	NETTRM			; CALL THE TERMINATION ROUTINE
	SETZM	CALLCT			; CLEAR THE CALL/CLEAR INTERLOCK
	RET
; THIS ROUTINE IS CALLED TO TERMINATE ACCESS TO A GATEWAY PORT

NETTRM:
	MOVE	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,TPABLK		; AND STORE IT
	SETZM	TPABLK+1		; CLEAR THE RETURN STATUS WORD
	MOVEI	T1,TPABLK		; LOAD THE ADDRESS OF THE ARG BLOCK
	CALL	X%TPA##			; AND CALL THE TERMINATION ROUTINE
	MOVE	P1,TPABLK+1		; GET THE STATUS RETURNED
	CAIN	P1,XC%SUC		; SUCCESS?
	JRST	NETTR1			; YES, JUST RETURN
	MOVEM	P1,LASTNE		; SAVE THIS ERROR CODE
;	CALL	NETERR			; AND NOTIFY USER OF ERROR
NETTR1:	SETZM	CALLCT			; CLEAR THE INTERLOCK
	SETZM	ESCFLG			; CLEAR THE ESCAPE FLAG
	HRRZ	T1,PAD.6		; GET NET-MSG-DISPLAY PARAMETER
	CAIE	T1,1			; DISPLAY STATISTICS?
	JRST	NETTRX			; NO, JUST EXIT
	HRROI	T1,[ASCIZ\ Call cleared at \]
	CALL	.SOUT
	HRROI	T1,ODBUF		; POINT TO OUTPUT BUFFER
	SETOM	T2			; -1 IN T2
	MOVE	T3,[OT%NDA!OT%TMZ]	; TIME ONLY
	ODTIM
	ERCAL	FATAL
	SETZ	T2,			; ZERO T2
	IDPB	T2,T1			; AND FINISH STRING WITH A "NULL"
	HRROI	T1,ODBUF		; POINT TO STRING
	CALL	.SOUT			; AND PRINT IT
	HRROI	T1,[ASCIZ\ on \]
	CALL	.SOUT
	HRROI	T1,ODBUF		; POINT TO OUTPUT BUFFER
	SETOM	T2			; -1 IN T2
	MOVE	T3,[OT%FMN!OT%4YR!OT%DAM!OT%SPA!OT%NTM]	; DATE ONLY
	ODTIM
	ERCAL	FATAL
	SETZ	T2,			; ZERO T2
	IDPB	T2,T1			; AND FINISH STRING WITH A "NULL"
	HRROI	T1,ODBUF		; POINT TO STRING
	CALL	.SOUTR			; AND PRINT IT
	HRROI	T1,[ASCIZ\ Transmitted \]
	CALL	.SOUT
	MOVE	T2,XMTCHR		; GET NUMBER OF CHARACTERS TRANSMITTED
	MOVEI	T3,^D10			; PRINT IN DECIMAL
	CALL	.NOUT
	  CALL	ERROR
	HRROI	T1,[ASCIZ\ characters in \]
	CALL	.SOUT
	MOVE	T2,XMTPKT		; GET THE NUMBER OF PACKETS
	MOVEI	T3,^D10			; PRINT IN DECIMAL
	CALL	.NOUT
	  CALL	ERROR
	HRROI	T1,[ASCIZ\ packets.\]
	CALL	.SOUTR
	HRROI	T1,[ASCIZ\ Received \]
	CALL	.SOUT
	MOVE	T2,RCVCHR		; GET NUMBER OF CHARACTERS RECEIVED
	MOVEI	T3,^D10			; PRINT IN DECIMAL
	CALL	.NOUT
	  CALL	ERROR
	HRROI	T1,[ASCIZ\ characters in \]
	CALL	.SOUT
	MOVE	T2,RCVPKT		; GET THE NUMBER OF PACKETS
	MOVEI	T3,^D10			; PRINT IN DECIMAL
	CALL	.NOUT
	  CALL	ERROR
	HRROI	T1,[ASCIZ\ packets.\]
	CALL	.SOUTR
NETTRX:	CALL	INIPAD			; RE-INITIALIZE THE PAD PARAMETERS
	SKIPN	SNDFLG			; SKIP IF WE NEED TO CLEAN UP A SEND CMD
	RET				; NO, JUST RETURN
	MOVE	T1,SNDJFN		; GET THE INPUT FILE'S JFN
	CLOSF				; CLOSE THE SNDJFN
	  ERCAL	FATAL			; SHOULD NEVER HAPPEN
	SETZM	SNDFLG			; CLEAR THE SEND FLAG
	SETZM	SNDINT			; CLEAR THE INTERRUPT FLAG
	SETZM	SNDJFN			; CLEAR THE FILE JFN
	RET				; AND RETURN
	SUBTTL	CLOSE COMMAND

.CLOSE:	NOISE (log file!)
	CONFIRM
NOLOG:	SKIPN	T1,LOGJFN		; ANY LOG?
	RET				; NO, EXIT
	CALL	OCRLF
	HRROI	T1,[ASCIZ\ ***** Log file closed at \]
	CALL	.SOUT
	HRROI	T1,ODBUF		; POINT TO OUTPUT BUFFER
	SETOM	T2			; -1 IN T2
	MOVE	T3,[OT%NDA!OT%TMZ]	; TIME ONLY
	ODTIM
	ERCAL	FATAL
	SETZ	T2,			; ZERO T2
	IDPB	T2,T1			; AND FINISH STRING WITH A "NULL"
	HRROI	T1,ODBUF		; POINT TO STRING
	CALL	.SOUT			; AND PRINT IT
	HRROI	T1,[ASCIZ\ on \]
	CALL	.SOUT
	HRROI	T1,ODBUF		; POINT TO OUTPUT BUFFER
	SETOM	T2			; -1 IN T2
	MOVE	T3,[OT%FMN!OT%4YR!OT%DAM!OT%SPA!OT%NTM]	; DATE ONLY
	ODTIM
	ERCAL	FATAL
	SETZ	T2,			; ZERO T2
	IDPB	T2,T1			; AND FINISH STRING WITH A "NULL"
	HRROI	T1,ODBUF		; POINT TO STRING
	CALL	.SOUT			; AND PRINT IT
	HRROI	T1,[ASCIZ\ *****\]
	CALL	.SOUTR
	CALL	OCRLF
	MOVE	T1,LOGJFN		; GET THE .LOG FILE JFN
	SETZM	LOGJFN			; CLEAR JFN
	CLOSF				; CLOSE IT
	JRST	FATAL			; SHOULD NEVER HAPPEN
	RET


; HERE TO CLOSE A LOG FILE AND TERMINATE SESSION LOGGING
	SUBTTL	CONTINUE COMMAND

.CONTI:
	NOISE (current call)
	CONFIRM
	SKIPE	ESCFLG
	JRST	.CONT1			; YES, THERE MAY BE A CALL TO CONTINUE
	HRROI	T1,[ASCIZ\?There is no call to continue\]
	CALL	.SOUTR
	RET

.CONT1:	SETZM	ESCFLG			; CLEAR THE ESCAPE FLAG
	HRRZ	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,RPSBLK		; AND STORE IT
	SETZM	RPSBLK+1		; ZERO STATUS RETURN WORD
	SETZM	RPSBLK+2		; ZERO ERROR CONDITION,,PORT STATE
	SETZM	RPSBLK+3		; ZERO THE INTERRUPT/BIT MASK
	MOVEI	T1,RPSBLK		; POINT TO THE ARG BLOCK
	CALL	X%RPS##			; AND READ THE PORT STATUS
	MOVE	T1,RPSBLK+1		; GET THE RETURN CODE
	CAIN	T1,XC%SUC		; SUCCESSFUL RETURN?
	JRST	.CONT2			; YES, GO ON
	MOVEM	T1,LASTNE		; SAVE THE ERROR CODES
	CALL	NETERR			; AND REPORT THE ERROR
	HRROI	T1,[ASCIZ\?Aborting the call and clearing the circuit\]
	CALL	.SOUTR
	CALL	NETTRM			; TERMINATE PORT ACCESS
	RET				; SIGH, JUST RETURN

.CONT2:	HRRZ	T1,RPSBLK+2		; GET THE STATE OF THE PORT
	CAIN	T1,XS%RUN		; STILL RUNNING?
	JRST	.CAL8A			; YES, CONTINUE
	CAIN	T1,XS%SYN		; SYNCHING?
	JRST	.CAL8A			; YES, CONTINUE
	CAIN	T1,XS%UNS		; UNSYNCH?
	JRST	.CAL8A			; CONTINUE (NET TASK WILL RESET CIRCUIT)
	HRROI	T1,[ASCIZ\?The PORT is not RUNNING! The current PORT state is \]
	CALL	.SOUT
	HRRZ	T1,RPSBLK+2		; GET THE PORT STATE
	MOVE	T1,PORTST(T1)		; GET THE POINTER TO THE STRING
	CALL	.SOUTR
	HRROI	T1,[ASCIZ\?Aborting and clearing the circuit!\]
	CALL	.SOUTR
	CALL	NETTRM			; TERMINATE PORT ACCESS
	RET				; SIGH, JUST RETURN
	SUBTTL	DEFINE COMMAND


; SAMPLE COMMAND:
;
;	DEFINE (remote-host) host-name (to be) dte-address,dte-sub-address
;
.DEFIN:
	NOISE (remote-host)
	MOVEI	T2,[FLDDB. .CMFLD,CM%SDH,,<host name to be defined>]
	COMND
	ERCAL	FATAL
	MOVE	P1,[POINT 7,ATMBUF]	; POINT TO THE FIRST CHARACTER
	MOVE	P2,[POINT 7,DFHOST]	; POINT TO TEMPORARY HOLDING BUFFER
	SETZ	P3,			; ZERO THE COUNT
	ILDB	P4,P1			; GET THE FIRST CHARACTER
	CAIE	P4,0			; IS IT A NUL?
	JRST	.DEFI2			; NO, GO ON
	HRROI	T1,[ASCIZ\?No name given\]
	CALL	.SOUTR			; COMPLAIN
	RET
.DEFI1:	ILDB	P4,P1			; GET THE NEXT CHARACTER
	CAIN	P4,0			; END OF STRING
	JRST	.DEFI3			; YES, FINISHED
.DEFI2:	AOS	P3			; NO, COUNT IT
	CAILE	P4,172			; IS THIS A LOWER CASE ALPHABETIC CHAR?
	SKIPA
	CAIGE	P4,141			; 
	SKIPA
	SUBI	P4,40			; YES, MAKE IT UPPER CASE
	CAIG	P3,^D16			; MORE THAN ^D16 CHARACTERS?
	IDPB	P4,P2			; NO, STORE IT
	JRST	.DEFI1			; AND CONTINUE
.DEFI3:	SETZ	P4,			; ZERO P4
	IDPB	P4,P2			; TERMINATE STRING
	NOISE (as DTE number)
	MOVEI	T2,[FLDDB. .CMFLD,CM%SDH,,<DTE address or null to delete>]
	COMND
	ERCAL	FATAL
	MOVE	P1,[POINT 7,ATMBUF]	; POINT TO STRING
	MOVE	P2,[POINT 7,DFDTEA]	; POINT TO DESTINATION
	SETZ	P3,			; ZERO COUNT
	ILDB	P4,P1			; GET THE FIRST CHARACTER
	CAIN	P4,0			; NULL CHARACTER?
	JRST	DELDEF			; YES, TRY TO DELETE THIS HOST NAME
	JRST	.DEFI5			; NO, COPY THE ADDRESS
.DEFI4:	ILDB	P4,P1			; GET THE NEXT CHARACTER
	CAIN	P4,0			; END OF STRING?
	JRST	.DEFI6			; YES
.DEFI5:	CAIG	P4,"9"			; SKIP IF GREATER THAN THE CHARACTER "9"
	CAIGE	P4,"0"			; SKIP IF GREATER THAN OR EQUAL "0"
	JRST	PARERR			; NOT NUMERIC...GO COMPLAIN
	AOS	P3			; COUNT IT
	CAIG	P3,^D15			; MORE THAN ^D15 CHARACTERS
	IDPB	P4,P2			; STORE IT
	JRST	.DEFI4			; AND GO BACK FOR MORE
.DEFI6:	SETZ	P4,			; ZERO P4
	IDPB	P4,P2			; AND TERMINATE THE STRING
	CAIG	P3,^D15			; MORE THAN ^D15 CHARACTERS?
	JRST	.DEFI7			; NO, GET THE DTE SUBADDRESS
	HRROI	T1,[ASCIZ\?DTE address may not exceed 15 characters\]
	CALL	.SOUTR			; COMPLAIN
	RET

.DEFI7:	MOVEI	T2,[FLDDB. .CMFLD,CM%SDH,,<DTE subaddress>,,GENRIC]
	COMND
	ERCAL	FATAL
	HRRZ	T3,T3			; WHO PARSED THIS FIELD?
	CAIN	T3,GENRIC		; CONFIRMED?
	JRST	[	SKIPE	LOGJFN	; YES, GO DO COMMAND
			CALL	LOG
			JRST	ADDDEF	]
	MOVE	P1,[POINT 7,ATMBUF]	; POINT TO STRING
	MOVE	P2,[POINT 7,DFDTES]	; POINT TO DESTINATION
	SETZ	P3,			; ZERO COUNT
.DEFI8:	ILDB	P4,P1			; GET THE NEXT CHARACTER
	CAIN	P4,0			; END OF STRING?
	JRST	.DEFI9			; YES
	CAIG	P4,"9"			; SKIP IF GREATER THAN THE CHARACTER "9"
	CAIGE	P4,"0"			; SKIP IF GREATER THAN OR EQUAL "0"
	JRST	PRSERR			; NOT NUMERIC...GO COMPLAIN
	AOS	P3			; COUNT IT
	CAIG	P3,^D15			; MORE THAN ^D15 CHARACTERS
	IDPB	P4,P2			; STORE IT
	JRST	.DEFI8			; AND GO BACK FOR MORE
.DEFI9:	SETZ	P4,			; ZERO P4
	IDPB	P4,P2			; AND TERMINATE THE STRING
	CAIG	P3,^D15			; MORE THAN ^D15 CHARACTERS?
	JRST	.DEFCF			; NO, GO CONFIRM
	HRROI	T1,[ASCIZ\?DTE subaddress may not exceed 15 characters\]
	CALL	.SOUTR			; COMPLAIN
	RET


.DEFCF:	CONFIRM

; HERE TO ADD A HOST TO THE TABLE (OR CHANGE THE ENTRY IF IT EXISTS ALREADY)

ADDDEF:
	MOVEI	T1,DTETAB		; POINT TO THE TABLE
	MOVE	T2,[POINT 7,DFHOST]	; POINTER TO THE HOST NAME TO LOOK FOR
	TBLUK
	TXNN	T2,TL%EXM		; WAS THERE AN EXACT MATCH?
	JRST	ADDTBL			; NO, GO ADD IT TO THE TABLE
	HLRZ	P1,(T1)			; POINT TO THE DESTINATION
	HRRZ	P2,P1			; POINT TO DEST IN RH
	HRLI	P2,DFHOST		; POINT TO SOURCE, DEST ALREADY IN RH
	BLT	P2,^D11(P1)		; AND MOVE THE DATA
	RET				; AND RETURN

ADDTBL:
	CALL	FNDTBL			; FIND THE FIRST FREE TABLE ENTRY
	CAIE	P1,0			; WAS THERE A FREE SLOT?
	JRST	ADDTB1			; YES, GO ADD THE HOST
	HRROI	T1,[ASCIZ\?No room to add another REMOTE-HOST\]
	CALL	.SOUTR			; GO COMPLAIN
	RET				; AND RETURN

ADDTB1:	MOVEI	T1,DTETAB		; POINT TO THE TABLE
	HRLZ	T2,P1			; MAKE TABLE ENTRY ARG
	HRRZ	P2,P1			; POINT TO DEST IN RH
	HRLI	P2,DFHOST		; POINT TO SOURCE, DEST ALREADY IN RH
	BLT	P2,^D11(P1)		; AND MOVE THE DATA
	TBADD				; NOW ADD IT TO THE TABLE
	RET

; HERE TO FIND A SLOT IN DTEDAT
; RETURN ADDR OF FREE SLOT IN P1...
; ZERO RETURNED IN P1 IF DTEDAT IS FULL

FNDTBL:	MOVEI	P1,DTEDAT		; POINT TO THE TOP BLOCK
FNDTB1:	SKIPN	(P1)			; FIRST WORD OF THIS BLOCK ZERO?
	RET				; YES, RETURN THE ADDRESS TO CALLER
	ADDI	P1,^D12			; POINT TO NEXT BLOCK
	CAIGE	P1,DTEEND		; AT THE END?
	JRST	FNDTB1			; NO, TRY AGAIN
	SETZ	P1,			; YES, THE TABLE IS FULL SO ZERO P1
	RET				; AND RETURN



; HERE TO DELETE A HOST DEFINITION (IF ONE EXISTS)

DELDEF:
	CONFIRM
	MOVEI	T1,DTETAB		; POINT TO THE TABLE
	MOVE	T2,[POINT 7,DFHOST]	; POINT TO THE NAME TO LOOK FOR
	TBLUK				; LOOK FOR THIS ENTRY
	TXNN	T2,TL%EXM		; AN EXACT MATCH?
	RET				; NO, JUST RETURN
	HLRZ	P1,(T1)			; POINT TO THE ARG BLOCK
	SETZM	(P1)			; ZERO THE ENTRY
	MOVE	T2,T1			; MOVE THE ENTRY TO BE DELETED TO T2
	MOVEI	T1,DTETAB		; POINT TO THE TABLE
	TBDEL				; AND DELETE THE ENTRY
	RET
	SUBTTL	EXIT COMMAND

.EXIT:
	NOISE (from X29PAD)
	CONFIRM
	SKIPE	CALLCT			; WAS THERE A CALL STILL IN PROGRESS?
	CALL	NETTRM			; YES, CLEAR IT!!!
	CALL	NOLOG			; TERMINATE LOGGING
	HALTF				; RETURN TO EXEC
	RET				; CONTINUE PUTS US BACK IN THE PARSER
	SUBTTL	HELP COMMAND

.HELP:
	NOISE (with)
	MOVEI	T2,[FLDDB. .CMKEY,,HLPTAB,<>,,GENRIC]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; WHO PARSED THIS FIELD?
	CAIN	T3,GENRIC		; JUST CONFIRMED?
	JRST	.HELP1			; YES, GIVE GENERAL HELP MESSAGE
	HRRZ	T2,(T2)
	JRST	(T2)

HLPTAB:	HLPTBL,,HLPTBL			; ACTUAL,,MAXIMUM NUMBER OF ENTRIES
	TBL (ABORT,,.HABO)
	TBL (BREAK,,.HBRK)
	TBL (CALL,,.HCALL)
	TBL (CLEAR,,.HCLEA)
	TBL (CLOSE,,.HCLOS)
	TBL (CONTINUE,,.HCONT)
	TBL (DEFINE,,.HDEFI)
	TBL (EXIT,,.HEXIT)
	TBL (HELP,,.HHELP)
	TBL (INFORMATION,,.HINFO)
	TBL (LOG,,.HLOG)
	TBL (PUSH,,.HPUSH)
	TBL (SEND,,.HSEND)
	TBL (SET,,.HSET)
	TBL (TAKE,,.HTAKE)
	TBL (X29PAD,,.HX29P)
HLPTBL==<.-HLPTAB>-1			; NUMBER OF ENTRIES IN THE TABLE
.HELP1:
	SKIPE	LOGJFN
	CALL	LOG
	HRROI	T1,.HMINI
	CALL	.SOUT
	RET

.HMINI:	ASCIZ\ X29PAD is a program which will allow a user to "SET HOST" to a remote
 system through the X.25 Gateway. The remote host need not be a DEC
 computer. X29PAD has the following commands:

        ABORT           Terminate the transfer of a file to the remote-host
	BREAK		Initiate a BREAK sequence and CONTINUE (if possible)
        CALL            Initiate a call to a selected REMOTE-HOST
        CLEAR           Clear a call that was in progress
        CLOSE           Close the log file opened by the LOG command
	CONTINUE	Continue a call that was interrupted by the user
        DEFINE          Define a REMOTE-HOST in terms of its DTE address
        EXIT            Exit to the EXEC
        HELP            Give help with X29PAD's commands and operation
        INFORMATION     Give information on various parameters in X29PAD
        LOG             Record the terminal session in a designated log file
        PUSH            Push to a new EXEC
        SEND            Send a file to the remote-host
        SET             Set one of X29PAD's parameters
        TAKE            Take a command file

 To learn how to obtain more information, type:

  X29PAD> HELP (with) HELP
\
; HERE TO GIVE HELP WITH THE "ABORT" COMMAND

.HABO:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMABO
	CALL	.SOUT
	RET

.HMABO:	ASCIZ\
 The ABORT command allows the user to stop the sending of a file to the
 REMOTE-HOST. After the user issues the ABORT command the user may elect
 to SEND another file or just CONTINUE the terminal session with the
 REMOTE-HOST. The format of this command is:

    X29PAD>ABORT (the transmition of the file currently being sent)

 There are no arguments to this command.
\
; HERE TO GIVE HELP WITH THE "BREAK" COMMAND

.HBRK:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMBRK
	CALL	.SOUT
	RET


.HMBRK:	ASCIZ\ The BREAK command is used to initiate a break sequence and then
 continue the session if possible. The BREAK command will cause
 execution of actions specified by the ACTION-ON-BREAK PAD Parameter.

\
; HERE TO GIVE HELP WITH THE "CALL" COMMAND

.HCALL:
	MOVEI	T2,[FLDDB. .CMKEY,,HCATAB,<>,,GENRIC]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; WHO PARSED THIS FIELD?
	CAIN	T3,GENRIC		; JUST CONFIRMED?
	JRST	.HCAL1			; YES, GIVE THE GENERAL HELP CALL MSG
	HRRZ	T2,(T2)
	JRST	(T2)

HCATAB:	HCATBL,,HCATBL
	TBL (ABORT,,.HCABO)
	TBL (CLOSED-USER-GROUP,,.HCCUG)
	TBL (FACILITIES-DATA,,.HCFAC)
	TBL (HELP,,.HCHEL)
	TBL (INFORMATION,,.HCINF)
	TBL (USER-DATA,,.HCUSD)
HCATBL==<.-HCATAB>-1
; HERE TO PROCESS A HELP CALL COMMAND

.HCAL1:
	HRROI	T1,.HMCAL
	CALL	.SOUT
	RET

.HMCAL:	ASCIZ\ The CALL command is used to initiate a terminal session with a remote host.
 The command format is:

  X29PAD>CALL remote-host-name

 where the remote-host-name has been defined previously using the DEFINE
 command. Typing a ? after CALL will list the names of the remote hosts that
 have been defined up to that point. Optionally, you may elect to supply the
 actual DTE address and subaddress. This format is:

  X29PAD>CALL dte-address dte-subaddress

 where dte-address and dte-subaddress are the numbers of the REMOTE-HOST
 you wish to call.

 You may enter subcommands by typing a COMMA and a RETURN following the name
 or number of the REMOTE-HOST you are calling. For information on subcommands
 type:

  X29PAD>HELP (with) CALL ?

 If you have not already supplied a network name and password (using the
 SET NETWORK command) you will be asked to supply them before the call to
 the remote-host will be placed.
\
; HERE TO PROCESS HELP CALL ABORT

.HCABO:	NOISE (subcommand)
	CONFIRM
	HRROI	T1,.HMCAS
	CALL	.SOUT
	RET

.HMCAS:	ASCIZ\ The ABORT subcommand allows the user to exit from the CALL subcommand mode
 return to X29PAD command mode without placing the outgoing call. The format
 of this command is:

	X29PAD-CALL>ABORT (this attempt to place a call)

 Any data entered in subcommand mode is lost if the user ABORTS the call.
\
; HERE TO PROCESS HELP CALL CLOSED-USER-GROUP

.HCCUG:	NOISE (subcommand)
	CONFIRM
	HRROI	T1,.HMCCS
	CALL	.SOUT
	RET

.HMCCS:	ASCIZ\ The CLOSED-USER-GROUP subcommand allows the user to specify CLOSED-USER-GROUP
 data in the form of a quoted string. The format of this command is:

	X29PAD-CALL>CLOSED-USER-GROUP (is) argument

 where argument is a quoted string of up to sixteen characters in length.
 If specified, the CLOSED-USER-GROUP subcommand overrides any default
 previously specified by the SET DEFAULT CALL CLOSED-USER-GROUP command.
 Also, if specified, data supplied by the user is valid for a particular
 call and must be resupplied for any subsequent outgoing calls.
\
; HERE TO PROCESS HELP CALL HELP

.HCHEL:	NOISE (subcommand)
	CONFIRM
	HRROI	T1,.HMCHS
	CALL	.SOUT
	RET

.HMCHS:	ASCIZ\ The HELP subcommand allows the user to obtain help with CALL subcommands
 without having to abort the current outgoing call and return to the top
 command level. The HELP subcommand provides help with those subcommands
 available in CALL subcommand mode. The format of this command is:

	X29PAD-CALL>HELP (with) argument

 where argument is optional and if supplied is one of the available subcommands.
\
; HERE TO PROCESS HELP CALL INFORMATION

.HCINF:	NOISE (subcommand)
	CONFIRM
	HRROI	T1,.HMCIS
	CALL	.SOUT
	RET

.HMCIS:	ASCIZ\ The INFORMATION subcommand allows the user to examine call data that has
 been entered and will be used for the current outgoing call. The format of
 this command is:

	X29PAD-CALL>INFORMATION (about current CALL parameters)

 The INFORMATION subcommand will display any data the user has supplied in
 subcommand mode. If a specific parameter has not been modified by the user
 in subcommand mode the default data will be displayed (and noted).
\
; HERE TO PROCESS HELP CALL FACILITIES-DATA

.HCFAC:
	NOISE (subcommand)
	CONFIRM
	HRROI	T1,.HMCFS
	CALL	.SOUT
	RET

.HMCFS:	ASCIZ\ The FACILITIES-DATA subcommand allows the user to set FACILITIES-DATA on
 a per call basis. The format of this command is:

  X29PAD-CALL>FACILITIES-DATA (are) arguments

 where the arguments are either octal data in the range 0 to 377 or quoted
 ASCII strings. For example, the following command:

  X29PAD-CALL>FACILITIES-DATA (are) 1 1 0 0 "A2" 3 21

 sets the FACILITIES-DATA string for this call to:

	<1><1><0><0>A2<3><21>

 Note: Default FACILITIES-DATA are overridden by data supplied by the
       user to the FACILITIES-DATA subcommand to the CALL command.
       Issuing the FACILITIES-DATA subcommand without supplying data
       clears the FACILITIES-DATA data string for this call.

\
; HERE TO PROCESS A HELP CALL USER-DATA COMMAND

.HCUSD:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMCUS
	CALL	.SOUT
	RET

.HMCUS: ASCIZ\The USER-DATA subcommand allows the user to set USER-DATA on a per call
 basis. The format of this command is:

  X29PAD-CALL>USER-DATA (are) arguments

 where the arguments are either octal data in the range 0 to 377 or quoted
 ASCII strings. For example, the following command:

  X29PAD-CALL>USER-DATA (are) 1 1 0 0 "A2" 3 21

 sets the default USER-DATA string to:

	<1><0><0><0><1><1><0><0>A2<3><21>

 Issuing the USER-DATA subcommand without supplying data clears the default
 data string.

 Note: Default USER-DATA are overridden by data supplied by the user to the
       USER-DATA subcommand to the CALL command. Also, there is a mandatory
       four byte string that prefixes any user supplied data. The string is
       <1><0><0><0> and indicates to the REMOTE-HOST that the call is an X.29
       call.

\
; HERE TO GIVE HELP WITH THE "CLEAR" COMMAND

.HCLEA:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMCLE
	CALL	.SOUT
	RET

.HMCLE:	ASCIZ\ The CLEAR command is used to disconnect a call initiated by a CALL command.
 The form of the CLEAR command is:

  X29PAD>CLEAR

 There are no arguments or options for this command.

\
; HERE TO GIVE HELP WITH THE "CLOSE" COMMAND

.HCLOS:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMCLO
	CALL	.SOUT
	RET

.HMCLO:	ASCIZ\ The CLOSE command terminates session logging and closes the log file that
 was initiated by using the LOG command. The format of the command is:

  X29PAD>CLOSE (log file!)

\
; HERE TO GIVE HELP WITH THE "CONTINUE" COMMAND

.HCONT:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMCON
	CALL	.SOUT
	RET

.HMCON:	ASCIZ\ The CONTINUE command allows the user to continue a call that was
 interrupted by the typing of the ESCAPE-CHARACTER to return to
 command mode. The format of this command is:

  X29PAD>CONTINUE (current call)

 The CONTINUE command will attempt to restart communications with
 the REMOTE-HOST and will notify the user if this is not possible.

\
; HERE TO GIVE HELP WITH THE "DEFINE" COMMAND

.HDEFI:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMDEF
	CALL	.SOUT
	RET

.HMDEF:	ASCIZ\ The DEFINE command is used to associate the name of a remote host with
 a DTE address and (optionally) a DTE subaddress. The format of this
 command is:

  X29PAD>DEFINE remote-host-name (to be) dte-address dte-subaddress

 where the remote-host-name is an alphanumeric string of up to 16 characters
 in length and dte-address and dte-subaddress are numeric strings of up to
 15 digits in length.

 The DEFINE command may also be used to remove a remote host from the remote
 host table. This is done by typing a carriage return after the name of the
 remote host you wish to delete. The format is:

  X29PAD>DEFINE remote-host-name <carriage-return>

 The DEFINE command may also be used to change the DTE address and subaddress
 of a remote host that has already been defined by simply defining the remote
 host again. The entry for this remote host will be updated in the remote host
 table.

\
.HEXIT:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMEXI
	CALL	.SOUT
	RET

.HMEXI:	ASCIZ\ The EXIT command causes X29PAD to return the user to TOPS20 command mode.
 If a CALL to a REMOTE-HOST is still in progress it will be cleared. If
 LOGGING was being done, the log file will be closed and logging terminated.
 Typing the TOPS20 CONTINUE command will cause X29PAD to resume execution,
 but you must re-enable logging manually.
\
.HHELP:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMHEL
	CALL	.SOUT
	RET

.HMHEL:	ASCIZ\ The HELP command is the way a user can obtain more detailed information
 relating to the operation of X29PAD than available through the inline
 help facility (i.e. "?"). The format of the HELP command is:

  X29PAD>HELP (with) argument-1 argument-2 ... argument-n

 where argument is a key word in the context of the command it is found in.
 For example, typing the following:

  X29PAD>HELP (with) SET PAD-PARAMETER IDLE-TIMER <carriage-return>

 would give you a description of the IDLE-TIMER parameter which is changeable
 via the SET command.

 In all cases, typing a ? at any point will give you a list of optional
 key words you may elect to supply or you may type a carriage-return at
 any point to receive information about the last key word typed in context.

\
.HINFO:
	MOVEI	T2,[FLDDB. .CMKEY,,HINTAB,<>,,GENRIC]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; WHO PARSED THIS FIELD?
	CAIN	T3,GENRIC		; JUST CONFIRMED?
	JRST	.HINF1			; YES, GIVE THE GENERAL HELP INFO MSG
	HRRZ	T2,(T2)
	JRST	(T2)

HINTAB:	HINTBL,,HINTBL
	TBL (DEFAULTS,,.HIDEF)
	TBL (LAST-NETWORK-ERROR,,.HINET)
	TBL (PAD-PARAMETERS,,.HIPAR)
	TBL (REMOTE-HOSTS,,.HIREM)
	TBL (STATUS,,.HISTA)
	TBL (VERSION,,.HIVER)
HINTBL==<.-HINTAB>-1
.HINF1:
	SKIPE	LOGJFN
	CALL	LOG
	HRROI	T1,.HMINF
	CALL	.SOUT
	RET

.HMINF:	ASCIZ\ The INFORMATION command allows you to obtain information about various
 parameters and topics in X29PAD. The format of this command is:

  X29PAD>INFORMATION (about) argument

 where the user supplied argument is one of the following:

        DEFAULTS        LAST-NETWORK-ERROR      PAD-PARAMETERS
        REMOTE-HOSTS    STATUS                  VERSION

 For more help with any of these arguments, type:

  X29PAD>HELP (with) INFORMATION argument

\
.HIDEF:
	MOVEI	T2,[FLDDB. .CMKEY,,HIDTAB,<>,,GENRIC]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; WHO PARSED THIS FIELD?
	CAIN	T3,GENRIC		; JUST CONFIRMED?
	JRST	.HIND1			; YES, GIVE THE GENERAL DEFAULTS MSG
	HRRZ	T2,(T2)
	JRST	(T2)

HIDTAB:	HIDTBL,,HIDTBL
	TBL (CALL,,.HIDC)
	TBL (LOG,,.HIDL)
	TBL (SEND,,.HIDS)
	TBL (TAKE,,.HIDT)
HIDTBL==<.-HIDTAB>-1
.HIND1:
	SKIPE	LOGJFN
	CALL	LOG
	HRROI	T1,.HMIND
	CALL	.SOUT
	RET

.HMIND:	ASCIZ\ The INFORMATION (about) DEFAULTS command allows you to obtain information
 about default parameters for X29PAD commands. The format of this command is:

  X29PAD>INFORMATION (about) DEFAULTS (for) argument

 where the user supplied argument is one of the following:

	CALL          LOG           SEND           TAKE

\
; HERE TO PROCESS HELP INFORMATION DEFAULTS CALL COMMAND

.HIDC:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMIDC
	CALL	.SOUT
	RET

.HMIDC:	ASCIZ\ The INFORMATION (about) DEFAULTS (for) CALL displays the current default
 values and conditions for the CALL command.

\
; HERE TO PROCESS HELP INFORMATION DEFAULTS LOG COMMAND

.HIDL:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMIDL
	CALL	.SOUT
	RET

.HMIDL:	ASCIZ\ The INFORMATION (about) DEFAULTS (for) LOG displays the current default
 values and conditions for the LOG command.

\
; HERE TO PROCESS HELP INFORMATION DEFAULTS SEND COMMAND

.HIDS:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMIDS
	CALL	.SOUT
	RET

.HMIDS:	ASCIZ\ The INFORMATION (about) DEFAULTS (for) SEND command displays the current
 default values and conditions for the SEND command.
\
; HERE TO PROCESS HELP INFORMATION DEFAULTS TAKE COMMAND

.HIDT:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMIDT
	CALL	.SOUT
	RET

.HMIDT:	ASCIZ\ The INFORMATION (about) DEFAULTS (for) TAKE displays the current default
 values and conditions for the TAKE command.

\
; HERE TO PROCESS THE INFORMATION LAST-NETWORK-ERROR COMMAND

.HINET:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMINE
	CALL	.SOUT
	RET

.HMINE:	ASCIZ\ The INFORMATION (about) LAST-NETWORK-ERROR command gives the user a more
 verbose description (and possible causes) of the last reported network
 error. The format of the command is:

  X29PAD>INFORMATION (about) LAST-NETWORK-ERROR

\
; HERE TO GIVE HELP ON "INFORMATION PAD-PARAMETERS" COMMAND

.HIPAR:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMIPA
	CALL	.SOUT
	RET

.HMIPA:	ASCIZ\ The INFORMATION (about) PAD-PARAMETERS command allows the user to
 display the current state of the PAD. The PAD (Packet Assembly and
 Disassembly) parameters are the values that determine how the terminal
 will act and exchange data with the remote-host. PAD parameters may be
 set either by the remote-host or by the user via the SET PAD-PARAMETER
 command. PAD parameters set by the remote-host are denoted by a star (*)
 preceeding the parameter. The format of the command is:

  X29PAD>INFORMATION (about) PAD-PARAMETERS

 For more information on specific PAD parameters, type:

  X29PAD>HELP (with) SET PAD-PARAMETER argument

 where the argument is one of the following:

 ACTION-ON-BREAK          CANCEL-CHARACTER         CARRIAGE-RETURN-PADDING
 DATA-FORWARDING          DELETE-CHARACTER         DISCARD-OUTPUT
 DISPLAY-CHARACTER        DTE-TO-NET-FLOW-CONTROL  ECHO
 ESCAPE-TO-COMMAND-MODE   IDLE-TIMER               LINE-WIDTH
 LINEFEED-INSERTION       LINEFEED-PADDING         LOCAL-EDITING
 NET-TO-DTE-FLOW-CONTROL  PAD-SIGNAL-CONTROL       RATE

\
; HERE TO GIVE HELP ON "INFORMATION REMOTE-HOSTS" COMMAND

.HIREM:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMIRE
	CALL	.SOUT
	RET

.HMIRE:	ASCIZ\ The INFORMATION (about) REMOTE-HOSTS command provides the user with
 a list of REMOTE-HOSTS that have been defined via the DEFINE command.
 Each REMOTE-HOST will have diaplayed the DTE address and (optionally)
 the DTE subaddress associated with it.

 The format of the command is:

  X29PAD>INFORMATION (about) REMOTE-HOSTS

\
.HISTA:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMIST
	CALL	.SOUT
	RET

.HMIST:	ASCIZ\ The INFORMATION (about) STATUS (of X29PAD) command gives the user a summary
 of X29PAD's state and counter information. It also displays the current
 NETWORK NAME and PASSWORD, ESCAPE-CHARACTER, and STATUS-DISPLAY-CHARACTER.
 The format of this command is:

  X29PAD>INFORMATION (about) STATUS (of X29PAD)

\
.HIVER:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMIVE
	CALL	.SOUT
	RET

.HMIVE:	ASCIZ\ The INFORMATION (about) VERSION command displays the version number and
 edit number of X29PAD and the version and edit numbers of the X.25 Gateway
 Access Module loaded with X29PAD.

\
; HERE TO GIVE HELP ON "LOG" COMMAND

.HLOG:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMLOG
	CALL	.SOUT
	RET

.HMLOG:	ASCIZ\ The LOG command causes your terminal session to be recorded in a file
 specified by the user. The format of this command is:

  X29PAD>LOG (output to file) output filespec

 where output filespec is the filename the user wishes to call the log
 file.

\
; HERE TO GIVE HELP ON "PUSH" COMMAND

.HPUSH:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMPUS
	CALL	.SOUT
	RET

.HMPUS:	ASCIZ\ The PUSH command is analogous to the TOPS20 Monitor PUSH command. This
 command allows you to push to a new copy of the TOPS20 EXEC and pop back
 into X29PAD at some later point in time. Popping back from the new EXEC
 does not discard the EXEC you pushed to or any subsequent programs running
 under it. You may PUSH back down to that EXEC and continue any programs
 started by that EXEC.

\
; HERE TO GIVE HELP ON "SEND" COMMAND

.HSEND:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMSEN
	CALL	.SOUT
	RET

.HMSEN:	ASCIZ\ The SEND command instructs X29PAD to read the specified file and send it
 line by line to the REMOTE-HOST as if the use had typed it. The format of
 the SEND command is:

    X29PAD>SEND (file) argument (to the REMOTE-HOST)

 where argument is the name of the file the user wishes to send. During the
 sending of a file all keyboard input from the user is ignored and discarded
 except for the ESCAPE-CHARACTER, STATUS-DISPLAY-CHARACTER, and BREAK-CHARACTER.
 A SEND command may be stopped by typing the ESCAPE-CHARACTER to return to
 command mode followed by the ABORT command.

 The SEND command attempts (by default) to discard the LINEFEED from a CARRIAGE
 RETURN / LINEFEED sequence. The SEND command will also pause for one second
 (again, the default) after each line sent to the REMOTE-HOST. These values
 may be changed by using the SET DEFAULT SEND command.

 CAUTION: The SEND command does not process characters from the input file
 in the same way characters typed by the user are processed. The SEND command
 reads the input file and sends a line at a time to the REMOTE-HOST. A line
 is a string of characters terminated by a CARRIAGE RETURN. In SEND mode the
 X.3 PAD-PARAMETERS are not taken into consideration and have no effect of the
 data sent to the REMOTE-HOST.
\
; HERE TO PARSE "HELP SET"

.HSET:
	MOVEI	T2,[FLDDB. .CMKEY,,HSETAB,<>,,GENRIC]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; LETS FIND OUT WHO PARSED
	CAIN	T3,GENRIC		; JUST CONFIRM?
	JRST	.HSET1			; YES, GO PRINT SET HELP MESSAGE
	HRRZ	T2,(T2)			; NO, GET POINTER
	JRST	(T2)			; AND DISPATCH


.HSET1:
	SKIPE	LOGJFN
	CALL	LOG
	HRROI	T1,.HMSET
	CALL	.SOUT
	RET

.HMSET:	ASCIZ\ The SET command allows you to change or set various parameters and
 values used by X29PAD. The format of this command is:

  X29PAD>SET argument-1 argument-2 ... argument-n

 where argument-1 is one of the following:

 BREAK-CHARACTER        DEFAULT                ESCAPE-CHARACTER
 NETWORK                PAD-PARAMETER          STATUS-DISPLAY-CHARACTER

 and argument-2 through argument-n are dependent on argument-1. For more
 information type:

  X29PAD>HELP SET argument-1 argument-2 ... argument-n

 Use "?" to find out what specific options are available for each argument.

\

HSETAB:	HSETBL,,HSETBL			; ACTUAL,,MAXIMUM NUMBER OF ENTRIES
	TBL (BREAK-CHARACTER,,.HSBRK)
	TBL (DEFAULT,,.HSDEF)
	TBL (ESCAPE-CHARACTER,,.HSESC)
	TBL (NETWORK,,.HSNT)
	TBL (PAD-PARAMETER,,.HSPAD)
	TBL (STATUS-DISPLAY-CHARACTER,,.HSSTA)
HSETBL==<.-HSETAB>-1
; HERE TO GIVE HELP ON "SET BREAK-CHARACTER" COMMAND

.HSBRK:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMSBR
	CALL	.SOUT
	RET

.HMSBR:	ASCIZ/ The SET BREAK-CHARACTER command allows you to define a special character
 which, when typed, will cause X29PAD to perform the actions defined by
 the ACTION-ON-BREAK PAD Parameter. This action might be to discard pending
 terminal output or possibly reset the network. The format of the command is:

  X29PAD>SET BREAK-CHARACTER (to) argument

 where argument is the octal value for the ASCII character code you wish to
 be the escape character or any printing character in double quotes. An
 alternate form of this command is:

  X29PAD>SET BREAK-CHARACTER (to) CONTROL argument

 This form of the command is used to define the BREAK-CHARACTER to be a
 control character. The user supplied argument is a printing character in
 double quotes. For example, to set the BREAK-CHARACTER to CONTROL-P you
 would type:

  X29PAD>SET BREAK-CHARACTER (to) CONTROL "P"

 Note that the default BREAK-CHARACTER is CONTROL-X.

/
; HERE TO GIVE HELP ON "SET ESCAPE-CHARACTER" COMMAND

.HSESC:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMSES
	CALL	.SOUT
	RET

.HMSES:	ASCIZ/ The SET ESCAPE-CHARACTER command allows you to define a special character
 which, when typed, will cause X29PAD to return you to command mode. The
 format of the command is:

  X29PAD>SET ESCAPE-CHARACTER (to) argument

 where argument is the octal value for the ASCII character code you wish to
 be the escape character or any printing character in double quotes. An
 alternate form of this command is:

  X29PAD>SET ESCAPE-CHARACTER (to) CONTROL argument

 This form of the command is used to define the ESCAPE-CHARACTER to be a
 control character. The user supplied argument is a printing character in
 double quotes. For example, to set the ESCAPE-CHARACTER to CONTROL-P you
 would type:

  X29PAD>SET ESCAPE-CHARACTER (to) CONTROL "P"

 Note that the default ESCAPE-CHARACTER is CONTROL-\.

/
; HERE TO PARSE "HELP SET NETWORK" 

.HSNT:
	MOVEI	T2,[FLDDB. .CMKEY,,HSNTAB,<>,,GENRIC]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; LETS FIND OUT WHO PARSED
	CAIN	T3,GENRIC		; JUST CONFIRM?
	JRST	.HSNT1			; YES, GO PRINT SET HELP MESSAGE
	HRRZ	T2,(T2)			; NO, GET POINTER
	JRST	(T2)			; AND DISPATCH


.HSNT1:
	SKIPE	LOGJFN
	CALL	LOG
	HRROI	T1,.HMSNT
	CALL	.SOUT
	RET

.HMSNT:	ASCIZ\ The SET NETWORK command allows the user to set either the NETWORK NAME
 or the NETWORK PASSWORD for the PSI GATEWAY the user wishes to access.
 The format of this command is:

  X29PAD>SET NETWORK argument-1 argument-2

 where argument-1 is either NAME or PASSWORD and argument-2 is dependent
 on argument-1.

 For more information, type:

  X29PAD>HELP (with) SET NETWORK NAME

                 or

  X29PAD>HELP (with) SET NETWORK PASSWORD

\


HSNTAB:	HSNTBL,,HSNTBL
	TBL (NAME,,.HSNEN)
	TBL (PASSWORD,,.HSNEP)
HSNTBL=<.-HSNTAB>-1
; HERE TO GIVE HELP WITH THE "SET NETWORK NAME" COMMAND

.HSNEN:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMSNN
	CALL	.SOUT
	RET

.HMSNN:	ASCIZ\ The SET NETWORK NAME command allows the user to set the name of the
 network he wishes. The format of this command is:

  X29PAD>SET NETWORK NAME (to) argument-1

 where argument-1 is the name supplied by your network manager.

 Please note that this name is assigned by the network manager and may
 be bear no association to the actual PPSN you buy services from.

\
; HERE TO GIVE HELP WITH THE "SET NETWORK PASSWORD" COMMAND

.HSNEP:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMSNP
	CALL	.SOUT
	RET

.HMSNP:	ASCIZ\ The SET NETWORK PASSWORD command allows the user to specify the password
 required to access the X.25 PSI Gateway. The form of the command is:

  X29PAD>SET NETWORK PASSWORD (to) argument-1

 where argument-1 is the Gateway access password supplied by your network
 manager.

\
; HERE TO PARSE "HELP SET DEFAULT"

.HSDEF:
	MOVEI	T2,[FLDDB. .CMKEY,,HSDTAB,<>,,GENRIC]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; WHO PARSED THIS TIME
	CAIN	T3,GENRIC		; JUST CONFIRM?
	JRST	.HSDE1			; YES
	HRRZ	T2,(T2)
	JRST	(T2)

.HSDE1:
	SKIPE	LOGJFN
	CALL	LOG
	HRROI	T1,.HMSDE
	CALL	.SOUT
	RET

.HMSDE:	ASCIZ\ The SET DEFAULT command allows you to set default values for certain X29PAD
 command parameters. These parameters affect the actions performed by the
 specified command. The format of this command is:

  X29PAD>SET DEFAULT (for) argument-1 argument-2 ... argument-n

 where argument-1 is one of the following:

        CALL       LOG        SEND         TAKE

 and argument-2 through argument-n are dependent on argument-1.

 For more help, type:

  X29PAD>HELP (with) SET DEFAULT argument

 where argument is one of the above choices.

\

HSDTAB:	HSDTBL,,HSDTBL
	TBL (CALL,,.HSDCA)
	TBL (LOG,,.HSDLO)
	TBL (SEND,,.HSDSE)
	TBL (TAKE,,.HSDTK)
HSDTBL==<.-HSDTAB>-1
; HERE TO PARSE "HELP SET DEFAULT CALL"

.HSDCA:
	MOVEI	T2,[FLDDB. .CMKEY,,HDCTAB,<>,,GENRIC]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; WHO PARSED?
	CAIN	T3,GENRIC		; CONFIRM?
	JRST	.HSDC1			; YES
	HRRZ	T2,(T2)
	JRST	(T2)

.HSDC1:
	SKIPE	LOGJFN
	CALL	LOG
	HRROI	T1,.HMSDC
	CALL	.SOUT
	RET

.HMSDC:	ASCIZ\ The SET DEFAULT CALL command allows you to set certain defaults for the
 CALL command. The format of this command is

  X29PAD>SET DEFAULT (for) CALL (to) argument-1 argument-2

 where argument-1 is one of the following:

  CLOSED-USER-GROUP    FACILITIES-DATA      USER-DATA

 For more information concerning these options, type:

  X29PAD>HELP SET DEFAULT CALL argument

\

HDCTAB:	HDCTBL,,HDCTBL
	TBL (CLOSED-USER-GROUP,,.HSDCC)
	TBL (FACILITIES-DATA,,.HSDCF)
	TBL (USER-DATA,,.HSDCU)
HDCTBL==<.-HDCTAB>-1
; HERE TO PARSE "HELP SET DEFAULT CALL CLOSED-USER-GROUP"

.HSDCC:	NOISE (command)
	CONFIRM
	HRROI	T1,.HMSCC
	CALL	.SOUT
	RET

.HMSCC:	ASCIZ\ The SET DEFAULT CALL CLOSED-USER-GROUP command allows the user to specify
 default CLOSED-USER-GROUP data in the form of a quoted string. The format
 of this command is:

	X29PAD>SET DEFAULT CALL CLOSED-USER-GROUP (to) argument

 where argument is a quoted string of up to sixteen characters in length.

 For example, to set the default CLOSED-USER-GROUP to "FUNNY-FARM" one would
 type the following:

	X29PAD>SET DEFAULT CALL CLOSED-USER-GROUP "FUNNY-FARM"

 Note: Default the CLOSED-USER-GROUP is overridden by data supplied by the
       user to the CLOSED-USER-GROUP subcommand to the CALL command.
\
; HERE TO PARSE "HELP SET DEFAULT CALL FACILITIES-DATA"

.HSDCF:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMSCF
	CALL	.SOUT
	RET

.HMSCF:	ASCIZ\ The SET DEFAULT CALL FACILITIES-DATA command allows the user to specify
 default FACILITIES-DATA to be used when placing an outgoing call. The format
 of this command is:

 X29PAD>SET DEFAULT (for) CALL FACILITIES-DATA (to) argument-1 argument-2 ...

 where the arguments are either octal data in the range 0 to 377 or quoted
 ASCII strings. For example, the following command:

 X29PAD>SET DEFAULT (for) CALL FACILITIES-DATA (to) 1 1 0 0 "A2" 3 21

 sets the default FACILITIES-DATA string to:

	<1><1><0><0>A2<3><21>

 Issuing the SET DEFAULT (for) CALL FACILITIES-DATA command without supplying
 data clears the default data string.

 Note: Default FACILITIES-DATA are overridden by data supplied by the user to
       the FACILITIES-DATA subcommand to the CALL command.

\
; HERE TO PARSE "HELP SET DEFAULT CALL USER-DATA"

.HSDCU:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMSCU
	CALL	.SOUT
	RET

.HMSCU:	ASCIZ\ The SET DEFAULT CALL USER-DATA command allows the user to specify default
 USER-DATA to be used when placing an outgoing call. The format is:

 X29PAD>SET DEFAULT (for) CALL USER-DATA (to) arguments

 where the arguments are either octal data in the range 0 to 377 or quoted
 ASCII strings. For example, the following command:

 X29PAD>SET DEFAULT (for) CALL USER-DATA (to) 1 1 0 0 "A2" 3 21

 sets the default USER-DATA string to:

	<1><0><0><0><1><1><0><0>A2<3><21>

 Issuing the SET DEFAULT (for) CALL USER-DATA command without supplying data
 clears the default data string.

 Note: Default USER-DATA are overridden by data supplied by the user to the
       USER-DATA subcommand to the CALL command. Also, there is a mandatory
       four byte string that prefixes any user supplied data. The string is
       <1><0><0><0> and indicates to the REMOTE-HOST that the call is an X.29
       call.
\
; HERE TO PARSE "HELP SET DEFAULT LOG"

.HSDLO:
	MOVEI	T2,[FLDDB. .CMKEY,,HDLTAB,<>,,GENRIC]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; WHO PARSED?
	CAIN	T3,GENRIC		; CONFIRM?
	JRST	.HSDL1			; YES
	HRRZ	T2,(T2)
	JRST	(T2)

.HSDL1:
	SKIPE	LOGJFN
	CALL	LOG
	HRROI	T1,.HMSDL
	CALL	.SOUT
	RET

.HMSDL:	ASCIZ\ The SET DEFAULT LOG command allows you to set certain defaults
 for the LOG command. The format of this command is

  X29PAD>SET DEFAULT (for) LOG (to) argument-1 argument-2

 where argument-1 is one of the following:

  APPEND      NO           SUPERSEDE     SUPPRESS

 For more information concerning these options, type:

  X29PAD>HELP SET DEFAULT LOG argument


\

HDLTAB:	HDLTBL,,HDLTBL
	TBL (APPEND,,.HSDLA)
	TBL (NO,,.HSDLN)
	TBL (SUPERSEDE,,.HSDLS)
	TBL (SUPPRESS,,.HSDLX)
HDLTBL==<.-HDLTAB>-1
; HERE TO PARSE "HELP SET DEFAULT LOG APPEND"

.HSDLA:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMSLA
	CALL	.SOUT
	RET

.HMSLA:	ASCIZ\ The SET DEFAULT LOG APPEND command causes X29PAD to append to an
 existing log file rather than supersede it with a new generation.
 For example, if you specify that the default for logging should be
 APPEND and you issue the LOG command to X29PAD specifying a LOG
 file that already exists, X29PAD will append to the existing LOG
 file.

 You may desire a new generation of LOG file. If so, you may use
 the SET DEFAULT LOG SUPERSEDE command to affect this action.

\
; HERE TO PARSE "HELP SET DEFAULT LOG NO"

.HSDLN:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMSLN
	CALL	.SOUT
	RET

.HMSLN:	ASCIZ\ The SET DEFAULT LOG NO command has only one option available.
 The option is SUPPRESS. This command (SET DEFAULT LOG NO SUPPRESS)
 causes X29PAD to include NULLs transmitted by the remote host in
 the log file. The format of this command is:

  X29PAD>SET DEFAULT (for) LOG (to) NO SUPPRESS (null characters in log file!)

\
; HERE TO PARSE "HELP SET DEFAULT LOG SUPERSEDE"

.HSDLS:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMSLS
	CALL	.SOUT
	RET

.HMSLS:	ASCIZ\ The SET DEFAULT LOG SUPERSEDE command causes X29PAD to create
 a new generation log file whenever session logging is initiated.

\
; HERE TO PARSE "HELP SET DEFAULT LOG SUPPRESS"

.HSDLX:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMSLX
	CALL	.SOUT
	RET

.HMSLX:	ASCIZ\ The SET DEFAULT LOG SUPPRESS command causes X29PAD to discard
 nulls sent by the remote host and not include them in the log file.

\
; HERE TO PARSE "HELP SET DEFAULT SEND"

.HSDSE:
	MOVEI	T2,[FLDDB. .CMKEY,,HDSTAB,<>,,GENRIC]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; WHO PARSED?
	CAIN	T3,GENRIC		; CONFIRM?
	JRST	.HSDS1			; YES
	HRRZ	T2,(T2)
	JRST	(T2)

HDSTAB:	HDSTBL,,HDSTBL
	TBL (PAUSE,,.HSDSP)
	TBL (STRIP,,.HSDSS)
	TBL (TRANSMIT,,.HSDST)
HDSTBL==<.-HDSTAB>-1

.HSDS1:
	SKIPE	LOGJFN
	CALL	LOG
	HRROI	T1,.HMSDS
	CALL	.SOUT
	RET

.HMSDS:	ASCIZ\ The SET DEFAULT SEND command allows the user to change the default values
 for certain SEND command parameters. The format of this command is:

    X29PAD>SET DEFAULT (for) SEND (to) argument-1 argument-2

 where argument-1 is one of the following:

        PAUSE         STRIP         TRANSMIT

 and argument-2 is dependent on argument-1.

 For more information type:

    X29PAD>HELP (with) SET DEFAULT SEND argument

 where argument is one of the above keywords.
\
; HERE TO PARSE "HELP SET DEFAULT SEND PAUSE"

.HSDSP:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSDSP
	CALL	.SOUT
	RET

HMSDSP:	ASCIZ\ The SET DEFAULT SEND PAUSE command allows the user to change the length of
 time the SEND command will pause between messages sent to the REMOTE-HOST.
 The format of this command is:

 X29PAD>SET DEFAULT SEND (to) PAUSE (between transmitted lines) n (seconds)

 where "n" is an integer from 0 to 10. The initial default value is one second.

 This parameter is changeable by the user because some REMOTE-HOSTS may lose
 data sent to them at highspeed. If it appears that data is indeed being lost,
 set the default timer value higher and retry the SEND command.
 \
; HERE TO PARSE "HELP SET DEFAULT SEND STRIP"

.HSDSS:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSDSS
	CALL	.SOUT
	RET

HMSDSS:	ASCIZ\ The SET DEFAULT SEND STRIP command lets the user specify that X29PAD's SEND
 command should remove any LINEFEEDS that immediately follow a CARRIAGE RETURN
 in the input file from the data stream being sent to the REMOTE-HOST. The
 format of this command is:

 X29PAD>SET DEFAULT (for) SEND (to) STRIP (linefeeds following carriage-returns)

 Normal ASCII files in a DECsystem-10 or DECSYSTEM-20 have a LINEFEED inserted
 into the file after a CARRIAGE RETURN automatically. If the REMOTE-HOST you
 are sending the file to also inserts a LINEFEED the resulting file will be
 double spaced. For this reason you will normally want to STRIP out these
 LINEFEEDS.
\
; HERE TO PARSE "HELP SET DEFAULT SEND TRANSMIT"

.HSDST:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSDST
	CALL	.SOUT
	RET

HMSDST:	ASCIZ\
 The SET DEFAULT SEND TRANSMIT command lets the user specify that X29PAD's SEND
 command should send any and all LINEFEEDS encountered in the input file to the
 REMOTE-HOST regardless where they appear. The format of this command is:

 X29PAD>SET DEFAULT (for) SEND (to) TRANSMIT (all linefeeds)

 Normal ASCII files in a DECsystem-10 or DECSYSTEM-20 have a LINEFEED inserted
 into the file after a CARRIAGE RETURN automatically. If the REMOTE-HOST you
 are sending the file to DOES NOT automatically insert a LINEFEED after a
 CARRIAGE RETURN the resulting file will be improperly spaced. For this reason
 you will normally want to change the default action of the SEND command to
 TRANSMIT all LINEFEEDS to the REMOTE-HOST.
\
; HERE TO PARSE "HELP SET DEFAULT TAKE"
.HSDTK:
	MOVEI	T2,[FLDDB. .CMKEY,,HDTTAB,<>,,GENRIC]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; WHO PARSED?
	CAIN	T3,GENRIC		; CONFIRM?
	JRST	.HSDT1			; YES
	HRRZ	T2,(T2)
	JRST	(T2)

.HSDT1:
	SKIPE	LOGJFN
	CALL	LOG
	HRROI	T1,.HMSDT
	CALL	.SOUT
	RET

.HMSDT:	ASCIZ\ The SET DEFAULT TAKE command allows the user to specify and
 control the actions of the TAKE command. The format of this command is:

  X29PAD>SET DEFAULT (for) TAKE (to) argument-1 argument-2

 where argument-1 is one of the following:

   ALLOW     DISALLOW      ECHO        NO

 and argument-2 is dependent on argument-1.

 For more help on the options, type:

  X29PAD>HELP SET DEFAULT TAKE argument

\

HDTTAB:	HDTTBL,,HDTTBL			; ACTUAL,,MAXIMUM NUMBER OF ENTRYS
	TBL (ALLOW,,.HSDTA)
	TBL (DISALLOW,,.HSDTD)
	TBL (ECHO,,.HSDTE)
	TBL (NO,,.HSDTN)
HDTTBL==<.-HDTTAB>-1			; NUMBER OF ENTRYS IN THE TABLE
; HERE TO GIVE HELP ON "SET DEFAULT TAKE ALLOW" COMMAND

.HSDTA:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSDTA
	CALL	.SOUT
	RET

HMSDTA:	ASCIZ\ The SET DEFAULT TAKE ALLOW command causes X29PAD's TAKE command
 processor to ignore errors while processing command files. The
 format of this command is:

  X29PAD>SET DEFAULT (for) TAKE (to) ALLOW (errors during "TAKE" files)

\
; HERE TO GIVE HELP ON "SET DEFAULT TAKE DISALLOW" COMMAND

.HSDTD:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSDTD
	CALL	.SOUT
	RET

HMSDTD:	ASCIZ\ The SET DEFAULT TAKE DISALLOW command causes X29PAD's command
 processor to abort the processing of a command file if an error
 is encountered during processing. The format of this command is:

  X29PAD>SET DEFAULT (for) TAKE (to) DISALLOW (errors during "TAKE" file)

\
; HERE TO GIVE HELP ON "SET DEFAULT TAKE ECHO" COMMAND

.HSDTE:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSDTE
	CALL	.SOUT
	RET

HMSDTE:	ASCIZ\ The SET DEFAULT TAKE ECHO command causes the X29PAD command
 processor to echo all commands taken from a command file via
 the TAKE command. The format of this command is:

  X29PAD>SET DEFAULT (for) TAKE (to) ECHO (commands from "TAKE" file)

\
; HERE TO PARSE "HELP SET DEFAULT TAKE NO"

.HSDTN:
	MOVEI	T2,[FLDDB. .CMKEY,,HTNTAB,<>,,GENRIC]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; WHO PARSED?
	CAIN	T3,GENRIC		; JUST CONFIRM?
	JRST	.HSTN1			; YES
	HRRZ	T2,(T2)
	JRST	(T2)

.HSTN1:
	SKIPE	LOGJFN
	CALL	LOG
	HRROI	T1,HMSDTN
	CALL	.SOUT
	RET

HMSDTN:	ASCIZ\ The SET DEFAULT TAKE NO command has only one option. This option
 is ECHO. The SET DEFAULT TAKE NO ECHO command causes X29PAD's
 command processor to suppress the display of commands taken
 from a command file via the TAKE command. The format of this
 command is:

  X29PAD>SET DEFAULT (for) TAKE (to) NO ECHO (commands from "TAKE" file)

\

HTNTAB:	HTNTBL,,HTNTBL
	TBL (ECHO,,.HSTNE)
HTNTBL==<.-HTNTAB>-1
; HERE TO GIVE HELP ON "SET DEFAULT TAKE NO ECHO" COMMAND

.HSTNE:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSTNE
	CALL	.SOUT
	RET

HMSTNE:	ASCIZ\ The SET DEFAULT TAKE NO ECHO command causes X29PAD's command
 processor to suppress the display of commands taken from
 a command file via the TAKE command. The format of this
 command is:

  X29PAD>SET DEFAULT (for) TAKE (to) NO ECHO (commands from "TAKE" file)


\
; HERE TO PARSE "HELP SET PAD-PARAMETER"

.HSPAD:
	MOVEI	T2,[FLDDB. .CMKEY,,HSPTAB,<>,,GENRIC]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; LETS FIND OUT WHO PARSED
	CAIN	T3,GENRIC		; JUST CONFIRM?
	JRST	.HSPA1			; YES, GO PRINT SET PAD HELP MESSAGE
	HRRZ	T2,(T2)			; NO, GET POINTER
	JRST	(T2)			; AND DISPATCH


.HSPA1:
	SKIPE	LOGJFN
	CALL	LOG
	HRROI	T1,.HMSPA
	CALL	.SOUT
	RET

.HMSPA:	ASCIZ\ The SET PAD-PARAMETER command allows you to set the parameters which
 control the interaction of your terminal and the REMOTE-HOST. The
 format of the command is:

  X29PAD>SET PAD-PARAMETER argument-1 (to) argument-2 ... argument-n

 where argument-1 is one of the following:

 ACTION-ON-BREAK          CANCEL-CHARACTER         CARRIAGE-RETURN-PADDING
 DATA-FORWARDING          DELETE-CHARACTER         DISCARD-OUTPUT
 DISPLAY-CHARACTER        DTE-TO-NET-FLOW-CONTROL  ECHO
 ESCAPE-TO-COMMAND-MODE   IDLE-TIMER               LINE-WIDTH
 LINEFEED-INSERTION       LINEFEED-PADDING         LOCAL-EDITING
 NET-TO-DTE-FLOW-CONTROL  PAD-SIGNAL-CONTROL       RATE

 and argument-2 through argument-n are dependent on argument-1.

 For more help, type:

  X29PAD>HELP SET PAD-PARAMETER argument-1

 You may use "?" after PAD-PARAMETER to obtain a list choices for argument-1.

\


HSPTAB:	HSPTBL,,HSPTBL				; ACTUAL,,MAX NUMBER OF ENTRIES
	TBL (ACTION-ON-BREAK,,.HSP07)		; X.3 PAD PARAMETER 7
	TBL (CANCEL-CHARACTER,,.HSP17)		; X.3 PAD PARAMETER 17
	TBL (CARRIAGE-RETURN-PADDING,,.HSP09)	; X.3 PAD PARAMETER 9
	TBL (DATA-FORWARDING,,.HSP03)		; X.3 PAD PARAMETER 3
	TBL (DELETE-CHARACTER,,.HSP16)		; X.3 PAD PARAMETER 16
	TBL (DISCARD-OUTPUT,,.HSP08)		; X.3 PAD PARAMETER 8
	TBL (DISPLAY-CHARACTER,,.HSP18)		; X.3 PAD PARAMETER 18
	TBL (DTE-TO-NET-FLOW-CONTROL,,.HSP12)	; X.3 PAD PARAMETER 12
	TBL (ECHO,,.HSP02)			; X.3 PAD PARAMETER 2
	TBL (ESCAPE-TO-COMMAND-MODE,,.HSP01)	; X.3 PAD PARAMETER 1
	TBL (IDLE-TIMER,,.HSP04)		; X.3 PAD PARAMETER 4
	TBL (LINE-WIDTH,,.HSP10)		; X.3 PAD PARAMETER 10
	TBL (LINEFEED-INSERTION,,.HSP13)	; X.3 PAD PARAMETER 13
	TBL (LINEFEED-PADDING,,.HSP14)		; X.3 PAD PARAMETER 14
	TBL (LOCAL-EDITING,,.HSP15)		; X.3 PAD PARAMETER 15
	TBL (NET-TO-DTE-FLOW-CONTROL,,.HSP05)	; X.3 PAD PARAMETER 5
	TBL (PAD-SIGNAL-CONTROL,,.HSP06)	; X.3 PAD PARAMETER 6
	TBL (RATE,,.HSP11)			; X.3 PAD PARAMETER 11
HSPTBL==<.-HSPTAB>-1
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER ESCAPE-TO-COMMAND-MODE" COMMAND

.HSP01:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP01
	CALL	.SOUT
	RET

HMSP01:	ASCIZ\ The SET PAD-PARAMETER ESCAPE-TO-COMMAND-MODE command is used
 to set X.3 PAD Parameter 1 to one of two states. If PERMITTED,
 the user may return to command mode by typing the ESCAPE-CHARACTER.
 If PROHIBITED, typing the ESCAPE-CHARACTER will not return the user
 to command mode. The format of this command is:

  X29PAD>SET PAD-PARAMETER ESCAPE-TO-COMMAND-MODE (to) argument

 where argument is one of the following:

         PERMITTED    PROHIBITED

 NOTE: The state of this PAD parameter is currently ignored by X29PAD.

\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER ECHO" COMMAND

.HSP02:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP02
	CALL	.SOUT
	RET

HMSP02: ASCIZ\ The SET PAD-PARAMETER ECHO command allows the user to set the
 X.3 PAD Parameter #2 to specify whether the echoing of characters
 typed by the user will be done by X29PAD (LOCAL-ECHO) or by the
 REMOTE-HOST (REMOTE-ECHO). The format of this command is:

  X29PAD>SET PAD-PARAMETER ECHO (to) argument

 where argument is one of the following:

         LOCAL-ECHO    REMOTE-ECHO

\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER DATA-FORWARDING" COMMAND

.HSP03:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP03
	CALL	.SOUT
	RET

HMSP03: ASCIZ\ The SET PAD-PARAMETER DATA-FORWARDING command allows the user to set
 X.3 PAD Parameter - 3. This PAD Parameter is used to determine the
 set of characters that will cause data typed by the user to be sent
 to the REMOTE-HOST. This parameter may be set to one of the following:

 ALPHANUMERICS         CARRIAGE-RETURN       CONTROL-CHARACTERS
 EDITING-CHARACTERS    ESCAPE-CHARACTERS     FORMS-CONTROL-CHARACTERS
 NO-SIGNAL             OTHER-CHARACTERS      TERMINATOR-CHARACTERS

 The following are legal combinations of the above:

 CARRIAGE-RETURN (and) ESCAPE-CHARACTERS
 CARRIAGE-RETURN (and) TERMINATOR-CHARACTERS
 CARRIAGE-RETURN, ESCAPE-CHARACTERS, EDITING-CHARACTERS, TERMINATOR-CHARACTERS,
        FORMS-CONTROL-CHARACTERS, (and) CONTROL-CHARACTERS

 All other combinations are illegal.

\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER IDLE-TIMER" COMMAND

.HSP04:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP04
	CALL	.SOUT
	RET

HMSP04: ASCIZ\ The SET PAD-PARAMETER IDLE-TIMER command allows the user to
 set X.3 PAD Parameter 4. This parameter may also be set by the
 REMOTE-HOST. It affects the sending of data from X29PAD to the
 REMOTE-HOST. Its format is:

  X29PAD>SET PAD-PARAMETER IDLE-TIMER (to) argument

 where the argument is either the keyword "DISABLED" or an interval
 from 0.05 seconds to 12.75 seconds in 0.05 second increments. If
 the IDLE-TIMER is set, data typed by the user will be sent to the
 REMOTE-HOST at the set interval. (Data will also be sent if a
 character is typed that satisfies the conditions specified by the
 DATA-FORWARDING PAD parameter.) If the IDLE-TIMER is DISABLED, data
 will be sent when the input buffer is full or by typing a character
 that satisfies the DATA-FORWARDING conditions.

 NOTE: The IDLE-TIMER is ignored if LOCAL-EDITING is being done.

\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER NET-TO-DTE-FLOW-CONTROL" COMMAND

.HSP05:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP05
	CALL	.SOUT
	RET

HMSP05: ASCIZ\ The SET PAD-PARAMETER NET-TO-DTE-FLOW-CONTROL command allows
 the user to set X.3 PAD Parameter #5. This parameter enables
 or disables the use of XON and XOFF to control data flow from
 the local host to the user's terminal. The format of this command
 is:

  X29PAD>SET PAD-PARAMETER NET-TO-DTE-FLOW-CONTROL (to) argument

 where argument is either DISABLED or ENABLED.

 NOTE: X29PAD does not currently use X.3 PAD Parameter #5.

\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER PAD-SIGNAL-CONTROL" COMMAND

.HSP06:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP06
	CALL	.SOUT
	RET

HMSP06: ASCIZ\ The SET PAD-PARAMETER PAD-SIGNAL-CONTROL command allows
 the user to set X.3 PAD Parameter #x.

 NOTE: X29PAD currently does not use this parameter in its operation.

\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER ACTION-ON-BREAK" COMMAND

.HSP07:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP07
	CALL	.SOUT
	RET

HMSP07: ASCIZ\ The SET PAD-PARAMETER ACTION-ON-BREAK command allows the user to set X.3
 PAD Parameter - 7 which determine the action X29PAD will take when the user
 types the predefined BREAK-CHARACTER. This parameter may be set to one of
 the following:

  DISCARD-OUTPUT   ESCAPE            INDICATE          INTERRUPT
  NO-ACTION        RESET

 The following is the only legal combination of the above:

        DISCARD-OUTPUT, INDICATE, INTERRUPT

 All other combinations are illegal.

\


\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER DISCARD-OUTPUT" COMMAND

.HSP08:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP08
	CALL	.SOUT
	RET

HMSP08: ASCIZ\ The SET PAD-PARAMETER DISCARD-OUTPUT command allows the user
 to set X.3 PAD Parameter. X29PAD uses this parameter to determine
 whether to display data from the remote-host on the user's terminal
 or to discard that data.

 NOTE: This command is implemented for completeness and should not be
       set by the user.

\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER CARRIAGE-RETURN-PADDING" COMMAND

.HSP09:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP09
	CALL	.SOUT
	RET

HMSP09: ASCIZ\ The SET PAD-PARAMETER CARRIAGE-RETURN-PADDING command allows
 the user to set X.3 PAD Parameter #9. This parameter determines
 the number of null characters to be sent to the user's terminal
 after a carriage return is transmitted.

 NOTE: X29PAD does not use this parameter in its operation.

\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER LINE-WIDTH" COMMAND

.HSP10:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP10
	CALL	.SOUT
	RET

HMSP10: ASCIZ\ The SET PAD-PARAMETER LINE-WIDTH command allows the user to set
 X.3 PAD Parameter #10.

 NOTE: X29PAD currently does not use this PAD Parameter.

\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER RATE" COMMAND

.HSP11:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP11
	CALL	.SOUT
	RET

HMSP11: ASCIZ\ The SET PAD-PARAMETER RATE command allows the user to set
 X.3 PAD Parameter #11.

 NOTE: X29PAD currently does not make use of this PAD parameter.

\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER DTE-TO-NET-FLOW-CONTROL" COMMAND

.HSP12:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP12
	CALL	.SOUT
	RET

HMSP12: ASCIZ\ The SET PAD-PARAMETER DTE-TO-NET-FLOW-CONTROL command allows
 the user to set X.3 PAD Parameter #12. This parameter enables
 or disables the use of XON and XOFF to control data flow to the
 local host from the user's terminal. The format of this command
 is:

  X29PAD>SET PAD-PARAMETER DTE-TO-NET-FLOW-CONTROL (to) argument

 where argument is either DISABLED or ENABLED.

 NOTE: X29PAD does not currently use X.3 PAD Parameter #5.

\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER LINEFEED-INSERTION" COMMAND

.HSP13:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP13
	CALL	.SOUT
	RET

HMSP13: ASCIZ\ The SET PAD-PARAMETER LINEFEED-INSERTION command allows the user to set
 X.3 PAD Parameter #13. This parameter determines when (if ever) X29PAD
 should insert a linefeed after a carriage return in the data stream.
 The format of this command is:

  X29PAD>SET PAD-PARAMETER LINEFEED-INSERTION (to be done after) argument

 where argument is one of the following:

    ECHOED      NEVER     RECEIVED    SEND      

 NOTE: Currently X29PAD does not do LINEFEED-INSERTION after carriage
       returns in the received data stream.

\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER LINEFEED-PADDING" COMMAND

.HSP14:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP14
	CALL	.SOUT
	RET

HMSP14: ASCIZ\ The SET PAD-PARAMETER LINEFEED-PADDING command allows the user
 to set X.3 PAD Parameter #14.

 NOTE: X29PAD currently does not use this parameter in its operation.

\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER LOCAL-EDITING" COMMAND

.HSP15:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP15
	CALL	.SOUT
	RET

HMSP15: ASCIZ\ The SET PAD-PARAMETER LOCAL-EDITING command allows the user to set X.3 PAD
 Parameter 15. The LOCAL-EDITING parameter determines whether or not X29PAD
 does editing of user input. The format of this command is:

  X29PAD>SET PAD-PARAMETER LOCAL-EDITING (to) argument

 where argument is either the keyword "DISABLED" or "ENABLED".

 If LOCAL-EDITING is ENABLED, the DELETE-CHARACTER, CANCEL-CHARACTER, and
 DISPLAY-CHARACTER can be used to modify user input before it is sent to
 the REMOTE-HOST. Data will be sent to the REMOTE-HOST whenever a character
 is typed that meets the DATA-FORWARDING criteria or when the input buffer
 becomes full. The IDLE-TIMER is ignored if LOCAL-EDITING is enabled.
 For more information, type:

  X29PAD>HELP SET PAD-PARAMETER argument

 where argument is one of the following:

         CANCEL-CHARACTER   DELETE-CHARACTER   DISPLAY-CHARACTER

 NOTE: If data is sent because the input buffer was full, all characters
 typed are ignored (and a BELL echoed) until a CARRIAGE-RETURN is typed.

\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER DELETE-CHARACTER" COMMAND

.HSP16:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP16
	CALL	.SOUT
	RET

HMSP16: ASCIZ\ The SET PAD-PARAMETER DELETE-CHARACTER command allows you to set X.3 PAD
 Parameter - 16. This parameter specifies the character that X29PAD will
 interpret as its DELETE-CHARACTER whenever LOCAL-EDITING is ENABLED. Typing
 this character will cause X29PAD to remove one character from the buffer of
 characters waiting to be sent to the REMOTE-HOST. The format of the command
 is:

  X29PAD>SET PAD-PARAMETER DELETE-CHARACTER (to) argument

 where argument is the octal value for the ASCII character code you wish
 to be the DELETE-CHARACTER or any printing character in double quotes.
 An alternate form of this command is:

  X29PAD>SET PAD-PARAMETER DELETE-CHARACTER (to) CONTROL argument

 This form of the command is used to define the DELETE-CHARACTER to be a
 control character. The user supplied argument is a printing character in
 double quotes. For example, to set the DELETE-CHARACTER to CONTROL-H you
 would type:

  X29PAD>SET PAD-PARAMETER DELETE-CHARACTER (to) CONTROL "H"

 Note that the default DELETE-CHARACTER is RUBOUT (octal 177).
\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER CANCEL-CHARACTER" COMMAND

.HSP17:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP17
	CALL	.SOUT
	RET

HMSP17: ASCIZ\ The SET PAD-PARAMETER CANCEL-CHARACTER command allows you to set X.3 PAD
 Parameter - 17. This parameter specifies the character that X29PAD will
 interpret as its line-delete character whenever LOCAL-EDITING is ENABLED.
 Typing this character will cause X29PAD to remove ALL characters from the
 buffer of characters waiting to be sent to the REMOTE-HOST.
 The format of the command is:

  X29PAD>SET PAD-PARAMETER CANCEL-CHARACTER (to) argument

 where argument is the octal value for the ASCII character code you wish
 to be the status display character or any printing character in double
 quotes. An alternate form of this command is:

  X29PAD>SET PAD-PARAMETER CANCEL-CHARACTER (to) CONTROL argument

 This form of the command is used to define the CANCEL-CHARACTER to be a
 control character. The user supplied argument is a printing character in
 double quotes. For example, to set the CANCEL-CHARACTER to CONTROL-X you
 would type:

  X29PAD>SET PAD-PARAMETER CANCEL-CHARACTER (to) CONTROL "X"

 Note that the default CANCEL-CHARACTER is CONTROL-U.
\
; HERE TO GIVE HELP WITH THE "SET PAD-PARAMETER DISPLAY-CHARACTER" COMMAND

.HSP18:
	NOISE (command)
	CONFIRM
	HRROI	T1,HMSP18
	CALL	.SOUT
	RET

HMSP18: ASCIZ\ The SET PAD-PARAMETER DISPLAY-CHARACTER command allows you to set X.3 PAD
 Parameter - 18. This parameter specifies the character that X29PAD will
 interpret as its line-display character whenever LOCAL-EDITING is ENABLED.
 Typing this character will cause X29PAD to redisplay the contents of the
 buffer of characters waiting to be sent to the REMOTE-HOST.
 The format of the command is:

  X29PAD>SET PAD-PARAMETER DISPLAY-CHARACTER (to) argument

 where argument is the octal value for the ASCII character code you wish to
 be the DISPLAY-CHARACTER or any printing character in double quotes. An
 alternate form of this command is:

  X29PAD>SET PAD-PARAMETER DISPLAY-CHARACTER (to) CONTROL argument

 This form of the command is used to define the DISPLAY-CHARACTER to be a
 control character. The user supplied argument is a printing character in
 double quotes. For example, to set the DISPLAY-CHARACTER to CONTROL-L you
 would type:

  X29PAD>SET STATUS-DISPLAY-CHARACTER (to) CONTROL "L"

 Note that the default DISPLAY-CHARACTER is CONTROL-R.
\
; HERE TO GIVE HELP WITH THE "SET STATUS-DISPLAY-CHARACTER" COMMAND

.HSSTA:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMSSC
	CALL	.SOUT
	RET

.HMSSC:	ASCIZ\ The SET STATUS-DISPLAY-CHARACTER command allows you to define a special
 character which, when typed, will cause X29PAD to display the current call.
 status. The format of the command is:

  X29PAD>SET STATUS-DISPLAY-CHARACTER (to) argument

 where argument is the octal value for the ASCII character code you wish
 to be the status display character or any printing character in double
 quotes. An alternate form of this command is:

  X29PAD>SET STATUS-DISPLAY-CHARACTER (to) CONTROL argument

 This form of the command is used to define the STATUS-DISPLAY-CHARACTER to
 be a control character. The user supplied argument is a printing character
 in double quotes. For example, to set the STATUS-DISPLAY-CHARACTER to
 CONTROL-P, you would type:

  X29PAD>SET STATUS-DISPLAY-CHARACTER (to) CONTROL "P"

 Note that the default STATUS-DISPLAY-CHARACTER is CONTROL-A.

\
; HERE TO PARSE "HELP TAKE"

.HTAKE:
	NOISE (command)
	CONFIRM
	HRROI	T1,.HMTAK
	CALL	.SOUT
	RET

.HMTAK:	ASCIZ\ The TAKE command allows the user to direct X29PAD to execute
 a series of commands from a specified file. The format of this
 command is:

  X29PAD>TAKE (commands from) file-spec

 where file-spec is the name of the file containing commands for
 X29PAD to execute. After the file-spec type a comma followed
 by a carriage return to enter subcommand mode. There the user
 may modify the actions of the command processor by entering
 various subcommands.

\
.HX29P:
	CONFIRM
	HRROI	T1,HLPMSG
	CALL	.SOUT
	RET

HLPMSG:	ASCIZ\ X29PAD is a program which will allow a user to "SET HOST" to a remote
 system an X.25 Gateway. The remote host need not be a DEC computer.

 Here is a list of useful things to know about X29PAD:

	o X29PAD will take commands from PS:<directory-name>X29PAD.INIT
	  when it is started. This file may contain commands to define
	  remote hosts, set special characters, or set the network name
	  and password you wish to access.

	o You should not use the SET PAD-PARAMETERS command to change
	  PAD Parameters in the middle of a call.

	o PAD Parameters are reset to a known state everytime you place
	  an outgoing call.

\
	SUBTTL	INFORMATION COMMAND

.INFORM:
	NOISE (about)
	MOVEI	T2,[FLDDB. .CMKEY,,INFTAB,<>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T2,(T2)
	JRST	(T2)

INFTAB:	INFTBL,,INFTBL
	TBL (DEFAULTS,,.IDEF)
	TBL (LAST-NETWORK-ERROR,,.INETE)
	TBL (PAD-PARAMETERS,,.IPARM)
	TBL (REMOTE-HOSTS,,.IREMH)
	TBL (STATUS,,.ISTAT)
	TBL (VERSION,,.IVERS)
INFTBL==<.-INFTAB>-1
; HERE TO DISPLAY PARAMETERS INFORMATION

.IPARM:
	CONFIRM
	HRROI	T1,[ASCIZ\ Current PAD Parameters are:
\]
	CALL	.SOUT
;	.
;	.
;	.
; HERE TO DISPLAY ACTION-ON-BREAK SETTING

IPABR:
	MOVE	T4,PAD.7
	CALL	WHOSET			; WHO SET THIS PARAMETER?
	HRROI	T1,[ASCIZ\ACTION-ON-BREAK (is) \]
	CALL	.SOUT
	HRRZ	S,PAD.7			; GET THE BREAK CHARACTER CODE
	MOVE	T3,[-6,,ABRTXT]		; SET THE INDEX AND COUNT
	HRROI	T4,[ASCIZ\                      \]	; BLANK TXT
	CALL	IPSUB			; GO PRINT SET FUNCTIONS
; HERE TO DISPLAY CANCEL-CHARACTER SETTING

IPCAN:	MOVE	T4,PAD.17
	CALL	WHOSET			; WHO SET THIS PAD PARAMETER
	HRROI	T1,[ASCIZ\CANCEL-CHARACTER (is) \]
	CALL	.SOUT
	HRRZ	T2,PAD.17		; GET PAD.17 VALUE
	CAIG	T2,177			; 
	CAIGE	T2,0			; BETWEEN 0 AND 177?
	JRST	IPCA.3			; NO, SIGH
	CAIE	T2,40			; A SPACE?
	JRST	IPCA.1			; NO
	HRROI	T1,[ASCIZ\A SPACE\]
	CALL	.SOUT
	JRST	IPCA.X
IPCA.1:	CAILE	T2,37			; A CONTROL CHARACTER?
	JRST	IPCA.2			; NO
	HRROI	T1,[ASCIZ\CONTROL-\]
	CALL	.SOUT
	ADDI	T2,100			; CONVERT TO A PRINTABLE CHARACTER
IPCA.2:	CALL	.BOUT
	JRST	IPCA.X
IPCA.3:	HRROI	T1,[ASCIZ\AN ILLEGAL VALUE\]
	CALL	.SOUT

IPCA.X:	CALL	OCRLF
; HERE TO DISPLAY CARRIAGE-RETURN-PADDING SETTING

IPCRP:	MOVE	T4,PAD.9
	CALL	WHOSET
	HRROI	T1,[ASCIZ\CARRIAGE-RETURN-PADDING (is) \]
	CALL	.SOUT
	HRRZ	T2,PAD.9		; GET PAD.9 VALUE
	CAIE	T2,0			; PADDING BEING DONE?
	JRST	IPCR.1			; YES
	HRROI	T1,[ASCIZ\DISABLED\]
	CALL	.SOUT
	JRST	IPCR.X
IPCR.1:	CAIG	T2,7			; BETWEEN
	CAIGE	T2,1			; 1 AND 7?
	JRST	IPCR.2			; OUT OF RANGE
	ADDI	T2,60			; MAKE IT AN ASCII CHARACTER
	MOVEI	T3,^D10
	CALL	.BOUT
	HRROI	T1,[ASCIZ\ CHARACTER-TIME\]
	CALL	.SOUT
	HRRZ	T2,PAD.9		; GET PAD.9 VALUE
	CAIG	T2,1			; GREATER THAN 1?
	JRST	IPCR.X			; NO, FINISH LINE
	MOVEI	T2,"S"
	CALL	.BOUT
	JRST	IPCR.X
IPCR.2:	HRROI	T1,[ASCIZ\AN ILLEGAL VALUE\]
	CALL	.SOUT
IPCR.X:	CALL	OCRLF
; HERE TO DISPLAY DATA-FORWARDING SETTING

IPDFW:
	MOVE	T4,PAD.3
	CALL	WHOSET
	HRROI	T1,[ASCIZ\DATA FORWARDING (is done on) \]
	CALL	.SOUT
	HRRZ	S,PAD.3			; GET THE BREAK CHARACTER CODE
	MOVE	T3,[-11,,DFWTXT]	; SET THE INDEX AND COUNTER
	HRROI	T4,[ASCIZ\                              \]	; BLANK TXT
	CALL	IPSUB			; GO PRINT SET FUNCTIONS
; HERE TO DISPLAY THE DELETE-CHARACTER

IPDEL:	MOVE	T4,PAD.16
	CALL	WHOSET
	HRROI	T1,[ASCIZ\DELETE-CHARACTER (is) \]
	CALL	.SOUT
	HRRZ	T2,PAD.16		; GET PAD.16 VALUE
	CAIG	T2,177			; 
	CAIGE	T2,0			; BETWEEN 0 AND 177?
	JRST	IPDE.4			; NO, SIGH
	CAIE	T2,40			; A SPACE?
	JRST	IPDE.1			; NO
	HRROI	T1,[ASCIZ\A SPACE\]
	CALL	.SOUT
	JRST	IPDE.X
IPDE.1:	CAIE	T2,177			; A RUBOUT?
	JRST	IPDE.2			; NO
	HRROI	T1,[ASCIZ\A RUBOUT\]
	CALL	.SOUT
	JRST	IPDE.X
IPDE.2:	CAILE	T2,37			; A CONTROL CHARACTER?
	JRST	IPDE.3			; NO
	HRROI	T1,[ASCIZ\CONTROL-\]
	CALL	.SOUT
	ADDI	T2,100			; CONVERT TO A PRINTABLE CHARACTER
IPDE.3:	CALL	.BOUT
	JRST	IPDE.X
IPDE.4:	HRROI	T1,[ASCIZ\AN ILLEGAL VALUE\]
	CALL	.SOUT

IPDE.X:	CALL	OCRLF
; HERE TO DISPLAY THE DISCARD-OUTPUT SETTING

IPDIS:	MOVE	T4,PAD.8
	CALL	WHOSET
	HRROI	T1,[ASCIZ\DISCARD-OUTPUT (is) \]
	CALL	.SOUT
	HRRZ	T2,PAD.8		; GET PAD.8 VALUE
	CAIE	T2,0			; DISABLED?
	JRST	IPDI.1			; NO
	HRROI	T1,[ASCIZ\DISABLED\]
	CALL	.SOUT
	JRST	IPDI.X
IPDI.1:	CAIE	T2,1			; ENABLED?
	JRST	IPDI.2			; NO
	HRROI	T1,[ASCIZ\ENABLED\]
	CALL	.SOUT
	JRST	IPDI.X
IPDI.2:	HRROI	T1,[ASCIZ\AN ILLEGAL VALUE\]
	CALL	.SOUT

IPDI.X:	CALL	OCRLF
; HERE TO DISPLAY THE DISPLAY-CHARACTER SETTING

IPDCH:	MOVE	T4,PAD.18
	CALL	WHOSET
	HRROI	T1,[ASCIZ\DISPLAY-CHARACTER \]
	CALL	.SOUT
	HRRZ	T2,PAD.18		; GET PAD.18 VALUE
	CAIG	T2,177			; 
	CAIGE	T2,0			; BETWEEN 0 AND 177?
	JRST	IPDC.3			; NO, SIGH
	CAIE	T2,40			; A SPACE?
	JRST	IPDC.1			; NO
	HRROI	T1,[ASCIZ\A SPACE\]
	CALL	.SOUT
	JRST	IPDC.X
IPDC.1:	CAILE	T2,37			; A CONTROL CHARACTER?
	JRST	IPDC.2			; NO
	HRROI	T1,[ASCIZ\CONTROL-\]
	CALL	.SOUT
	ADDI	T2,100			; CONVERT TO A PRINTABLE CHARACTER
IPDC.2:	CALL	.BOUT
	JRST	IPDC.X
IPDC.3:	HRROI	T1,[ASCIZ\AN ILLEGAL VALUE\]
	CALL	.SOUT

IPDC.X:	CALL	OCRLF
; HERE TO DISPLAY THE DTE-TO-NET-FLOW-CONTROL SETTING

IPDNF:	MOVE	T4,PAD.12
	CALL	WHOSET
	HRROI	T1,[ASCIZ\DTE-TO-NET-FLOW-CONTROL (is) \]
	CALL	.SOUT
	HRRZ	T2,PAD.12		; GET PAD.12 VALUE
	CAIE	T2,0			; DISABLED?
	JRST	IPDN.1			; NO
	HRROI	T1,[ASCIZ\DISABLED\]
	CALL	.SOUT
	JRST	IPDN.X
IPDN.1:	CAIE	T2,1			; ENABLED?
	JRST	IPDN.2			; NO
	HRROI	T1,[ASCIZ\ENABLED\]
	CALL	.SOUT
	JRST	IPDN.X
IPDN.2:	HRROI	T1,[ASCIZ\AN ILLEGAL VALUE\]
	CALL	.SOUT

IPDN.X:	CALL	OCRLF
; HERE TO DISPLAY THE ECHO SETTING

IPECH:	MOVE	T4,PAD.2
	CALL	WHOSET
	HRROI	T1,[ASCIZ\ECHO (is) \]
	CALL	.SOUT
	HRRZ	T2,PAD.2		; GET PAD.2 VALUE
	CAIE	T2,1			; LOCAL ECHO?
	JRST	IPEC.1			; NO
	HRROI	T1,[ASCIZ\DONE LOCALLY\]
	CALL	.SOUT
	JRST	IPEC.3
IPEC.1:	CAIE	T2,0			; REMOTE ECHO?
	JRST	IPEC.2			; NO?!
	HRROI	T1,[ASCIZ\DONE REMOTELY\]
	CALL	.SOUT
	JRST	IPEC.3
IPEC.2:	HRROI	T1,[ASCIZ\IN AN ILLEGAL STATE\]
	CALL	.SOUT
IPEC.3:	CALL	OCRLF
; HERE TO DISPLAY THE ESCAPE-TO-COMMAND-MODE SETTING

IPESC:	MOVE	T4,PAD.1
	CALL	WHOSET
	HRROI	T1,[ASCIZ\ESCAPE-TO-COMMAND-MODE (is) \]
	CALL	.SOUT
	HRRZ	T2,PAD.1		; GET PAD.1 VALUE
	CAIE	T2,1			; IS ESCAPE ALLOWED?
	JRST	IPES.1			; NO
	HRROI	T1,[ASCIZ\PERMITTED\]	; YES
	CALL	.SOUT
	JRST	IPES.3
IPES.1:	CAIE	T2,0			; IS ESCAPE NOT ALLOWED?
	JRST	IPES.2			; WHOOPS...ILLEGAL VALUE
	HRROI	T1,[ASCIZ\PROHIBITED\]
	CALL	.SOUT
	JRST	IPES.3
IPES.2:	HRROI	T1,[ASCIZ\IN AN UNKNOWN STATE\]
	CALL	.SOUT
IPES.3:	CALL	OCRLF
; HERE TO DISPLAY THE IDLE-TIMER SETTING

IPITM:	MOVE	T4,PAD.4
	CALL	WHOSET
	HRROI	T1,[ASCIZ\IDLE-TIMER (is) \]
	CALL	.SOUT
	HRRZ	T2,PAD.4		; GET PAD.4 VALUE
	CAIE	T2,0			; TEST TO SEE IF IT IS DISABLED
	JRST	IPIT.1			; NOT DISABLED
	HRROI	T1,[ASCIZ\DISABLED\]
	CALL	.SOUT
	JRST	IPIT.X
IPIT.1:	CAIG	T2,^D255		; 
	CAIGE	T2,1			; BETWEEN 1 AND ^D255?
	JRST	IPIT.3			; GRUMBLE GRUMBLE
	IMULI	T2,5
	MOVE	T3,T2			; SAVE # OF SECONDS X100
	IDIVI	T2,^D100		; DIVIDE DOWN TO SECONDS
	MOVE	S,T2			; SAVE WHOLE SECONDS
	IMULI	T2,^D100		
	SUB	T2,T3			; GET FRACTION OF A SECOND
	MOVE	T4,T3			; SAVE
	MOVE	T2,S
	MOVEI	T3,^D10			; RADIX 10
	CALL	.NOUT
	ERJMP .+1			; THIS CAN'T HAPPEN
	MOVEI	T2,"."
	CALL	.BOUT
	CAILE	T4,^D10			; IS FRACTION <.10?
	JRST	IPIT.2			; NO, NO NEED FOR LEADING ZERO
	MOVEI	T2,"0"
	CALL	.BOUT
IPIT.2:	MOVE	T2,T4
	CALL	.NOUT
	ERJMP .+1			; THIS CAN'T HAPPEN
	HRROI	T1,[ASCIZ\ SECOND\]
	CALL	.SOUT
	HRRZ	T2,PAD.4
	CAIN	T2,^D20			; EXACTLY ONE SECOND?
	JRST	IPIT.X			; YES, FINISH LINE
	MOVEI	T2,"S"			; NO, ADD A "S"
	CALL	.BOUT
	JRST	IPIT.X
IPIT.3:	HRROI	T1,[ASCIZ\AN ILLEGAL VALUE\]
	CALL	.SOUT

IPIT.X:	CALL	OCRLF
; HERE TO DISPLAY THE LINE-WIDTH SETTING

IPLWD:	MOVE	T4,PAD.10
	CALL	WHOSET
	HRROI	T1,[ASCIZ\LINE-WIDTH (is) \]
	CALL	.SOUT
	HRRZ	T2,PAD.10		; GET PAD.10 VALUE
	CAIG	T2,^D255		; 
	CAIGE	T2,0			; BETWEEN 0 AND ^D255?
	JRST	IPLW.1			; HMMMMM, COMPLAIN
	MOVEI	T3,^D10
	CALL	.NOUT
	ERJMP .+1			; THIS CAN'T HAPPEN
	JRST	IPLW.X

IPLW.1:	HRROI	T1,[ASCIZ\AN ILLEGAL VALUE\]
	CALL	.SOUT
IPLW.X:	CALL	OCRLF
; HERE TO DISPLAY THE LINEFEED-INSERTION SETTING

IPLIN:	MOVE	T4,PAD.13
	CALL	WHOSET
	HRROI	T1,[ASCIZ\LINEFEED-INSERTION (is done after) \]
	CALL	.SOUT
	HRRZ	S,PAD.13		; GET PAD.13 VALUE
	MOVE	T3,[-3,,LFITXT]	; SET THE INDEX AND COUNTER
	HRROI	T4,[ASCIZ\                                    \] ; BLANK TXT
	CALL	IPSUB			; GO PRINT SET FUNCTIONS
; HERE TO DISPLAY THE LINEFEED-PADDING SETTING

IPLPD:	MOVE	T4,PAD.14
	CALL	WHOSET
	HRROI	T1,[ASCIZ\LINEFEED-PADDING (is) \]
	CALL	.SOUT
	HRRZ	T2,PAD.14		; GET PAD.14 VALUE
	CAIE	T2,0			; PADDING BEING DONE?
	JRST	IPLP.1			; YES
	HRROI	T1,[ASCIZ\DISABLED\]
	CALL	.SOUT
	JRST	IPLP.X
IPLP.1:	CAIG	T2,7			; 
	CAIGE	T2,1			; BETWEEN 1 AND 7?
	JRST	IPLP.2			; OUT OF RANGE
	ADDI	T2,60			; MAKE IT AN ASCII CHARACTER
	CALL	.BOUT
	HRROI	T1,[ASCIZ\ CHARACTER-TIME\]
	CALL	.SOUT
	HRRZ	T2,PAD.14		; GET PAD.14 AGAIN
	CAIG	T2,1			; GREATER THAN 1?
	JRST	IPLP.X			; NO, FINISH THE LINE
	MOVEI	T2,"S"
	CALL	.BOUT
	JRST	IPLP.X
IPLP.2:	HRROI	T1,[ASCIZ\AN ILLEGAL VALUE\]
	CALL	.SOUT
IPLP.X:	CALL	OCRLF
; HERE TO DISPLAY THE LOCAL-EDITING SETTING

IPLOC:	MOVE	T4,PAD.15
	CALL	WHOSET
	HRROI	T1,[ASCIZ\LOCAL-EDITING (is) \]
	CALL	.SOUT
	HRRZ	T2,PAD.15		; GET PAD.15 VALUE
	CAIE	T2,0			; DISABLED?
	JRST	IPLO.1			; NO
	HRROI	T1,[ASCIZ\DISABLED\]
	CALL	.SOUT
	JRST	IPLO.X
IPLO.1:	CAIE	T2,1			; ENABLED
	JRST	IPLO.2			; NO
	HRROI	T1,[ASCIZ\ENABLED\]
	CALL	.SOUT
	JRST	IPLO.X
IPLO.2:	HRROI	T1,[ASCIZ\AN ILLEGAL VALUE\]
	CALL	.SOUT

IPLO.X:	CALL	OCRLF
; HERE TO DISPLAY THE NET-TO-DTE-FLOW-CONTROL SETTING

IPNDF:	MOVE	T4,PAD.5
	CALL	WHOSET
	HRROI	T1,[ASCIZ\NET-TO-DTE-FLOW-CONTROL (is) \]
	CALL	.SOUT
	HRRZ	T2,PAD.5		; GET PAD.5 VALUE
	CAIE	T2,0			; DISABLED?
	JRST	IPND.1			; NO
	HRROI	T1,[ASCIZ\DISABLED\]
	CALL	.SOUT
	JRST	IPND.X
IPND.1:	CAIE	T2,1			; ENABLED?
	JRST	IPND.2			; NO
	HRROI	T1,[ASCIZ\ENABLED\]
	CALL	.SOUT
	JRST	IPND.X
IPND.2:	HRROI	T1,[ASCIZ\AN ILLEGAL VALUE\]
	CALL	.SOUT

IPND.X:	CALL	OCRLF
; HERE TO DISPLAY THE PAD-SIGNAL-CONTROL SETTING

IPNMD:	MOVE	T4,PAD.6
	CALL	WHOSET
	HRROI	T1,[ASCIZ\PAD-SIGNAL-CONTROL (is) \]
	CALL	.SOUT
	HRRZ	T2,PAD.6		; GET PAD.6 VALUE
	CAIE	T2,0			; SUPPRESSED?
	JRST	IPNM.1			; NO
	HRROI	T1,[ASCIZ\SUPPRESSED\]
	CALL	.SOUT
	JRST	IPNM.X
IPNM.1:	CAIE	T2,1			; ENABLED?
	JRST	IPNM.2			; NO
	HRROI	T1,[ASCIZ\ENABLED\]
	CALL	.SOUT
	JRST	IPNM.X
IPNM.2:	HRROI	T1,[ASCIZ\AN ILLEGAL VALUE\]
	CALL	.SOUT

IPNM.X:	CALL	OCRLF
; HERE TO DISPLAY THE RATE SETTING

IPRAT:	MOVE	T4,PAD.11
	CALL	WHOSET
	HRROI	T1,[ASCIZ\RATE (is) \]
	CALL	.SOUT
	HRRZ	T2,PAD.11		; GET PAD.11 VALUE
	CAIE	T2,0			; 110 BAUD?
	JRST	IPR.01			; NO
	HRROI	T1,[ASCIZ\110 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.01:	CAIE	T2,1			; 134.5 BAUD?
	JRST	IPR.02			; NO
	HRROI	T1,[ASCIZ\134.5 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.02:	CAIE	T2,2			; 300 BAUD?
	JRST	IPR.03			; NO
	HRROI	T1,[ASCIZ\300 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.03:	CAIE	T2,3			; 1200 BAUD?
	JRST	IPR.04			; NO
	HRROI	T1,[ASCIZ\1200 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.04:	CAIE	T2,4			; 600 BAUD?
	JRST	IPR.05			; NO
	HRROI	T1,[ASCIZ\600 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.05:	CAIE	T2,5			; 75 BAUD?
	JRST	IPR.06			; NO
	HRROI	T1,[ASCIZ\75 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.06:	CAIE	T2,6			; 150 BAUD?
	JRST	IPR.07			; NO
	HRROI	T1,[ASCIZ\150 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.07:	CAIE	T2,7			; 1800 BAUD?
	JRST	IPR.08			; NO
	HRROI	T1,[ASCIZ\1800 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.08:	CAIE	T2,^D8			; 200 BAUD?
	JRST	IPR.09			; NO
	HRROI	T1,[ASCIZ\200 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.09:	CAIE	T2,^D9			; 100 BAUD?
	JRST	IPR.10			; NO
	HRROI	T1,[ASCIZ\100 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.10:	CAIE	T2,^D10			; 50 BAUD?
	JRST	IPR.11			; NO
	HRROI	T1,[ASCIZ\50 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.11:	CAIE	T2,^D11			; 75/1200 BAUD?
	JRST	IPR.12			; NO
	HRROI	T1,[ASCIZ\75/1200 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.12:	CAIE	T2,^D12			; 2400 BAUD?
	JRST	IPR.13			; NO
	HRROI	T1,[ASCIZ\2400 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.13:	CAIE	T2,^D13			; 4800 BAUD?
	JRST	IPR.14			; NO
	HRROI	T1,[ASCIZ\4800 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.14:	CAIE	T2,^D14			; 9600 BAUD?
	JRST	IPR.15			; NO
	HRROI	T1,[ASCIZ\9600 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.15:	CAIE	T2,^D15			; 19200 BAUD?
	JRST	IPR.16			; NO
	HRROI	T1,[ASCIZ\19200 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.16:	CAIE	T2,^D16			; 48000 BAUD?
	JRST	IPR.17			; NO
	HRROI	T1,[ASCIZ\48000 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.17:	CAIE	T2,^D17			; 56000 BAUD?
	JRST	IPR.18			; NO
	HRROI	T1,[ASCIZ\56000 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.18:	CAIE	T2,^D18			; 64000 BAUD?
	JRST	IPR.19			; NO
	HRROI	T1,[ASCIZ\64000 BAUD\]
	CALL	.SOUT
	JRST	IPRA.X
IPR.19:	HRROI	T1,[ASCIZ\AN ILLEGAL VALUE\]
	CALL	.SOUT


IPRA.X:	CALL	OCRLF
; HERE TO FINISH THE INFORMATION (ON) PAD-PARAMETERS COMMAND

	HRROI	T1,[ASCIZ\
 ( * Indicates PAD Parameters which were set by the remote host )
\]
	CALL	.SOUT
	RET				; END INFORMATION ON PAD-PARAMETERS
; MISC. ROUTINES

;ROUTINE TO PRINT ACTION ON BREAK AND DATA FORWARDING PARAMS

IPSUB:
	HLRZ	T2,(T3)			; GET THE MASK
	TDZN	S,T2			; IS THIS BIT SET
	AOBJN	T3,IPSUB		; NO, TRY NEXT IF NOT DONE
	HRRO	T1,(T3)			; GET THE TYPE MESSAGE
	CALL	.SOUTR
	JUMPE	S,IPSUBE		; AND RET IF NO MORE SET
	AOBJP	T3,IPSUBE		; INCREMENT INDEX, SHOULD NEVER JUMP
IPSUB1:	HLRZ	T2,(T3)			; GET THE MASK
	TDZN	S,T2			; IS THIS BIT SET
	AOBJN	T3,IPSUB1		; NO, GET NEXT IF NOT ALL
	MOVE	T1,T4			; GET THE BLANK TEXT
	CALL	.SOUT
	HRRO	T1,(T3)			; GET THE TYPE MESSAGE
	CALL	.SOUTR
	SKIPE	S			; AND RET IF NO MORE SET
	AOBJN	T3,IPSUB1		; GET NEXT, SHOULD ALWAYS JUMP
IPSUBE:	RET

DFWTXT:	P03%AL,,[ASCIZ\ALPHANUMERICS\]
	P03%CR,,[ASCIZ\CARRIAGE-RETURN\]
	P03%CT,,[ASCIZ\CONTROL-CHARACTERS\]
	P03%ED,,[ASCIZ\EDITING-CHARACTERS\]
	P03%ES,,[ASCIZ\ESCAPE-CHARACTERS\]
	P03%FM,,[ASCIZ\FORMS-CONTROL-CHARACTERS\]
	P03%TR,,[ASCIZ\TERMINATOR-CHARACTERS\]
	P03%OT,,[ASCIZ\OTHER CHARACTERS\]
	-1,,[ASCIZ\UNKNOWN CODE\]
	[ASCIZ\NO-SIGNAL\]

ABRTXT:	P07%ES,,[ASCIZ\ESCAPE\]
	P07%DO,,[ASCIZ\DISCARD-OUTPUT\]
	P07%IT,,[ASCIZ\INTERRUPT\]
	P07%ID,,[ASCIZ\INDICATE\]
	P07%RE,,[ASCIZ\RESET\]
	-1,,[ASCIZ\IN AN ILLEGAL STATE\]
	[ASCIZ\NOTHING\]

LFITXT:	P13%EC,,[ASCIZ\ECHOED CARRIAGE-RETURNS\]
	P13%TD,,[ASCIZ\RECEIVED CARRIAGE-RETURNS\]
	P13%FD,,[ASCIZ\SENT CARRIAGE-RETURNS\]
;	-1,,[ASCIZ\IN AN ILLEGAL STATE\]
	0,,[ASCIZ\NO CARRIAGE-RETURNS\]

; CALLED TO PRINT A * IF THE PAD PARAMETER IN T4 HAS PF%WRT SET
;          OR A "SPACE" IF THE PAD PARAMETER IN T4 HAS PF%WRT CLEARED

WHOSET:
	MOVEI	T2," "			; ASSUME PARAMETER LAST SET LOCALLY
	TXNE	T4,PF%WRT		; SET BY REMOTE?
	MOVEI	T2,"*"			; YES, MOVE IN A *
	CALL	.BOUT
	RET
; HERE TO DISPLAY DEFAULT INFORMATION

.IDEF:	NOISE	(for)
	MOVEI	T2,[FLDDB. .CMKEY,,IDFTAB]	; POINT TO TABLE
	COMND
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	HRRZ	T2,(T2)			; GET THE COMMAND DISPATCH
	JRST	(T2)			; GO...


IDFTAB:	IDFTBL,,IDFTBL
	TBL (CALL,,.IDCAL)
	TBL (LOG,,.IDLOG)
	TBL (SEND,,.IDSEN)
	TBL (TAKE,,.IDTAK)
IDFTBL==<.-IDFTAB>-1
; HERE TO DISPLAY DEFAULT INFO FOR THE CALL COMMAND

.IDCAL:	CONFIRM
	HRROI	T1,[ASCIZ\ SET DEFAULT (for) CALL CLOSED-USER-GROUP (to) \]
	CALL	.SOUT
	MOVE	T1,[POINT 7,CUGDEF]	; POINT AT DEFAULT CLOSED-USER-GROUP
	ILDB	P1,T1			; GET THE FIRST CHARACTER
	JUMPE	P1,.IDCA1		; JUMP IF NO DEFAULT SPECIFIED
	HRROI	T1,CUGDEF		; POINT TO DEFAULT STRING
	CALL	.SOUTR
	JRST	.IDCA2			; GO ON TO FACILITIES-DATA
.IDCA1:	HRROI	T1,[ASCIZ\%Nothing\]
	CALL	.SOUTR
.IDCA2:	HRROI	T1,[ASCIZ\ SET DEFAULT (for) CALL FACILITIES-DATA (to) \]
	CALL	.SOUT
	SKIPE	FACDCT			; ANY FACILITIES-DATA?
	JRST	.IDCA3			; YES, DISPLAY IT
	HRROI	T1,[ASCIZ\%Nothing\]	; INDICATE NO DEFAULT DATA
	CALL	.SOUTR			; AND PRINT IT
	JRST	.IDCA4			; NO GO ON TO USER-DATA
.IDCA3:	HRRZ	S,FACDCT		; LOAD THE COUNT AND
	MOVE	P1,[POINT 8,FACDEF]	; POINT TO DEFAULT FACILITIES-DATA BLK	
	CALL	.CDPNT			; PRINT DATA
	CALL	OCRLF
.IDCA4:	HRROI	T1,[ASCIZ\ SET DEFAULT (for) CALL USER-DATA (to) \]
	CALL	.SOUT
	HRRZ	S,UCDDCT		; LOAD THE COUNT AND
	MOVE	P1,[POINT 8,UCDDEF]	; THE DEFAULT USER-DATA BLK
	CALL	.CDPNT			; PRINT DATA
	CALL	OCRLF
	RET
; A ROUTINE TO PRINT 8-BIT DATA BYTE STRINGS

.CDPNT:	SKIPG	S			; MORE TO OUTPUT
	RET				; NO
	ILDB	T2,P1			; GET NEXT BYTE
	CAIGE	T2," "			; LESS THAN 40?
	JRST	.CDNBR			; YES, ITS A NUMBER
	CAILE	T2,176			; A PRINTING CHARACTER?
	JRST	.CDNBR			; NO, ITS A NUMBER
	SKIPE	T1,LOGJFN		; ARE WE LOGGING?
	BOUT				; YES, OUTPUT TO LOG
	MOVE	T1,OUTJFN		; GET THE OUTPUT JFN
	BOUT				; OUTPUT IT
	SOJA	S,.CDPNT		; AND CONTINUE ON

.CDNBR:	PUSH	P,T2			; SAVE BYTE
	MOVEI	T2,"<"
	SKIPE	T1,LOGJFN		; ARE WE LOGGING?
	BOUT				; YES, OUTPUT TO LOG
	MOVE	T1,OUTJFN		; GET THE OUTPUT JFN
	BOUT				; OUTPUT IT
	POP	P,T2			; GET THE NUMBER BACK
	MOVE	T3,[NO%OOV!10]
	SKIPE	T1,LOGJFN		; ARE WE LOGGING?
	NOUT				; YES, OUTPUT TO LOG
	MOVE	T3,[NO%OOV!10]
	MOVE	T1,OUTJFN		; GET THE OUTPUT JFN
	NOUT				; OUTPUT IT
	SKIP
	MOVEI	T2,">"
	SKIPE	T1,LOGJFN		; ARE WE LOGGING?
	BOUT				; YES, OUTPUT TO LOG
	MOVE	T1,OUTJFN		; GET THE OUTPUT JFN
	BOUT				; OUTPUT IT
	SOJA	S,.CDPNT
; HERE TO DISPLAY DEFAULT INFO FOR THE LOG COMMAND

.IDLOG:	CONFIRM
	HRROI	T1,[ASCIZ\ SET DEFAULT (for) LOG (to) APPEND\]
	SKIPGE	.LJBLK			; ARE WE DEFAULT APPEND
	HRROI	T1,[ASCIZ\ SET DEFAULT (for) LOG (to) SUPERSEDE\]	; NO
	CALL	.SOUTR
	HRROI	T1,[ASCIZ\ SET DEFAULT (for) LOG (to) \]
	CALL	.SOUT
	HRROI	T1,[ASCIZ\NO \]
	SKIPN	L.SUPP			; ARE WE STRIPPING NULLS
	CALL	.SOUT			; NO
	HRROI	T1,[ASCIZ\SUPPRESS\]
	CALLRE	.SOUTR
; HERE TO DISPLAY DEFAULT INFO FOR THE SEND COMMAND

.IDSEN:	CONFIRM
	HRROI	T1,[ASCIZ\ SET DEFAULT (for) SEND (to) PAUSE (between transmitted lines) \]
	CALL	.SOUT
	MOVE	T2,SNDTIM		; GET THE TIMER VALUE
	MOVEI	T3,^D10			; OUTPUT IN RADIX-10
	CALL	.NOUT
	CALL	ERROR
	HRROI	T1,[ASCIZ\ (seconds)\]
	CALL	.SOUTR
	HRROI	T1,[ASCIZ\ SET DEFAULT (for) SEND (to) \]	; PRINT HEADER
	CALL	.SOUT
	HRROI	T1,[ASCIZ\STRIP (linefeeds following carriage-returns)\]
	SKIPN	SNDSLF			; ARE WE STRIPPING LINEFEEDS?
	HRROI	T1,[ASCIZ\TRANSMIT (all linefeeds)\]	; NO, SO CHANGE THE MSG
	CALL	.SOUTR			; PRINT THE APPROPRIATE MESSAGE
	RET

; HERE TO DISPLAY DEFAULT INFO FOR THE TAKE COMMAND

.IDTAK:	CONFIRM
	HRROI	T1,[ASCIZ\ SET DEFAULT (for) TAKE (to) \]	; PRINT HEADER
	CALL	.SOUT
	HRROI	T1,[ASCIZ\NO \]		; SET UP FOR NO
	SKIPN	.DECHO			; IS DEFAULT ECHO SET
	CALL	.SOUT			; NO, PRINT "NO"
	HRROI	T1,[ASCIZ\ECHO (COMMAND FROM "TAKE" FILE)\]	; PRINT TRAILER
	CALL	.SOUTR			; PRINT IT WITH CRLF
	HRROI	T1,[ASCIZ\ SET DEFAULT (for) TAKE (to) \]	; PRINT HEADER
	CALL	.SOUT
	HRROI	T1,[ASCIZ\ALLOW \]	; ASS_U_ME HES ALLOWING ERRORS
	SKIPN	.DERRE			; IS HE
	HRROI	T1,[ASCIZ\DISALLOW \]	; NO
	CALL	.SOUT
	HRROI	T1,[ASCIZ\(ERRORS DURING "TAKE" FILE)\]	; PRINT TRAILER
	CALL	.SOUTR			; PRINT IT AND CRLF
	RET
; HERE TO DISPLAY REMOTE-HOST INFORMATION

.IREMH:
	CONFIRM
	HLRZ	P1,DTETAB		; GET THE NUMBER OF ENTRIES IN THE TABLE
	JUMPE	P1,.IREM3		; JUST RETURN IF EMPTY
	MOVEI	P2,1			; SET UP INDEX

.IREM1:	HLLZ	T1,DTETAB(P2)		; GET POINTER TO FIRST BLOCK
	HRRI	T1,DTENAM		; SET UP FOR A BLT
	BLT	T1,DTESUB+3		; FROM TABLE TO HOLDING BUFFER
	HRROI	T1,[ASCIZ\ \]
	CALL	.SOUT
	HRROI	T1,DTENAM		; POINT TO THE REMOTE-HOST NAME
	CALL	.SOUT			; PRINT IT
	HRROI	T1,[ASCIZ\ => \]	; 
	CALL	.SOUT
	HRROI	T1,DTEADR		; POINT TO THE ADDRESS STRING
	CALL	.SOUT
	MOVE	T1,[POINT 7,DTESUB,6]	; POINT AT FIRST CHARACTER IN SUBADDRESS
	LDB	T1,T1			; GET IT
	JUMPE	T1,.IREM2		; JUMP IF NO SUBADDRESS
	HRROI	T1,[ASCIZ\ (\]
	CALL	.SOUT
	HRROI	T1,DTESUB		; POINT AT SUBADDRESS STRING
	CALL	.SOUT
	HRROI	T1,[ASCIZ\)\]
	CALL	.SOUT

.IREM2:	CALL	OCRLF			; FINISH UP LINE
	AOS	P2			; INCREMENT INDEX INTO DTETAB
	SOJG	P1,.IREM1		; DECREMENT COUNT AND JUMP IF MORE

.IREM3:	CALL	OCRLF			; ADD AN EXTRA CR/LF
	RET				; AND RETURN
; HERE TO DISPLAY VERSION INFORMATION

.IVERS:
	NOISE (of program)
	CONFIRM
.IVERH:	HRROI	T1,[ASCIZ\ This is X29PAD version \]
	CALL	.SOUT
	MOVEI	T3,^D8			; RADIX 8
	LDB	T2,[POINT 9,VERSIO,11]	; MAJOR VERSION
	CALL	.NOUT
	ERJMP .+1			; THIS CAN'T HAPPEN
	LDB	T2,[POINT 6,VERSIO,17]	; MINOR VERSION
	JUMPE	T2,.IVER0		; IF NO MINOR VERSION SKIP TO EDIT
	MOVEI	T2,"."
	CALL	.BOUT
	LDB	T2,[POINT 6,VERSIO,17]	; MINOR VERSION
	CALL	.NOUT
	ERJMP .+1			; THIS CAN'T HAPPEN
.IVER0:	MOVEI	T2,"("
	CALL	.BOUT
	HRRZ	T2,VERSIO		; EDIT NUMBER
	CALL	.NOUT
	ERJMP .+1			; THIS CAN'T HAPPEN
	MOVEI	T2,")"
	CALL	.BOUT
	LDB	T2,[POINT 3,VERSIO,2]	; WHO EDITED LAST
	JUMPE	T2,.IVER1		; ZERO, SO JUST FINISH OFF LINE
	MOVEI	T2,"-"
	CALL	.BOUT
	LDB	T2,[POINT 3,VERSIO,2]	; GET LAST EDITOR AGAIN
	CALL	.NOUT
	ERJMP .+1			; THIS CAN'T HAPPEN
.IVER1:	HRROI	T1,CRLF
	CALL	.SOUT
	HRROI	T1,[ASCIZ\ Gateway Access Library version is \]
	CALL	.SOUT
	MOVEI	T3,^D8			; RADIX 8
	LDB	T2,[POINT 8,E.VERS##,7]	; MAJOR VERSION
	CALL	.NOUT
	ERJMP .+1			; THIS CAN'T HAPPEN
	MOVEI	T2,"("
	CALL	.BOUT
	LDB	T2,[POINT 8,E.VERS,15]	; EDIT NUMBER
	CALL	.NOUT
	ERJMP .+1			; THIS CAN'T HAPPEN
	MOVEI	T2,")"
	CALL	.BOUT
	LDB	T2,[POINT 8,E.VERS,23]	; WHO EDITED LAST
	JUMPE	T2,.IVER3		; ZERO, SO JUST FINISH OFF LINE
	MOVEI	T2,"-"
	CALL	.BOUT
	LDB	T2,[POINT 8,E.VERS,23]	; GET LAST EDITOR AGAIN
	CALL	.NOUT
	ERJMP .+1			; THIS CAN'T HAPPEN
.IVER3:	HRROI	T1,CRLF
	CALL	.SOUT


	RET
; HERE TO GIVE INFORMATION ON THE LAST NETWORK ERROR

.INETE:
	CONFIRM
	CALL	NETINF			; DISPLAY INFO AVAILABLE ON IT
	CALL	OCRLF
	RET
; HERE TO DISPLAY STATUS OF X29PAD

.ISTAT:
	NOISE (of X29PAD)
	CONFIRM
	HRROI	T1,[ASCIZ\ NETWORK NAME (is) \]
	CALL	.SOUT
	MOVE	P1,[POINT 7,NETNAM,6]
	LDB	P2,P1
	JUMPE	P2,.ISTA1		; IF ZERO THEN THE NAME HASN'T BEEN SET
	HRROI	T1,NETNAM		; NETWORK NAME HAS BEEN SET
	CALL	.SOUT			; SO PRINT IT
	JRST	.ISTA2			; AND GO ON TO OTHER THINGS
.ISTA1:	HRROI	T1,[ASCIZ\unknown\]
	CALL	.SOUT
.ISTA2:	CALL	OCRLF
	HRROI	T1,[ASCIZ\ NETWORK PASSWORD (is) \]
	CALL	.SOUT
	MOVEI	T1,.FHSLF		; CURRENT PROCESS
	RPCAP				; GET CAPABILITIES
	TXNE	T3,SC%WHL!SC%OPR!SC%MNT	; SHOULD WE PRINT THE PASSWORD?
	JRST	.ISTA3			; YES, GO TRY TO PRINT IT
	HRROI	T1,[ASCIZ\not available\]
	CALL	.SOUT
	JRST	.ISTA5			; CONTINUE ON
.ISTA3:	MOVE	P1,[POINT 7,NETPSW,6]
	LDB	P2,P1			; GET THE FIRST BYTE OF THE PASSWORD
	JUMPE	P2,.ISTA4		; IF ZERO THEN PASSWORD HASN'T BEEN SET
	HRROI	T1,NETPSW		; POINT TO THE PASSWORD
	CALL	.SOUT				; AND PRINT IT
	JRST	.ISTA5			; AND GO ON TO OTHER THINGS
.ISTA4:	HRROI	T1,[ASCIZ\unknown\]
	CALL	.SOUT
.ISTA5:	CALL	OCRLF
	HRROI	T1,[ASCIZ\ BREAK-CHARACTER (is) \]
	CALL	.SOUT
	MOVE	T2,BRKCHR		; GET BREAK CHARACTER
	CAIG	T2,177			; 
	CAIGE	T2,1			; BETWEEN 1 AND 177?
	JRST	.IST08			; NO, SIGH
	CAIE	T2,40			; A SPACE?
	JRST	.IST06			; NO
	HRROI	T1,[ASCIZ\A SPACE\]
	CALL	.SOUT
	JRST	.IST0X
.IST06:	CAILE	T2,37			; A CONTROL CHARACTER?
	JRST	.IST07			; NO
	HRROI	T1,[ASCIZ\CONTROL-\]
	CALL	.SOUT
	ADDI	T2,100			; CONVERT TO A PRINTABLE CHARACTER
.IST07:	CALL	.BOUT
	JRST	.IST0X
.IST08:	HRROI	T1,[ASCIZ\DISABLED\]
	CALL	.SOUT
.IST0X:	CALL	OCRLF			; FINISH LINE
	HRROI	T1,[ASCIZ\ ESCAPE-CHARACTER (is) \]
	CALL	.SOUT
	MOVE	T2,ESCCHR		; GET ESCAPE CHARACTER
	CAIG	T2,177			; 
	CAIGE	T2,1			; BETWEEN 1 AND 177?
	JRST	.ISTA8			; NO, SIGH
	CAIE	T2,40			; A SPACE?
	JRST	.ISTA6			; NO
	HRROI	T1,[ASCIZ\A SPACE\]
	CALL	.SOUT
	JRST	.ISTAX
.ISTA6:	CAILE	T2,37			; A CONTROL CHARACTER?
	JRST	.ISTA7			; NO
	HRROI	T1,[ASCIZ\CONTROL-\]
	CALL	.SOUT
	ADDI	T2,100			; CONVERT TO A PRINTABLE CHARACTER
.ISTA7:	CALL	.BOUT
	JRST	.ISTAX
.ISTA8:	HRROI	T1,[ASCIZ\DISABLED\]
	CALL	.SOUT
.ISTAX:	CALL	OCRLF			; FINISH LINE
	HRROI	T1,[ASCIZ\ STATUS-DISPLAY-CHARACTER (is) \]
	CALL	.SOUT
	MOVE	T2,STSCHR		; GET STATUS-DISPLAY-CHARACTER
	CAIG	T2,177			; 
	CAIGE	T2,1			; BETWEEN 1 AND 177?
	JRST	.ISTB3			; NO, SIGH
	CAIE	T2,40			; A SPACE?
	JRST	.ISTB1			; NO
	HRROI	T1,[ASCIZ\A SPACE\]
	CALL	.SOUT
	JRST	.ISTBX
.ISTB1:	CAILE	T2,37			; A CONTROL CHARACTER?
	JRST	.ISTB2			; NO
	HRROI	T1,[ASCIZ\CONTROL-\]
	CALL	.SOUT
	ADDI	T2,100			; CONVERT TO A PRINTABLE CHARACTER
.ISTB2:	CALL	.BOUT
	JRST	.ISTBX
.ISTB3:	HRROI	T1,[ASCIZ\DISABLED\]
	CALL	.SOUT
.ISTBX:	CALL	OCRLF			; FINISH LINE
	HRROI	T1,[ASCIZ\ Transmitted: \]
	CALL	.SOUT
	MOVE	T2,XMTPKT		; GET THE NUMBER OF PACKETS TRANSMITTED
	MOVEI	T3,^D10			; IN DECIMAL
	CALL	.NOUT
	CALL	ERROR
	HRROI	T1,[ASCIZ\ packets, \]
	CALL	.SOUT
	MOVE	T2,XMTCHR		; GET THE NUMBER OF CHARACTERS XMTD
	MOVEI	T3,^D10			; IN DECIMAL
	CALL	.NOUT
	CALL	ERROR
	HRROI	T1,[ASCIZ\ characters\]
	CALL	.SOUTR
	HRROI	T1,[ASCIZ\ Received: \]
	CALL	.SOUT
	MOVE	T2,RCVPKT		; GET THE NUMBER OF PACKETS TRANSMITTED
	MOVEI	T3,^D10			; IN DECIMAL
	CALL	.NOUT
	CALL	ERROR
	HRROI	T1,[ASCIZ\ packets, \]
	CALL	.SOUT
	MOVE	T2,RCVCHR		; GET THE NUMBER OF CHARACTERS XMTD
	MOVEI	T3,^D10			; IN DECIMAL
	CALL	.NOUT
	CALL	ERROR
	HRROI	T1,[ASCIZ\ characters\]
	CALL	.SOUTR

	RET

; OTHER THINGS TO DISPLAY:
;			CONNECTION STATUS
;				SESSION START-TIME (IF CONNECTED)
;				DTE NUMBER CALLED (IF CONNECTED)
;			LOGGING ENABLED/DISABLED
;
	SUBTTL	LOG COMMAND

.LOG:
	NOISE	(output to file)
	MOVE	T2,[.LJBLK,,GTJBLK]	; BLT POINTER
	BLT	T2,GTJBLK+.GJJFN	; PUT OUR STUF IN GET JFN BLOCK
	MOVEI	T2,[FLDDB. .CMFIL,CM%SDH,,<log file spec>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	MOVEM	T2,LJFN			; SAVE JFN
	CONFIRM
	CALL	NOLOG			; IF A LOG FILE WAS OPEN, CLOSE IT FIRST
GETLOG:
	HRRZ	T1,LJFN			; GET JFN
;	MOVE	T2,[FLD(7,OF%BSZ)!OF%APP!OF%RTD]	; APPEND FLAGS
	MOVE	T2,[FLD(7,OF%BSZ)!OF%APP]	; APPEND FLAGS
	OPENF
	CALLRE	NOLOG.			; FAILURE
	MOVEM	T1,LOGJFN		; SAVE IT
	CALL	OCRLF
	HRROI	T1,[ASCIZ\ ***** Log file opened at \]
	CALL	.SOUT
	HRROI	T1,ODBUF		; POINT TO OUTPUT BUFFER
	SETOM	T2			; -1 IN T2
	MOVE	T3,[OT%NDA!OT%TMZ]	; TIME ONLY
	ODTIM
	ERCAL	FATAL
	SETZ	T2,			; ZERO T2
	IDPB	T2,T1			; AND FINISH STRING WITH A "NULL"
	HRROI	T1,ODBUF		; POINT TO STRING
	CALL	.SOUT			; AND PRINT IT
	HRROI	T1,[ASCIZ\ on \]
	CALL	.SOUT
	HRROI	T1,ODBUF		; POINT TO OUTPUT BUFFER
	SETOM	T2			; -1 IN T2
	MOVE	T3,[OT%FMN!OT%4YR!OT%DAM!OT%SPA!OT%NTM]	; DATE ONLY
	ODTIM
	ERCAL	FATAL
	SETZ	T2,			; ZERO T2
	IDPB	T2,T1			; AND FINISH STRING WITH A "NULL"
	HRROI	T1,ODBUF		; POINT TO STRING
	CALL	.SOUT
	HRROI	T1,[ASCIZ\ *****\]
	CALL	.SOUTR
	CALL	OCRLF
	CALLRE	L.SAVE

NOLOG.:
	HRROI	T1,[ASCIZ\?Could not open LOG file\]
	CALLRE	.SOUTR

LOG:	PUSH	P,T1			; SAVE T1
	PUSH	P,T2			; SAVE T2
	PUSH	P,T3			; SAVE T3
	MOVE	T1,LOGJFN		; GET LOG JFN
	MOVE	T2,CMDBLK+2		; GET PROMT POINTER
	SETZ	T3,
	SOUT
	MOVE	T2,CMDBLK+3		; GET INPUT STRING
	SOUT
	HLL	T2,CMDBLK+3		; MAKE LEFT SIDE OF POINTERS THE SAME
	SUB	T2,CMDBLK+3		; GET LOCATIONS
	MOVM	T2,T2			; MAKE POSITIVE
	ADDI	T2,2			; GIVE IT 2 EXTRA
	IMULI	T2,5			; FIVE BYTES PER WORD
	ADDM	T2,L.CNT		; UPDATE COUNT
	POP	P,T3			; RESTORE T3
	SKIPL	L.CNT			; TIME TO UPDATE?
	CALLRE	L.SAV1			; YES, GO UPDATE LOG
	POP	P,T2			; RESTORE T2
	POP	P,T1			; RESTORE T1
	RET


L.SAVE:	PUSH	P,T1			; SAVE T1
	PUSH	P,T2			; SAVE T2
L.SAV1:	MOVX	T1,CO%NRJ
	HRR	T1,LOGJFN		; GET JFN
	CLOSF				; CLOSE IT
	JRST	FATAL			; SHOULD NEVER HAPPEN
	HRRZ	T1,T1			; CLEAR LEFT HALF OF T1
;	MOVE	T2,[FLD(7,OF%BSZ)!OF%APP!OF%RTD]	; OPENF BITS
	MOVE	T2,[FLD(7,OF%BSZ)!OF%APP]	; OPENF BITS
	OPENF
	JRST	FATAL			; SHOULD NEVER HAPPEN
	HRROI	T1,-L.CNT%		; UPDATE COUNTER
	MOVEM	T1,L.CNT
	POP	P,T2			; RESTORE T2
	POP	P,T1			; RESTORE T1
	RET

L.SUPP:	0				;SUPERSEDE FLAG
L.CNT:	0				;CHARACTER COUNT
LOGJFN:	0				;JFN OF LOG FILE
LJFN:	0				;TEMP STORAGE OF APPEND AND LOG JFN

.LJBLK:	0
	0
	0
	0
	0
	440700,,[ASCIZ\LOG\]
	0
	0
	0
	SUBTTL	PUSH COMMAND

.PUSH:
	NOISE	(command level)
	CONFIRM
	MOVE	T1,FKHAN		; GET THE EXEC'S FORK HANDLE
	SKIPN	T1			; HAVE WE ALREADY MAPPED AN EXEC?
	JRST	.PUSH1			; NO
	HLL	T1,[ SF%CON ]		; YES, JUST CONTINUE IT
	SFORK
	WFORK
	ERCAL	FATAL
	RET

.PUSH1:	MOVX	T1,GJ%OLD!GJ%SHT	; TRY TO GET AN EXEC
	HRROI	T2,[ASCIZ\SYSTEM:EXEC.EXE\]
	GTJFN
	ERJMP	ERROR
	MOVEM	T1,EXCJFN		; SAVE THE JFN WE GOT FOR THE EXEC
	MOVX	T1,CR%CAP		; MAKE A FORK, GIVE IT OUR CAPABILITIES
	CFORK				; CREATE A FORK
	ERJMP	ERROR
	MOVEM	T1,FKHAN		; SAVE THE FORK HANDLE
	HRL	T1,EXCJFN		; FORM JFN,,FORK HANDLE
	MOVS	T1,T1			; GET WANTS TO SEE FORK HANDLE,,JFN
	GET				; COPY EXEC.EXE INTO INFERIOR FORK
	ERCAL	FATAL
	MOVE	T1,FKHAN		; GET THE FORK HANDLE BACK
	SETZ	T2,			; START AT OFFSET 0 IN ENTRY VECTOR
	SFRKV				; START THE FORK
	ERCAL	FATAL
	WFORK				; WAIT FOR IT TO COMPLETE
	ERCAL	FATAL
	RET
	SUBTTL	SEND COMMAND

SNDTIM:	1				; TIME TO PAUSE BETWEEN SENT MSGS

SNDBUF:	BLOCK	<^D128/5>+1
XMTBUF:	BLOCK	<^D128/4>+1		; 8-BIT OUTPUT BUFFER

CRSEEN:	0				; FLAG TO INDICATE A <CR> SEEN

SNDINT:	0				; FLAG TO INDICATE THE USER TYPED THE
					; ESCAPE-CHARACTER

SNDSLF:	-1				; SAYS WHETHER OR NOT TO STRIP LF
					; DEFAULT IS TO STRIP THEM

TMPJFN:	0				; A PLACE TO TEMPORARILY STORE THE JFN


.SEND:
	NOISE	(file)
	MOVEI	T2,[FLDDB. .CMIFI,CM%SDH,,<name of file to send>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	HRRZM	T2,TMPJFN		; SAVE THE JFN
	NOISE (to the REMOTE-HOST)
	CONFIRM
	SKIPE	CALLCT			; IS THERE A CALL CURRENTLY IN PROGRESS?
	JRST	.SEN01			; YES...IT'S OK TO TRY
	HRROI	T1,[ASCIZ\?There is no current connection to send to\]
	CALL	.SOUTR
	RET

.SEN01:	SKIPN	SNDFLG			; ALREADY SENDING A FILE?
	JRST	.SEN02			; NO, GO ON
	HRROI	T1,[ASCIZ\?A SEND is already in progress\]
	CALL	.SOUTR
	RET

.SEN02:	SETOM	SNDFLG			; INDICATE WE ARE SENDING
	MOVE	T1,TMPJFN		; GET THE JFN
	MOVEM	T1,SNDJFN		; AND SAVE IT
	MOVE	T2,[70000,,OF%RD]	; OPEN 7-BIT ASCII,,READ
	OPENF
	  ERJMP	ERROR
	JRST	.CAL8A			; GO RESTART COMMUNICATIONS
; HERE TO READ THE FILE TO BE SENT, STRIP LINEFEEDS AFTER CARRIAGE RETURNS
; (IF NECESSARY), REPACK INTO 8-BIT CHARACTERS, AND SEND THE DATA TO THE
; REMOTE-HOST. DATA WILL BE SENT ON A LINE BY LINE BASIS (A LINE IS A STRING
; TERMINATED BY A CARRIAGE RETURN) OR WHEN THE OUTPUT BUFFER ( 128 CHARACTERS
; IN LENGTH) BECOMES FILLED. AFTER A BUFFER IS SENT, THE TRANSMITTING ROUTINE
; WILL DISMISS FOR AN AMOUNT OF TIME EQUAL TO THE DEFAULT SEND TIMER (SNDTIM).

SNDDAT:	MOVE	T1,SNDJFN		; GET THE JFN OF THE FILE TO SEND
	HRROI	T2,SNDBUF		; POINT TO THE BUFFER
	MOVEI	T3,^D128		; READ 128 CHARACTERS MAX
	MOVEI	T4,015			; OR UNTIL A <CR> IS ENCOUNTERED
	SIN
	  ERJMP	SINERR
	MOVE	P1,[POINT 7,SNDBUF]	; POINT AT THE SOURCE BUFFER
	MOVEI	T1,^D128		; MAX SIZE OF THE BUFFER MINUS
	SUBM	T1,T3			; THE NUMBER OF CHARACTERS NOT READ
					; GIVES THE NUMBER OF CHARACTERS READ
SNDAT1:	MOVE	P2,[POINT 8,XMTBUF]	; POINT AT THE TRANSMIT BUFFER
	SETZ	S,			; ZERO THE XMT COUNTER
SNDAT2:	ILDB	T4,P1			; GET A CHARACTER
	CAIN	T4,015			; A <CR>???
	JRST	SNDAT5			; YES, GO SEND THE BUFFER
	SKIPN	SNDSLF			; ARE WE TO STRIP <LF> AFTER <CR>???
	JRST	SNDAT3			; NO, SEND EVERYTHING
	CAIE	T4,012			; YES, IS THIS A <LF>
	JRST	SNDAT3			; NO, GO SEND THE CHARACTER
	SKIPN	CRSEEN			; WAS THE LAST CHAR A <CR>???
	JRST	SNDAT3			; NO, GO ON
	SETZM	CRSEEN			; YES, CLEAR THE CRSEEN FLAG
	JRST	SNDAT4			; AND TOSS THE <LF>
SNDAT3:	SETZM	CRSEEN			; CLEAR THE CRSEEN FLAG
	IDPB	T4,P2			; STORE THE CHAR IN THE XMT BUFFER
	AOS	S			; COUNT IT
	CAIL	S,^D128			; IS THE BUFFER FULL?
	JRST	SNDAT6			; YES, GO SEND THE BUFFER
SNDAT4:	SOJG	T3,SNDAT2		; END OF INPUT STRING?
	MOVE	T1,SNDJFN		; YES, GET THE JFN OF THE FILE
	HRROI	T2,SNDBUF		; POINT AT THE BUFFER
	MOVEI	T3,^D128		; READ 128 CHARACTERS OR
	MOVEI	T4,015			; UNTIL A <CR> IS ENCOUNTERED
	SIN
	  ERJMP	SINERR
	MOVE	P1,[POINT 7,SNDBUF]	; POINT TO THE INPUT BUFFER
	MOVEI	T1,^D128		; MAX BUFFER SIZE
	SUBM	T1,T3			; MINUS CHARACTERS NOT READ GIVES
					; CHARACTERS READ
	JRST	SNDAT2			; GO ON PROCESSING THE FILE

SNDAT5:	SETOM	CRSEEN			; INDICATE <CR> WAS THE LAST CHAR SEEN
	IDPB	T4,P2			; PUT IT IN THE XMT BUFFER
	AOS	S			; COUNT IT
	CALL	SNDRTN			; AND SEND THE BUFFER
	SKIPN	SNDINT			; HAVE WE BEEN INTERRUPTED BY THE USER?
	JRST	SNDDAT			; NO, GO BACK FOR MORE
	MOVX	T1,.FHSLF		; YES, POINT AT OURSELF
	MOVX	T2,CH%TTY		; POINT AT THE TTY CHANNEL
	DIC				; AND DISABLE HIM
	ERCAL	FATAL
	MOVX	T2,CH%TMR		; NOW THE TIMER CHANNEL
	DIC
	ERCAL	FATAL
	MOVX	T2,CH%NET		; AND THE NETWORK CHANNEL
	DIC
	ERCAL	FATAL
	SETZM	SNDINT			; CLEAR THE INTERRUPT FLAG
	SETOM	ESCFLG			; INDICATE ESCAPE
	MOVEI	T1,.PRIIN
	RFMOD				; READ CURRENT TERMINAL STATE
	ERCAL	FATAL
	MOVEM	T2,NMODE		; AND SAVE IT
	CALL	OCRLF			; PRINT A CR/LF
	JRST	.CALL9			; PAUSE AND LET USER TYPE COMMANDS

SNDAT6:	CALL	SNDRTN			; GO SEND THE BUFFER
	JRST	SNDAT1			; AND CONTINUE PROCESSING THE INPUT BUF


; HERE TO SEND THE TRANSMIT BUFFER

SNDRTN:
	HRRZ	T1,PORTNO		; GET THE PORT NUMBER
	MOVEM	T1,SDMBLK		; AND STORE IT
	SETZM	SDMBLK+1		; CLEAR THE STATUS RETURN WORD
	HRRZ	T1,S			; GET THE CHARACTER COUNT
	MOVEM	T1,SDMBLK+2		; AND STORE IT
	MOVE	T1,[POINT 8,XMTBUF]	; POINT AT THE BUFFER TO SEND
	MOVEM	T1,SDMBLK+3		; AND STORE IT
	MOVEI	T1,SDMBLK		; POINT AT THE ARG BLOCK
	CALL	X%SDM##			; AND SEND THE MESSAGE
	HRRZ	T1,SDMBLK+1		; GET THE RETRUN STATUS
	CAIN	T1,XC%SUC		; SUCCESS?
	JRST	SNDRT1			; YES
	MOVEM	T1,LASTNE		; SAVE THE ERROR
	CALL	NETERR			; AND COMPLAIN
SNDRT1:	ADDM	S,XMTCHR		; ADD NUMBER OF BYTES SENT TO TOTAL
	AOS	XMTPKT			; COUNT THE PACKET
	SKIPN	T1,SNDTIM		; GET THE TIME TO PAUSE AND SKIP IF >0
	RET				; PAUSE TIME =0 SO JUST RETURN
	IMULI	T1,^D1000		; MULTIPLY BY 1000. TO GET MILLISECONDS
	DISMS
	RET				; AND RETURN


SINERR:	MOVEI	T1,.FHSLF		; GET THE ERROR TYPE
	GETER
	HRRZ	T2,T2			; CLEAR LEFT HALF
	CAIE	T2,IOX4			; WAS IT AN EOF
	JRST	FATAL			; NO, FATAL ERROR
	MOVE	P1,[POINT 7,SNDBUF]	; POINT AT SOURCE
	MOVEI	T1,^D128		; MAX NUMBER OF CHARACTERS READ MINUS
	SUBM	T1,T3			; NUMBER OF CHARACTERS NOT READ GIVES
					; TOTAL CHARACTERS READ
SINER0:	MOVE	P2,[POINT 8,XMTBUF]	; POINT AT DESTINATION (HOLDING BUFFER)
	SETZ	S,			; ZERO THE XMT COUNT
SINER1:	ILDB	T4,P1			; GET A CHARACTER
	SKIPN	SNDSLF			; STRIPPING <LF> AFTER <CR>???
	JRST	SINER2			; NO, GO ON
	CAIE	T4,012			; IS THIS A <LF>
	JRST	SINER2			; NO, GO ON
	SKIPN	CRSEEN			; WAS LAST CHAR A <CR>??
	JRST	SINER2			; NO, GO ON
	SETZM	CRSEEN			; YES, CLEAR THE CRSEEN FLAG
	JRST	SINER3			; AND FLUSH THE <LF>
SINER2:	SETZM	CRSEEN			; CLEAR THE CRSEEN FLAG
	IDPB	T4,P2			; STORE THE CHARACTER
	AOS	S
	CAIL	S,^D128			; IS THE XMT BUFFER FULL?
	JRST	SINER5			; YES, GO TRANSMIT IT
SINER3:	SOJG	T3,SINER1		; GO PROCESS REMAINING CHARACTERS
	CALL	SNDRTN			; NOW GO SEND DATA
	JRST	SINER6			; GO FINISH UP

SINER5:	CALL	SNDRTN			; SEND THE BUFFER
	JRST	SINER0			; AND CONTINUE PROCESSING

SINER6:	MOVE	T1,SNDJFN		; GET THE INPUT FILE'S JFN
	CLOSF				; CLOSE THE SNDJFN
	  ERCAL	FATAL			; SHOULD NEVER HAPPEN
	MOVX	T1,.FHSLF		; POINT AT OURSELF
	MOVX	T2,CH%TTY		; POINT AT THE TTY CHANNEL
	DIC				; AND DISABLE HIM
	ERCAL	FATAL
	MOVX	T2,CH%TMR		; NOW THE TIMER CHANNEL
	DIC
	ERCAL	FATAL
	MOVX	T2,CH%NET		; AND THE NETWORK CHANNEL
	DIC
	ERCAL	FATAL
	SETOM	ESCFLG			; INDICATE ESCAPE
	MOVEI	T1,.PRIIN
	RFMOD				; READ CURRENT TERMINAL STATE
	ERCAL	FATAL
	MOVEM	T2,NMODE		; AND SAVE IT
	CALL	OCRLF			; PRINT A CR/LF
	SETZM	SNDJFN			; CLEAR THE SEND JFN
	SETZM	SNDFLG			; CLEAR THE SEND-IN-PROGRESS FLAG
	JRST	.CALL9			; ALL DONE
	SUBTTL	SET COMMAND

.SET:
	MOVEI	T2,[FLDDB. .CMKEY,,SETTAB,<>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL?
	JRST	ERROR			; YES
	HRRZ	T2,(T2)			; GET THE DISPATCH ADDRESS
	JRST	(T2)			; AND GO DO IT


; KEYWORD TABLE FOR THE SET COMMAND

SETTAB:	SETTBL,,SETTBL			; ACTUAL,,MAXIMUM NUMBER OF ENTRIES
	TBL (BREAK-CHARACTER,,.BRKCH)
	TBL (DEFAULT,,.DEF)
	TBL (ESCAPE-CHARACTER,,.ESCAP)
	TBL (NETWORK,,.NETWO)
	TBL (PAD-PARAMETER,,.PADPR)
	TBL (STATUS-DISPLAY-CHARACTER,,.STATU)
SETTBL==<.-SETTAB>-1
; HERE TO SET THE BREAK-CHARACTER

.BRKCH:	MOVEI	T2,BRKCHR		; WHERE TO PUT CHARACTER
	MOVEM	T2,CH.ADR
	CALLRE	.CHAR			; GO GET CHARACTER
; HERE TO SET THE ESCAPE CHARACTER

.ESCAP:	MOVEI	T2,ESCCHR		; WHERE TO PUT CHARACTER
	MOVEM	T2,CH.ADR
	CALLRE	.CHAR			; GO GET CHARACTER
; HERE TO SET NETWORK PARAMETERS

.NETWO:
	MOVEI	T2,[FLDDB. .CMKEY,,NETTAB,<>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T2,(T2)
	JRST	(T2)

NETTAB:	NETTBL,,NETTBL
	TBL (NAME,,.NTNAM)
	TBL (PASSWORD,,.NTPSW)
NETTBL=<.-NETTAB>-1
; HERE TO SET NETWORK NAME

.NTNAM:
	NOISE (to)
	MOVEI	T2,[FLDDB. .CMFLD,CM%SDH,,<network name (maximum of 16 characters)>]
	COMND
	ERCAL	FATAL
	MOVE	P1,[POINT 7,ATMBUF,6]	; POINT TO THE FIRST CHARACTER
	MOVE	P2,[POINT 7,NETNAM,6]	; POINT TO THE DESTINATION
	SETZ	P3,			; ZERO A CHARACTER COUNTER
	LDB	P4,P1			; GET A CHARACTER
.NTNM1:	CAIE	P4,040			; A SPACE?
	JRST	.NTNM2			; NO, GO ON
	ILDB	P4,P1			; GET ANOTHER CHARACTER
	JRST	.NTNM1			; AND CHECK FOR ANOTHER LEADING SPACE
.NTNM2:	DPB	P4,P2			; STORE IT
	AOS	P3			; COUNT IT
.NTNM3:	ILDB	P4,P1			; GET A CHARACTER
	CAIN	P4,0			; A NUL?
	JRST	.NTNES			; YES, END OF STRING
	IDPB	P4,P2			; DEPOSIT IT
	AOS	P3			; COUNT IT
	CAIG	P3,^D16			; MORE THAN ^D16 CHARACTERS?
	JRST	.NTNM3			; NO, MOVE ANOTHER CHARACTER
	HRROI	T1,[ASCIZ\?Network name cannot exceed 16 characters\]
	CALL	.SOUTR
	SETZM	NETNAM			; FLUSH THE BAD NAME
	RET

.NTNES:	IDPB	P4,P2			; FINISH OFF STRING
	CONFIRM
	RET
; HERE TO SET THE NETWORK ACCESS PASSWORD
; NOTE: DO NOT ECHO PASSWORD

.NTPSW:
	NOISE (to)
	MOVEI	T2,[FLDDB. .CMFLD,CM%SDH,,<network access password (maximum of 16 characters)>]
	COMND
	ERCAL	FATAL
	MOVE	P1,[POINT 7,ATMBUF,6]	; POINT TO THE FIRST CHARACTER
	MOVE	P2,[POINT 7,NETPSW,6]	; POINT TO THE DESTINATION
	SETZ	P3,			; ZERO A CHARACTER COUNTER
	LDB	P4,P1			; GET A CHARACTER
.NTPW1:	CAIE	P4,040			; A SPACE?
	JRST	.NTPW2			; NO, GO ON
	ILDB	P4,P1			; GET ANOTHER CHARACTER
	JRST	.NTPW1			; AND CHECK FOR ANOTHER LEADING SPACE
.NTPW2:	DPB	P4,P2			; STORE IT
	AOS	P3			; COUNT IT
.NTPW3:	ILDB	P4,P1			; GET A CHARACTER
	CAIN	P4,0			; A NUL?
	JRST	.NTPES			; YES, END OF STRING
	IDPB	P4,P2			; DEPOSIT IT
	AOS	P3			; COUNT IT
	CAIG	P3,^D16			; MORE THAN ^D16 CHARACTERS?
	JRST	.NTPW3			; NO, MOVE ANOTHER CHARACTER
	HRROI	T1,[ASCIZ\?Network password cannot exceed 16 characters\]
	CALL	.SOUTR
	SETZM	NETPSW			; ZERO OUT BAD PASSWORD
	RET

.NTPES:	IDPB	P4,P2			; FINISH OFF STRING
	CONFIRM
	RET
;HERE TO PARSE A SET DEFAULT COMMAND

.DEF:	NOISE	(for)
	MOVEI	T2,[FLDDB. .CMKEY,,DEFTAB]	; POINT TO DEFAULT TABLE
	COMND
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	HRRZ	T2,(T2)			; GET THE COMMAND DISPATCH
	JRST	(T2)			; GO...


DEFTAB:	DEFTBL,,DEFTBL
	TBL (CALL,,.DCALL)
	TBL (LOG,,.DLOG)
	TBL (SEND,,.DSEND)
	TBL (TAKE,,.DTAKE)
DEFTBL==<.-DEFTAB>-1
; HERE TO PROCESS A SET DEFAULT CALL COMMAND

.DCALL:	MOVEI	T2,[FLDDB. .CMKEY,,DCATAB]	; POINT TO THE DEF CALL TBL
	COMND
	  ERCAL	FATAL			; SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL?
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	HRRZ	T2,(T2)			; GET THE DISPATCH
	JRST	(T2)			; GO DO IT


DCATAB:	DCATBL,,DCATBL
	TBL (CLOSED-USER-GROUP,,.DCCUG)
	TBL (FACILITIES-DATA,,.DCFAC)
	TBL (USER-DATA,,.DCUSD)
DCATBL==<.-DCATAB>-1
; HERE TO PROCESS A SET DEFAULT CALL CLOSED-USER-GROUP COMMAND

.DCCUG:	NOISE (to)
	MOVEI	P1,^D16			; GET MAX NUMBER OF DATA BYTES LEGAL
	MOVE	P2,[POINT 7,CDBUF]	; POINT AT THE DEST DATA BUFFER
	CALL	.CUGPR
	  RET				; THE USER MADE A MISTAKE, JUST RETURN
	MOVE	P1,[CDBUF,,CUGDEF]	; LOAD SOURCE,,DESTINATION
	BLT	P1,CUGDEF+3		; AND MOVE THEM
	RET
; HERE TO PROCESS A SET DEFAULT CALL FACILITIES-DATA COMMAND

.DCFAC:	NOISE (to)
	MOVEI	P1,^D63			; GET MAX NUMBER OF DATA BYTES LEGAL
	MOVE	P2,[POINT 8,CDBUF]	; POINT AT THE DEST DATA BUFFER
	CALL	.CDPAR
	  RET				; HMMMM... THE TOAD MISTYPED
	MOVEM	S,FACDCT		; SET THE COUNT OF BYTES IN FACILITIES
					; DATA STRING
	MOVE	P1,[CDBUF,,FACDEF]	; LOAD SOURCE,,DESTINATION
	BLT	P1,FACDEF+17		; AND MOVE THEM
	RET
.DCUSD:	NOISE (to)
	MOVEI	P1,^D12			; GET MAX NUMBER OF DATA BYTES LEGAL
	MOVE	P2,[POINT 8,CDBUF]	; POINT AT THE DEST DATA BUFFER
	CALL	.CDPAR
	  RET				; HMMMM... THE TOAD MISTYPED
	ADDI	S,4			; ACCOUNT FOR THE PROTOCOL BYTES
	MOVEM	S,UCDDCT		; SET COUNT OF BYTES IN USER-DATA STRING
	MOVE	S,USRDAT		; GET THE PROTOCOL STRING
	MOVEM	S,UCDDEF		; AND STORE IT
	MOVE	P1,[CDBUF,,UCDDEF+1]	; LOAD SOURCE,,DESTINATION
	BLT	P1,UCDDEF+3		; AND MOVE THEM
	RET
; HERE TO PARSE FACILITIES-DATA OR USER-DATA STRINGS

.CDPAR:	SETZ	S,			; CLEAR THE NUMBER OF BYTES RETURNED
.CDPAL:	MOVEI	T2,[FLDDB. .CMQST,CM%SDH,,<characters to pass in double quotes>,,OCTFDB]
	COMND
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	HRRZ	T3,T3			; GET FDB USED
	CAIN	T3,OCTFDB		; DID HE TYPE A OCTAL NUMBER
	JRST	.CDOCT			; YES, GO SAVE IT
	CAIE	T3,GENRIC		; DID HE JUST TYPE A CRLF
	JRST	.CDQST			; NO, MUST HAVE BEEN A QUOTED STRING
	AOS	(P)			; YES, SUCCESS
	SKIPE	LOGJFN
	CALL	LOG
	SKIPE	.TAKEF			; ARE WE DOING A TAKE
	JRST	.TECC			; YES, GO ECHO
	RET				; NO

.CDOCT:	SOJL	P1,.CDOVF		; TO MANY BYTES?
	IDPB	T2,P2			; SAVE BYTE
	TDNN	T2,[-400]		; IN RANGE?
	AOJA	S,.CDPAL		; YES, GET NEXT ONE
	MOVEI	T1,.FHSLF		; THIS FORK
	MOVX	T2,FLINX3		; NUMBER TO LARGE
	SETER
	JRST	ERROR

.CDQST:	MOVE	T2,[POINT 7,ATMBUF]	; POINT TO THE ATOM BUFFER
.CDQSL:	ILDB	T3,T2			; GET THE BYTE
	JUMPE	T3,.CDPAL		; LAST ONE?
	SOJL	P1,.CDOVF		; TOO MANY BYTES?
	IDPB	T3,P2			; SAVE IT
	AOJA	S,.CDQSL

.CDOVF:	HRROI	T1,[ASCIZ\?String is too long\]
	CALL	.SOUTR
	RET


;	MOVEI	T1,.FHSLF		; THIS FORK
;	MOVX	T2,CKAX1		; ARGUMENT BLOCK TO SMALL
;	SETER
;	JRST	ERROR


OCTFDB:	FLDDB. .CMNUM,CM%SDH,10,<octal code <0-377>>,,GENRIC
; HERE TO PARSE CLOSED-USER-GROUP STRINGS

.CUGPR:
	MOVEI	T2,[FLDDB. .CMQST,CM%SDH,,<a string in double quotes (16 characters maximum)>,,GENRIC]
	COMND
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	HRRZ	T3,T3			; WHO PARSED THIS?
	CAIE	T3,GENRIC		; JUST A CONFIRM?
	JRST	.CUGP1			; NO, GO PROCESS THE STRING
	SETZ	T1,			; CLEAR OUT T1
	IDPB	T1,P2			; PUT IT IN THE BUFFER
	JRST	.CUGPY			; AND RETURN
	
.CUGP1:	MOVE	T2,[POINT 7,ATMBUF]	; POINT TO THE ATOM BUFFER
	AOS	P1			; ADD ONE TO ACCOUNT FOR THE LAST NULL
.CUGQS:	ILDB	T3,T2			; GET THE BYTE
	IDPB	T3,P2			; SAVE IT
	JUMPE	T3,.CUGPX		; LAST ONE?
	SOJL	P1,.CUGOV		; TOO MANY BYTES?
	JRST	.CUGQS			; GO GET MORE

.CUGOV:	HRROI	T1,[ASCIZ\?String is too long\]
	CALL	.SOUTR
	RET

.CUGPX:	CONFIRM
.CUGPY:	AOS	(P)			; SET SKIP RETURN
	SKIPE	LOGJFN
	CALL	LOG
	SKIPE	.TAKEF			; ARE WE DOING A TAKE
	JRST	.TECC			; YES, GO ECHO
	RET				; NO
; HERE TO PROCESS A SET DEFAULT LOG COMMAND

.DLOG:	NOISE (to)
	MOVEI	T2,[FLDDB. .CMKEY,,DLOTAB]	; POINT TO DEF LOG TBL
	COMND
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	SETOM	.DLOSF			; SET THE SET FLAG
	HRRZ	T2,(T2)			; GET THE DISPATCH
	JRST	(T2)			; GO DO IT


.DLOAP:	NOISE (existing log file!)
	CONFIRM
	MOVX	T2,GJ%MSG		; DONT SPECIFY NEW FILE
	MOVEM	T2,.LJBLK		; SABE IT IN BLOCK
	RET

.DLONO:	MOVEI	T2,[FLDDB. .CMKEY,,DLNTAB]
	COMND
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	SETZM	.DLOSF			;CLEAR THE SET FLAG
	HRRZ	T2,(T2)			; GET THE DISPATCH
	JRST	(T2)			; GO DO IT

.DLOSU:	NOISE (null characters in log file!)
	CONFIRM
	MOVE	T2,.DLOSF		; GET THE SET FLAG
	MOVEM	T2,L.SUPP		; SET OR CLEAR THE SUPPRESS FLAG
	RET

.DLONE:	NOISE (existing log file!)
	CONFIRM
	MOVX	T2,GJ%FOU!GJ%MSG	; GET JFN TYPE
	MOVEM	T2,.LJBLK		; SAVE IT
	RET

DLNTAB:	DLNTBL,,DLNTBL			; ACTUAL,,MAXIMUM NUMBER OF ENTRYS
	TBL (SUPPRESS,,.DLOSU)
DLNTBL==<.-DLNTAB>-1			; NUMBER OF ENTRYS IN THE TABLE


DLOTAB:	DLOTBL,,DLOTBL			; ACTUAL,,MAXIMUM NUMBER OF ENTRYS
	TBL(APPEND,,.DLOAP)
	TBL (NO,,.DLONO)
	TBL (SUPERSEDE,,.DLONE)
	TBL (SUPPRESS,,.DLOSU)
DLOTBL==<.-DLOTAB>-1			; NUMBER OF ENTRYS IN THE TABLE

.DLOSF:	0
; HERE TO PROCESS A SET DEFAULT SEND COMMAND

.DSEND:	NOISE (to)
	MOVEI	T2,[FLDDB. .CMKEY,,DSETAB]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T2,(T2)			; GET THE VALUE OF THE KEY WORD
	JRST	(T2)

DSETAB:	DSETBL,,DSETBL
	TBL (PAUSE,,.DSENP)
	TBL (STRIP,,.DSENS)
	TBL (TRANSMIT,,.DSENT)
DSETBL==<.-DSETAB>-1
; HERE TO PARSE SET DEFAULT SEND PAUSE

.DSENP:	NOISE (between transmitted lines)
	MOVEI	T2,DCPFLD
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	MOVE	S,T2			; SAVE THE ARG
	NOISE (seconds)
	CONFIRM
	CAIG	S,^D10			; LESS THAN OR EQUAL TO TEN?
	CAIGE	S,0			; AND GREATER THAN OR EQUAL TO ZERO?
	JRST	.DCPER			; COMPLAIN
	MOVEM	S,SNDTIM		; SAVE THE TIMER
	RET

.DCPER:	HRROI	T1,[ASCIZ\?Timer must be between 0 and 10 seconds\]
	CALL	.SOUTR
	RET


DCPFLD:	FLDDB. .CMNUM,CM%SDH,^D10,<an interval from 0 seconds to 10 seconds
    in 1 second increments>
; HERE TO PARSE SET DEFAULT SEND STRIP

.DSENS:	NOISE (linefeeds following carriage-returns)
	CONFIRM
	SETOM	SNDSLF			; INDICATE THAT WE SHOULD STRIP <LF>
	RET


.DSENT:	NOISE (all linefeeds)
	CONFIRM
	SETZM	SNDSLF			; INDICATE THAT WE SHOULD SEND ALL <LF>
	RET
; HERE TO PROCESS A SET DEFAULT TAKE COMMAND

.DTAKE:	NOISE	(to)
	MOVEI	T2,[FLDDB. .CMKEY,,DTATAB]	; POINT TO DEF TAKE TBL
	COMND
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	HRRZ	T2,(T2)			; GET THE COMMAND DISPATCH
	MOVEI	T3,-1			; SET FLAGS
	MOVEM	T3,.TERRE		; SET ALLOW ERROR FLAG
	MOVEM	T3,.TECHO		; SET .TECHO FLAG
	CALL	(T2)			; GO...
	MOVE	T2,.TECHO		; GET .TECHO
	SKIPG	T2			; DID HE SET IT
	MOVEM	T2,.DECHO		; YES, SAVE DEFAULT
	MOVE	T2,.TERRE		; GET .TERRE
	SKIPG	T2			; DID HE SET IT
	MOVEM	T2,.DERRE		; YES, SAVE DEFAULT
	RET

; DEFAULT TAKE TABLE

DTATAB:	DTATBL,,DTATBL			; ACTUAL,,MAXIMUM NUMBER OF ENTRYS
	TBL (ALLOW,,.TALOW)
	TBL (DISALLOW,,.TDISA)
	TBL (ECHO,,.TECO)
	TBL (NO,,.TNO)
DTATBL==<.-DTATAB>-1			; NUMBER OF ENTRYS IN THE TABLE
; HERE TO SET PAD PARAMETERS

.PADPR:
;	NOISE (parameter to set)
	MOVEI	T2,[FLDDB. .CMKEY,,PADTAB,<>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR
	HRRZ	T2,(T2)
	JRST	(T2)


PADTAB:	PADTBL,,PADTBL				; ACTUAL,,MAX NUMBER OF ENTRIES
	TBL (1,CM%INV,.P.ESC)			; X.3 PAD PARAMETER 1
	TBL (10,CM%INV,.P.WID)			; X.3 PAD PARAMETER 10
	TBL (11,CM%INV,.P.RAT)			; X.3 PAD PARAMETER 11
	TBL (12,CM%INV,.P.DNF)			; X.3 PAD PARAMETER 12
	TBL (13,CM%INV,.P.LFI)			; X.3 PAD PARAMETER 13
	TBL (14,CM%INV,.P.LFP)			; X.3 PAD PARAMETER 14
	TBL (15,CM%INV,.P.LOC)			; X.3 PAD PARAMETER 15
	TBL (16,CM%INV,.P.DEL)			; X.3 PAD PARAMETER 16
	TBL (17,CM%INV,.P.CAN)			; X.3 PAD PARAMETER 17
	TBL (18,CM%INV,.P.DPY)			; X.3 PAD PARAMETER 18
	TBL (2,CM%INV,.P.ECH)			; X.3 PAD PARAMETER 2
	TBL (3,CM%INV,.P.DFW)			; X.3 PAD PARAMETER 3
	TBL (4,CM%INV,.P.TMR)			; X.3 PAD PARAMETER 4
	TBL (5,CM%INV,.P.NDF)			; X.3 PAD PARAMETER 5
	TBL (6,CM%INV,.P.NMD)			; X.3 PAD PARAMETER 6
	TBL (7,CM%INV,.P.BRK)			; X.3 PAD PARAMETER 7
	TBL (8,CM%INV,.P.DIS)			; X.3 PAD PARAMETER 8
	TBL (9,CM%INV,.P.CRP)			; X.3 PAD PARAMETER 9
	TBL (ACTION-ON-BREAK,,.P.BRK)		; X.3 PAD PARAMETER 7
	TBL (CANCEL-CHARACTER,,.P.CAN)		; X.3 PAD PARAMETER 17
	TBL (CARRIAGE-RETURN-PADDING,,.P.CRP)	; X.3 PAD PARAMETER 9
	TBL (DATA-FORWARDING,,.P.DFW)		; X.3 PAD PARAMETER 3
	TBL (DELETE-CHARACTER,,.P.DEL)		; X.3 PAD PARAMETER 16
	TBL (DISCARD-OUTPUT,,.P.DIS)		; X.3 PAD PARAMETER 8
	TBL (DISPLAY-CHARACTER,,.P.DPY)		; X.3 PAD PARAMETER 18
	TBL (DTE-TO-NET-FLOW-CONTROL,,.P.DNF)	; X.3 PAD PARAMETER 12
	TBL (ECHO,,.P.ECH)			; X.3 PAD PARAMETER 2
	TBL (ESCAPE-TO-COMMAND-MODE,,.P.ESC)	; X.3 PAD PARAMETER 1
	TBL (IDLE-TIMER,,.P.TMR)		; X.3 PAD PARAMETER 4
	TBL (LINE-WIDTH,,.P.WID)		; X.3 PAD PARAMETER 10
	TBL (LINEFEED-INSERTION,,.P.LFI)	; X.3 PAD PARAMETER 13
	TBL (LINEFEED-PADDING,,.P.LFP)		; X.3 PAD PARAMETER 14
	TBL (LOCAL-EDITING,,.P.LOC)		; X.3 PAD PARAMETER 15
	TBL (NET-TO-DTE-FLOW-CONTROL,,.P.NDF)	; X.3 PAD PARAMETER 5
	TBL (PAD-SIGNAL-CONTROL,,.P.NMD)	; X.3 PAD PARAMETER 6
	TBL (RATE,,.P.RAT)			; X.3 PAD PARAMETER 11
PADTBL==<.-PADTAB>-1
; HERE TO SET THE ECHO PARAMETER

.P.ECH:
	NOISE (to)
	MOVEI	T2,[FLDDB. .CMKEY,,ECHTAB,<>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR
	HRRZ	S,(T2)			; GET THE VALUE RETURNED
	CONFIRM
	TXO	S,PF%SET		; PARAMETER WAS SET
	MOVEM	S,PAD.2			; AND SET THE PAD PARAMETER
	RET

ECHTAB:	ECHTBL,,ECHTBL
	TBL (LOCAL-ECHO,,1)
	TBL (REMOTE-ECHO,,0)
ECHTBL==<.-ECHTAB>-1
; HERE TO SET THE DATA FORWARDING PARAMETER

.P.DFW:
	NOISE (on)
	MOVE	T2,[DFWTAB,,SCRTAB]	; SET UP TABLE
	BLT	T2,SCRTAB+DFWTBL
	MOVEI	T4,DFWLGL		; POINT AT LEGAL COMBINATIONS
	CALL	SCRTCH			; GO GET THE ENTRYS
	RET				; ERROR, JUST RETURN
	TXO	S,PF%SET		; PARAMETER WAS SET
	MOVEM	S,PAD.3			; SET THE PAD PARAMETER
	RET

DFWTAB:	DFWTBL,,DFWTBL
	TBL (ALPHANUMERICS,,P03%AL)
	TBL (CARRIAGE-RETURN,,P03%CR)
	TBL (CONTROL-CHARACTERS,,P03%CT)
	TBL (EDITING-CHARACTERS,,P03%ED)
	TBL (ESCAPE-CHARACTERS,,P03%ES)
	TBL (FORMS-CONTROL-CHARACTERS,,P03%FM)
	TBL (NO-SIGNAL,,^D0)
	TBL (OTHER-CHARACTERS,,P03%OT)
	TBL (TERMINATOR-CHARACTERS,,P03%TR)
DFWTBL==<.-DFWTAB>-1

; TABLE OF LEGAL COMBINATIONS

DFWLGL:	DFWLEN
	0
	P03%CR
	P03%CR!P03%ES
	P03%CR!P03%TR
	P03%CR!P03%ES!P03%ED!P03%TR!P03%FM!P03%CT
DFWLEN==<.-DFWLGL>-1
; HERE TO SET THE ESCAPE FROM DATA TRANSFER MODE PARAMETER

.P.ESC:
	NOISE (to)
	MOVEI	T2,[FLDDB. .CMKEY,,ESCTAB,<>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	S,(T2)			; GET THE VALUE RETURNED
	CONFIRM
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	TXO	S,PF%SET
	MOVEM	S,PAD.1			; AND SET THE PAD PARAMETER
	RET

ESCTAB:	ESCTBL,,ESCTBL
	TBL (PERMITTED,,1)
	TBL (PROHIBITED,,0)
ESCTBL==<.-ESCTAB>-1
; HERE TO SET THE CHARACTER FORWARDING TIMER

.P.TMR:
	NOISE (to)
	MOVEI	T2,[FLDDB. .CMKEY,,TMRTAB,<>,,TMRFLD]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; GET THE ADDRESS OF THE FLD USED
	CAIN	T3,TMRFLD		; DID WE PARSE A NUMBER?
	JRST	.P.TM1			; YES, RESULT IN T2
	HRRZ	S,(T2)			; NO, GET THE ARGUMENT
	JRST	.P.TM3			; AND CONFIRM

.P.TM1:
	SETZ	S,			; CLEAR S
	FMPR	T2,[20.]		; MULTIPLY THE NUMBER BY 20.
	FIXR	S,T2			; CONVERT IT TO FIXED POINT
	JUMPLE	S,.FLERR		; IF ITS LESS THAN 1, ERROR
	CAILE	S,^D255			; IF ITS GREATER THAN 255., ERROR
	JRST	.FLERR			; OUT OF RANGE
.P.TM3:	CONFIRM
	TXO	S,PF%SET
	MOVEM	S,PAD.4			; AND SET PAD IDLE-TIMER
	RET

TMRTAB:	TMRTBL,,TMRTBL
	TBL (DISABLED,,0)
TMRTBL==<.-TMRTAB>-1

TMRFLD:	FLDDB. .CMFLT,CM%SDH,^D10,<an interval from .05 seconds to 12.75 seconds
    in .05 second increments>

.FLERR:	HRROI	T1,[ASCIZ\?Timer must be between .05 and 12.75 seconds\]
	CALL	.SOUTR
	RET
; HERE TO SET CARRIAGE RETURN PADDING

.P.CRP:
	NOISE (to)
	MOVEI	T2,[FLDDB. .CMKEY,,CRPTAB,<>,,CRPFLD]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; GET THE ADDRESS OF THE FLD USED
	CAIN	T3,CRPFLD		; DID WE PARSE A NUMBER?
	JRST	.P.CR1			; YES
	HRRZ	S,(T2)			; NO, GET THE ARGUMENT
	CONFIRM
	JRST	.P.CR3			; 

.P.CR1:	MOVE	T4,T2			; SAVE ARG OVER CONFIRM
	CONFIRM
	CAIG	T4,7			; 
	CAIGE	T4,1			; BETWEEN 1 AND 7?
	JRST	.P.CR2			; NO, COMPLAIN
	MOVE	S,T4			; SET UP ARGUMENT
	JRST	.P.CR3			; 

.P.CR2:	HRROI	T1,[ASCIZ\?Argument out of range\]
	CALL	.SOUT
	RET

.P.CR3:	TXO	S,PF%SET
	MOVEM	S,PAD.9			; AND SET THE CARRIAGE-RETURN PADDING
	RET

CRPTAB:	CRPTBL,,CRPTBL
	TBL (DISABLED,,0)
CRPTBL==<.-CRPTAB>-1

CRPFLD:	FLDDB. .CMNUM,CM%SDH,^D10,<the desired number of pad characters from 1 to 7>
; HERE TO SET LINEFEED-PADDING

.P.LFP:
	NOISE (to)
	MOVEI	T2,[FLDDB. .CMKEY,,LFPTAB,<>,,LFPFLD]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	T3,T3			; GET THE ADDRESS OF THE FLD USED
	CAIN	T3,LFPFLD		; DID WE PARSE A NUMBER?
	JRST	.P.LP1			; YES
	HRRZ	S,(T2)			; NO, GET THE ARGUMENT
	CONFIRM
	JRST	.P.LP3

.P.LP1:	MOVE	T4,T2			; SAVE THE ARG OVER THE CONFIRM
	CONFIRM
	CAIG	T4,7			; 
	CAIGE	T4,1			; BETWEEN 1 AND 7?
	JRST	.P.LP2			; NO, COMPLAIN
	MOVE	S,T4			; SET UP ARGUMENT
	JRST	.P.LP3

.P.LP2:	HRROI	T1,[ASCIZ\?Argument out of range\]
	CALL	.SOUT
	RET

.P.LP3:	TXO	S,PF%SET
	MOVEM	S,PAD.14		; AND SET THE LINEFEED PADDING PARAMETER
	RET

LFPTAB:	LFPTBL,,LFPTBL
	TBL (DISABLED,,0)
LFPTBL==<.-LFPTAB>-1

LFPFLD:	FLDDB. .CMNUM,CM%SDH,^D10,<the desired number of pad characters from 1 to 7>
; HERE TO SET LINE-WIDTH

.P.WID:
	NOISE	(to)
	MOVEI	T2,[FLDDB. .CMNUM,CM%SDH,^D10,<a number from 0 to 255>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	MOVE	T4,T2			; SAVE ARG OVER CONFIRM
	CONFIRM
	CAIG	T4,^D255		; 
	CAIGE	T4,0			; BETWEEN 0 AND ^D255?
	JRST	.P.WI1			; WHOOPS, COMPLAIN
	MOVEM	T4,PAD.10		; SET LINE-WIDTH PARAMETER
	RET

.P.WI1:	HRROI	T1,[ASCIZ\?Argument is out of range
\]
	CALL	.SOUT
	RET
; HERE TO SET NET-TO-DTE-FLOW-CONTROL

.P.NDF:
	NOISE (to)
	MOVEI	T2,[FLDDB. .CMKEY,,NDFTAB,<>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	S,(T2)			; GET THE VALUE RETURNED
	CONFIRM
	TXO	S,PF%SET
	MOVEM	S,PAD.5			; AND SET THE PAD PARAMETER
	RET

NDFTAB:	NDFTBL,,NDFTBL
	TBL (DISABLED,,0)
	TBL (ENABLED,,1)
NDFTBL==<.-NDFTAB>-1
; HERE TO SET DTE-TO-NETWORK-FLOW-CONTROL

.P.DNF:
	NOISE (to)
	MOVEI	T2,[FLDDB. .CMKEY,,DNFTAB,<>]
	COMND
	ERCAL FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	S,(T2)
	CONFIRM
	TXO	S,PF%SET
	MOVEM	S,PAD.12		; SET THE PAD PARAMETER
	RET

DNFTAB:	DNFTBL,,DNFTBL
	TBL (DISABLED,,0)
	TBL (ENABLED,,1)
DNFTBL==<.-DNFTAB>-1
; HERE TO SET ACTION-ON-BREAK

.P.BRK:
	NOISE (to)
	MOVE	T2,[BRKTAB,,SCRTAB]	; SET UP TABLE
	BLT	T2,SCRTAB+BRKTBL
	MOVEI	T4,BRKLGL		; POINT TO THE LEGAL COMBINATIONS
	CALL	SCRTCH			; GO GET THE ENTRYS
	RET				; ERROR, JUST RETURN
	TXO	S,PF%SET
	MOVEM	S,PAD.7
	RET

BRKTAB:	BRKTBL,,BRKTBL
	TBL (DISCARD-OUTPUT,,P07%DO)
	TBL (ESCAPE,,P07%ES)
	TBL (INDICATE,,P07%ID)
	TBL (INTERRUPT,,P07%IT)
	TBL (NO-ACTION,,0)
	TBL (RESET,,P07%RE)
BRKTBL==<.-BRKTAB>-1

; TABLE OF LEGAL COMBINATIONS

BRKLGL:	BRKLEN
	0
	P07%IT
	P07%RE
	P07%ES
	P07%IT!P07%ID!P07%DO
BRKLEN==<.-BRKLGL>-1
; HERE TO SET THE PAD-SIGNAL-CONTROL

.P.NMD:
	NOISE (to)
	MOVEI	T2,[FLDDB. .CMKEY,,NMDTAB,<>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	S,(T2)			; SAVE ARGUMENT OVER CONFIRM
	CONFIRM
	TXO	S,PF%SET
	MOVEM	S,PAD.6			; SET THE PAD PARAMETER
	RET

NMDTAB:	NMDTBL,,NMDTBL
	TBL (ENABLED,,1)
	TBL (SUPPRESSED,,0)
NMDTBL=<.-NMDTAB>-1
; HERE TO SET THE DISCARD-OUTPUT PARAMETER

.P.DIS:
	NOISE (to)
	MOVEI	T2,[FLDDB. .CMKEY,,DISTAB,<>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	S,(T2)			; SAVE THE ARGUMENT ACROSS THE CONFIRM
	CONFIRM
	TXO	S,PF%SET
	MOVEM	S,PAD.8			; SET THE PAD PARAMETER
	RET

DISTAB:	DISTBL,,DISTBL
	TBL (DISABLED,,0)
	TBL (ENABLED,,1)
DISTBL==<.-DISTAB>-1
; HERE TO SET THE RATE PARAMETER

.P.RAT:
	NOISE (to)
	MOVEI	T2,[FLDDB. .CMKEY,,RATTAB,<>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	S,(T2)			; SAVE ARGUMENT OVER CONFIRM
	CONFIRM
	TXO	S,PF%SET
	MOVEM	S,PAD.11
	RET


RATTAB:	RATTBL,,RATTBL
;	TBL (100,,^D9)
	TBL (110,,0)
	TBL (1200,,3)
;	TBL (134.5,,1)
	TBL (150,,6)
	TBL (1800,,7)
;	TBL (19200,,^D15)
	TBL (200,,^D8)
	TBL (2400,,^D12)
	TBL (300,,2)
	TBL (4800,,^D13)
;	TBL (48000,,^D16)
	TBL (50,,^D10)
;	TBL (56000,,^D17)
	TBL (600,,4)
;	TBL (64000,,^D18)
	TBL (75,,5)
;	TBL (75/1200,,^D11)
	TBL (9600,,^D14)
RATTBL==<.-RATTAB>-1
; HERE TO SET THE LINEFEED-INSERTION PARAMETER

.P.LFI:
	NOISE (to be done after carriage returns)
	MOVE	T2,[LFITAB,,SCRTAB]	; SET UP TABLE
	BLT	T2,SCRTAB+LFITBL
	MOVEI	T4,LFILGL		; POINT TO THE LEGAL COMBINATIONS
	CALL	SCRTCH			; GO GET THE ENTRYS
	RET				; ERROR, JUST RETURN
	TXO	S,PF%SET
	MOVEM	S,PAD.13		; AND SET THE PAD PARAMETER
	RET


LFITAB:	LFITBL,,LFITBL
	TBL (ECHOED,,P13%EC)
	TBL (NEVER,,^D0)
	TBL (RECEIVED,,P13%TD)
	TBL (SENT,,P13%FD)
LFITBL==<.-LFITAB>-1


; TABLE OF LEGAL COMBINATIONS

LFILGL:	LFILEN
	0
	P13%TD
	P13%EC
	P13%TD!P13%EC
	P13%FD!P13%EC
	P13%TD!P13%FD!P13%EC
LFILEN==<.-LFILGL>-1
; HERE TO SET THE LOCAL-EDITING PARAMETER

.P.LOC:
	NOISE (to)
	MOVEI	T2,[FLDDB. .CMKEY,,LOCTAB,<>]
	COMND
	ERCAL	FATAL
	TXNE	T1,CM%NOP
	JRST	ERROR
	HRRZ	S,(T2)			; SAVE ARGUMENT OVER CONFIRM
	CONFIRM
	TXO	S,PF%SET
	MOVEM	S,PAD.15		; AND SET THE PAD PARAMETER
	RET

LOCTAB:	LOCTBL,,LOCTBL
	TBL (DISABLED,,0)
	TBL (ENABLED,,1)
LOCTBL==<.-LOCTAB>-1
; HERE TO SET THE DELETE-CHARACTER

.P.DEL:	MOVEI	T2,PAD.16		; WHERE TO PUT CHARACTER
	MOVEM	T2,CH.ADR
	CALLRE	.CHAR			; GO GET CHARACTER
; HERE TO SET THE CANCEL-CHARACTER

.P.CAN:	MOVEI	T2,PAD.17		; WHERE TO PUT CHARACTER
	MOVEM	T2,CH.ADR
	CALLRE	.CHAR			; GO GET CHARACTER
; HERE TO SET THE DISPLAY-CHARACTER

.P.DPY:	MOVEI	T2,PAD.18		; WHERE TO PUT CHARACTER
	MOVEM	T2,CH.ADR
	CALLRE	.CHAR			; GO GET CHARACTER
; HERE TO SET THE STATUS-DISPLAY-CHARACTER

.STATU:	MOVEI	T2,STSCHR		; WHERE TO PUT CHARACTER
	MOVEM	T2,CH.ADR
	CALLRE	.CHAR			; GO GET CHARACTER
	SUBTTL	TAKE COMMAND

.TAKE:
	NOISE (commands from)
	MOVE	T2,[TJBLK1,,GTJBLK]	; BLT POINTER
	BLT	T2,GTJBLK+.GJJFN	; PUT IT IN GET JFN BLOCK
	MOVE	T2,CMDBLK+4		; GET CURRENT BYTE POINTER
	MOVEM	T2,.TPNT		; SAVE IT
	MOVEI	T2,.TFD0		; GET CMMAND FILE
	COMND
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	HRRZ	T3,T3			; GET FDB USED
	CAIE	T3,.TFD01		; INPUT A FILE?
	JRST	.TAKET			; NO, MUST HAVE BEEN A CONFIRM
	MOVEM	T2,.TIJFN		; YES, SAVE JFN
	MOVE	T2,.DECHO		; GET DEFAULT ECHO
	MOVEM	T2,.TECHO		; SET DEFAULT TEMP ECHO
	MOVE	T2,.DERRE		; GET DEFAULT ERROR ENABLE
	MOVEM	T2,.TERRE		; SET DEFAULT TEMP ALLOW ERROR
	MOVEI	T2,.PRIOU		; GET .PRIOU
	MOVEM	T2,.TOJFN		; USE .PRIOU FOR DEFAULT OUTPUT
	NOISE	(logging output on)
	MOVE	T2,[440700,,.TDEFS]	;GET POINTER TO DEFAULT STRING
.T05$:	ILDB	T3,.TPNT		; GET FILE
	IDPB	T3,T2			; SAVE BYTE
	CAIE	T3,56			; A "."?
	JUMPN	T3,.T05$		; NO, TRY NEXT IF NOT A NULL
	SETZ	T3,			; CLEAR T3
	DPB	T3,T2			; SAVE NULL BYTE
	MOVE	T2,[TJBLK2,,GTJBLK]	; BLT POINTER
	BLT	T2,GTJBLK+.GJJFN	; PUT IT IN GET JFN BLOCK
	MOVEI	T2,.TFD1		; POINT TO FDBs
	COMND
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	HRRZ	T3,T3			; GET FDB USED
	CAIN	T3,.TFD2		; DID WE TYPE A COMMA
	JRST	.T10$			; YES, INPUT SUBCOMMANDS
	CAIE	T3,.TFD3		; NO, DID WE SPECIFY A OUTPUT JFN
	JRST	.TIDON			; NO, MUST HAVE BEEN A CONFIRM
	MOVEM	T2,.TOJFN		; SAVE OUTPUT JFN
	MOVEI	T2,.TFD31		; POINT TO FDBs
	COMND
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	HRRZ	T3,T3			; GET FDB USED
	CAIE	T3,.TFD32		; WAS IT A ","
	JRST	.TIDON			; NO, MUST BE A CONFIRM

;HERE FOR ANY TAKE WITH A "," AS LAST CHARACTER

.T10$:	CONFIRM
	PUSH	P,CMDBLK		; SAVE REPARSE ADDRESS
	PUSH	P,CMDBLK+2		; SAVE CTRL/R BUFFER
	HRROI	T2,[ASCIZ\X29PAD-TAKE>\]	
	MOVEM	T2,CMDBLK+2		; UPDATE COMAND BLOCK
	MOVEI	T2,.T60$		; NEW REPARSE BUFFER
	MOVEM	T2,CMDBLK		; UPDATE COMAND BLOCK
	SKIPE	.TAKEF			; ARE WE DOING A TAKE
	JRST	.T20$			; YES
	CALL	.T50$			; GET TAKE SUBCOMMAND
	JRST	.-1			; LOOP

;THIS ROUTINE IS FOR PARSING TAKE SUBCOMANDS WHEN WE ARE ALREADY DOING
;A TAKE  ie TAKE TAKE

.T20$:	SKIPN	ERRENA			; ARE ERRORS ENABLED
	SKIPN	ERRCNT			; CHECK ERROR COUNT
	SKIPA				; NO ERRORS, OR ERRORS ARE ALOWED
	JUMPA	.T40$			; HE HAD ERROR LETS RESTORE AND RETURN
	MOVE T1,INJFN			; POINT TO INPUT JFN
	SIBE				; IS THE INPUT BUFFER EMPTY
	SKIP				; IGNORE SKIP NO SKIP
	JUMPE	T2,.T30$		; NO MORE BYTES,FUDGE CRLF AND CONTINUE
	CALL	.T50$			; GO GET LINE
	JRST	.T20$			; LOOP

;HERE TO FUDGE A CRLF FOR A TAKE SUBCOMAND OF A TAKE FILE THAT
;RAN OUT OF DATA

.T30$:	MOVE	T2,CRLF			; GIVE HIM A CARAGE RETURN
	MOVEM	T2,CMDBUF		; PUT CONFIRM IN COMAND BUF
	JRST	.T70$			; CONTINUE ON

;HERE FOR A TAKE FILE THAT HAD A ERROR DOING A TAKE SUBCOMAND WITHOUT ALLOW
;ERRORS ENABLED

.T40$:	POP	P,CMDBLK+2		; RESTORE CTRL/R BUFFER
	POP	P,CMDBLK		; RESTORE REPARSE ADDRESS
	RET				; RETURN TO ORIGINAL TAKE ON ERROR

;THIS ROUTINE PARSES A SUBCOMAND FOR THE TAKE

.T50$:	MOVEI	T1,CMDBLK		; POINT TO CMDBLK
	MOVEI	T2,[FLDDB. .CMINI]	; INITIALIZE STATE BLOCK
	COMND				; CTRL/H, DO OUTPUT PROMPT
	ERCAL	FATAL			; THIS SHOULD NEVER HAPPEN
	MOVEM	P,SAVPDL		; SAVE STACK POINTER FOR REPARSE
.T60$:	MOVE	P,SAVPDL		; RESTORE STACK POINTER FOR REPARSE
	MOVEI	T2,[FLDDB. .CMCFM,,,,,.TFDS2]	; CONFIRM OR GET SUB COMMAND
	COMND
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	HRRZ	T3,T3			; GET FDB USED
	HRRZ	T2,T2			; CLEAR LEFT OF T2
	HRRZ	T2,(T2)			; IF SUBCOMMAND GET DISPATCH
	CAIN	T3,.TFDS2		; WAS IT A SUBCOMMAND
	JRST	(T2)			; YES, GO DO IT
	POP	P,T2			; WERE NOT RETURNING, POP CALL ADR
.T70$:	SKIPE	LOGJFN
	CALL	LOG
	SKIPE	.TAKEF			; ARE WE IN A TAKE
	CALL	.TECC			; YES, GO ECHO IF NECESSARY
	POP	P,CMDBLK+2		; RESTORE CTRL/R BUEFF
	POP	P,CMDBLK		; RESTORE REPARSE ADDRESS
	JRST	.T80$			; ALL DONE, GO DO IT

;FINISHED PARSING COMANDS SET UP TO DO IT


.TIDON:	SKIPE	LOGJFN
	CALL	LOG
	SKIPE	.TAKEF			; ARE WE ALREADY DOING A TAKE
	CALL	.TECC			; YES, GO ECHO IF NECESSARY
.T80$:	PUSH	P,.TPSAV		; SAVE .TPSAV
	PUSH	P,CMDBLK+1		; SAVE OLD CMDBLK I/O
	PUSH	P,ECHOEN		; SAVE ECHO ENA
	PUSH	P,ERRENA		; SAVE ERROR ENA
	PUSH	P,INJFN			; SAVE OLD INPUT JFN
	PUSH	P,OUTJFN		; SAVE OLD OUTPUT JFN
	SETZM	ERRCNT			; CLEAR ERROR COUNT
	AOS	.TAKEF			; INCREMENT .TAKEF
	MOVE	.TECHO			; GET ECHO FLAG
	MOVEM	ECHOEN			; SAVE NEW ECHO ENA
	MOVE	.TERRE			; GET ERROR ENA FLAG
	MOVEM	ERRENA			; SAVE IT
	MOVEI	T2,.NULIO		; SET NO ECHO
	HRL	T2,.TIJFN		; GET INPUT JFN
	MOVEM	T2,CMDBLK+1		; UPDATE CMDBLK I/O
	MOVEM	P,.TPSAV		; SAVE P
	MOVE	T1,.TOJFN		; GET OUTPUT JFN
	MOVEM	T1,OUTJFN		; SAVE NEW OUTPUT JFN
	MOVE	T1,.TIJFN		; GET INPUT JFN
	MOVEM	T1,INJFN		; SAVE NEW INPUT JFN
	MOVE	T2,[FLD(7,OF%BSZ)!OF%RD]	; ASCII MODE,READ ACCESS
	OPENF				; OPEN FILE
	JRST	.TOERR			; FAILURE, RELESE JFNs AND REPORT
	SETZ	T2,			; CLEAR T2
	SFPTR				; POINT TO BEGINIG OF FILE
					; NOT NECESSARY, BUT IF IT DOESN'T
					; WORK, ie  TTY: , LETS FIND OUT NOW
	JRST	.TFIN			; MUST BE TTY: OR SOMTHING LIKE IT
	MOVE	T1,.TOJFN		; GET OUTPUT JFN
	CAIN	T1,.PRIOU		; ARE WE USING .PRIOU
	JRST	.TLOOP			; YES, GO ON
	MOVE	T2,[FLD(7,OF%BSZ)!OF%WR]	; NO, OPEN OUTPUT ASCII/WRITE
	OPENF
	JRST	.TOERR			; ERROR, RESTORE WORLD AND REPORT

;HERE WE LOOP THROUGH THE TAKE FILE

.TLOOP:	CALL	GETCMD			; GET A COMMAND AND RUN IT
	SKIPN	ERRENA			; IF ERROR ENA DON'T TEST FOR ERROR
	SKIPN	ERRCNT			; IF ERROR SKIP
	JRST	.TLOOP1			; GO GET NEXT LIN
	HRROI	T2,[ASCIZ\%Error while reading file \]
	SETZ	T3,			; CLEAR T3 FOR SOUT
	SKIPE	T1,LOGJFN		; ARE WE LOGGING
	CALL	LSOUT
	MOVE	T1,(P)			; GET OLD OUTPUT JFN
	SOUT				; PRINT ERROR MESSAGE
	MOVE	T2,INJFN		; INPUT THAT FAILED
	MOVE	T3,[222220,,1]		; SWITCHES
	CALL	.JFNS			; PRINT FILE NAME
	HRROI	T2,[ASCIZ\, file aborted.
\]					; PRINT ABORT
	SETZ	T3,			; CLEAR T3 FOR SOUT
	SKIPE	T1,LOGJFN		; ARE WE LOGGING
	CALL	LSOUT
	MOVE	T1,(P)			; GET OLD OUTPUT JFN
	SOUT				; PRINT CRLF
	JRST	.TRES			; RESTORE THE WORLD

;FILES DONE, LETS FINISH

.TAKET:	SKIPN	.TAKEF			; ARE WE DOING A TAKE ALREADY
	RET				; NO, JUST RETURN
	POP	P,T2			; YES, CLEAR RETURN ADRESS
	SKIPE	LOGJFN
	CALL	LOG
	CALL	.TECC			; GO ECHO IF NECESSARY
	JRST	.TFIN1			; DON'T PRINT THE EOF MESSAGE
.TFIN:	MOVE	P,.TPSAV		; RESTORE P INCASE IT WAS EOF TERM
	HRROI	T2,[ASCIZ\End of \]
	SETZ	T3,			; CLEAR T3 FOR SOUT
	SKIPE	T1,LOGJFN		;ARE WE LOGGING?
	CALL	LSOUT			;YES, GO PRINT IT
	MOVE	T1,(P)			; GET OLD OUTPUT JFN
	SOUT				; PRINT END OF TAKE MESSAGE
	MOVE	T2,INJFN		; INPUT JFN
	MOVE	T3,[222220,,1]		; SWITCHES
	MOVE	T1,(P)			; GET OLD OUTPUT JFN
	CALL	.JFNS			; PRINT FILE NAME
	HRROI	T2,CRLF
	SETZ	T3,			; CLEAR T3 FOR SOUT
	SKIPE	T1,LOGJFN		;ARE WE LOGGING?
	CALL	LSOUT			;YES, GO PRINT IT
	MOVE	T1,(P)			; GET OLD OUTPUT JFN
	SOUT				; PRINT CRLF
.TFIN1:	SKIPE	ERRENA			; ERRORS ENABLED
	SETZM	ERRCNT			; YES, CLEAR ANY ERRORS
	JRST	.TRES			; RESTORE THE WORLD


;TAKE SUBCOMAND FOR LOG-FILE

.TOUT:	MOVEI	T2,.TFD3		; POINT TO LOG FILE
	COMND
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	SKIP
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST ERROR			; YES
	MOVE	T4,T2			; SAVE JFN
;	MOVE	T2,GENRIC		; CONFIRM
;	COMND
;	ERCAL	FATAL
;	TXNE	T1,CM%NOP		; PARSE FAIL?
;	JRST	ERROR			; YES, REPORT ERROR AND RETURN
	CONFIRM
	MOVEM	T4,.TOJFN		; SAVE NEW JFN
	RET

;TAKE SUBCOMMAND FOR "ALLOW"

.TALOW:	NOISE (errors during "TAKE" file)
	CONFIRM
	SETOM	.TERRE			; SET ERROR EN FLAG
	RET

;TAKE SUBCOMMAND FOR "DISALLOW"

.TDISA:	NOISE (errors during "TAKE" file)
	CONFIRM
	SETZM	.TERRE			; CLEAR ERROR ENA FLAG
	RET

;TAKE SUBCOMMAND FOR "NO "

.TNO:	MOVEI	T2,[FLDDB. .CMKEY,,.TNODA]	; POINT TO "NO ECHO"
	COMND
	ERCAL	FATAL			; THIS SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST ERROR			; YES
	NOISE	(commands from "TAKE" file)
	CONFIRM
	SETZM	.TECHO			; CLEAR ECHO FLAG
	RET

;TAKE SUBCOMMAND FOR "ECHO"

.TECO:	NOISE	(commands from "TAKE" file)
	CONFIRM
	SETOM	.TECHO			; SET ECHO FLAG
	RET

;THIS ROUTINE OUTPUTS THE PARSE BUFFER TO THE LOG FILE IF NECESSARY

.TECC:	SKIPN	ECHOEN			; IS ECHO ENABLED
	RET				; NO,RETURN
	PUSH	P,T1			; SAVE T1
	PUSH	P,T2			; SAVE T2
	PUSH	P,T3			; SAVE T3
	MOVE	T1,OUTJFN		; GET OUTPUT JFN
	MOVE	T2,CMDBLK+2		; GET PROMT POINTER
	SETZ	T3,
	SOUT
	MOVE	T2,CMDBLK+3		; GET INPUT STRING
	SOUT
	POP	P,T3			; RESTORE T3
	POP	P,T2			; RESTORE T2
	POP	P,T1			; RESTORE T1
	RET


;COULDN'T OPEN TAKE FILE OR OUTPUT JFN, REPORT AND ABORT

.TOERR:	POP	P,OUTJFN		; GET OUTPUT JFN BACK
	CALL	ERROR			; REPORT ERROR
	PUSH	P,OUTJFN		; PUT BACK ON STACK
	JRST	.TRES1			; RESTORE

;HERE TO RESTORE WORLD AND RETURN

.TRES:	MOVE	T1,OUTJFN		; GET OUTPUT JFN
	CAIE	T1,.PRIOU		; IS IT THE .PRIOU
	CLOSF				; NO, CLOSE AND RELEASE JFN
	SKIP				; IGNORE ERROR RETURN
.TRES1:	MOVE	T1,INJFN		; GET INPUT JFN
	CLOSF				; CLOSE THE JFN
	SKIP				; IGNORE ERROR RETURN
	POP	P,OUTJFN		; RESTORE OUTPUT JFN
	POP	P,INJFN			; RESTORE INPUT JFN
	POP	P,ERRENA		; RESTORE .ERREN
	POP	P,ECHOEN		; RESTORE ECHO ENABLE
	POP	P,CMDBLK+1		; RESTORE COMMAND BLOCK
	POP	P,.TPSAV		; RESTORE .TPSAV
	SOS	.TAKEF			; DECREMENT TAKE FLAG
	RET				; RETURN


TJBLK1:	GJ%OLD
	0
	0
	0
	0
	440700,,[ASCIZ\CMD\]
	0
	0
	0

TJBLK2:	GJ%FOU!GJ%MSG!GJ%ACC
	0
	0
	0
	440700,,.TDEFS
	440700,,[ASCIZ\LOG\]
	0
	0
	0

.TDEFS:	BLOCK	10

.TFD0:	FLDDB. .CMCFM,CM%SDH,,<Carrage return to end current command level>,,.TFD01
.TFD01:	FLDDB. .CMFIL,CM%SDH,,<Command file name>

					; JUST CONFIRM OR
.TFD1:	FLDDB. .CMCFM,CM%SDH,,<Carriage return if no change of output desired>,,.TFD2
					; TRY TO GET A COMMA OR
.TFD2:	FLDDB. .CMCMA,CM%SDH,,<Comma for no change, but to enter subcommands>,,.TFD3
					; TRY TO GET A OUPUT FILE
.TFD3:	FLDDB. .CMFIL,CM%SDH,,<Output file name>


					; COMFIRM OR
.TFD31:	FLDDB. .CMCFM,,,<Comma to enter subcommands, or>,,.TFD32
.TFD32:	FLDDB. .CMCMA,CM%SDH		; GET A COMMA


.TFDS2:	FLDDB. .CMKEY,,.TDATA,<Take subcommand,>	; TAKE SUBCOMMAND FDB

.CMFRD:	FLDDB. .CMCFM,CM%SDH,

; TAKE SUBCOMMAND TABLE

.TDATA:	.TDATL,,.TDATL			; ACTUAL,,MAXIMUM NUMBER OF ENTRYS
	TBL (ALLOW,,.TALOW)
	TBL (DISALLOW,,.TDISA)
	TBL (ECHO,,.TECO)
	TBL (LOG-FILE,,.TOUT)
	TBL (NO,,.TNO)
.TDATL==<.-.TDATA>-1			; NUMBER OF ENTRYS IN THE TABLE


; TAKE SUBCOMMAND TABLE FOR "NO"

.TNODA:	.TNODL,,.TNODL		; ACTUAL,,MAXIMUM NUMBER OF ENTRYS
	TBL (ECHO,,.TNO)
.TNODL==<.-.TNODA>-1			; NUMBER OF ENTRYS IN THE TABLE
; ROUTINE TO TAKE INTITAL COMMAND FILES

TAKER:	PUSH	P,OUTJFN		; SAVE OUTPUT JFN
	MOVEI	T1,.NULIO		; GET NUL OUTPUT JFN
	MOVEM	T1,OUTJFN		; PRINT ALL OUTPUT TO NUL
	MOVEM	T1,.TOJFN		; DITO
	SETZM	.TECHO			; DON'T ECHO
	SETZM	.TERRE			; DON'T ALLOW ERRORS
	MOVE	T1,[GJ%OLD!GJ%SHT]	; SHORT FORM FOR OLD FILE
	HRROI	T2,[ASCIZ\SYSTEM:X29PAD-DEFAULTS.INIT
\]					; POINT TO STRING
	GTJFN				; GET JFN
	JRST	TAKERU			; NO FILE, GET USERS INIT
	HRRZM	T1,.TIJFN		; SAVE INPUT JFN
	CALL	.T80$			; GO TAKE STUF
	SKIPN	ERRCNT			; ANY ERRORS
	JRST	TAKERU			; NO, GET USERS INIT
	CALL	ERROR			; REPORT LAST ERROR
	HRROI	T1,[ASCIZ\%ERROR DURING X29PAD-DEFAULTS.INIT
\]
	PSOUT
TAKERU:	SETZM	ERRCNT			; CLEAR ERROR COUNT
	SETO	T1,			; POINT TO CURRENT JOB
	HRROI	T2,CMDBUF		; GET 1 WORD INTO CMDBUF
	MOVEI	T3,.JILNO		; GET LOGIN DIRECTORY #
	GETJI
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	HRROI	T1,CMDBUF		; PUT STRING IN CMDBUF
	MOVE	T2,CMDBUF		; GET LOGIN DIR #
	DIRST				; GET STRING
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	MOVE	T2,[440700,,[ASCIZ\X29PAD.INIT
\]]					; TAKE PS:<DIRECTORY>X29PAD.INIT
TAKERL:	ILDB	T3,T2			; GET BYTE
	IDPB	T3,T1			; SAVE NEW BYTE
	JUMPN	T3,TAKERL		; LOOP THRU ALL BYTES
	MOVE	T1,[GJ%OLD!GJ%SHT]	; SHORT FORM FOR OLD FILE
	HRROI	T2,CMDBUF		; POINT TO STRING
	GTJFN				; GET JFN
	JRST	TAKERD			; DONE
	HRRZM	T1,.TIJFN		; SAVE INPUT JFN
	CALL	.T80$			; GO TAKE STUF
TAKERD:	POP	P,OUTJFN		; RESTORE OUTPUT JFN
	SKIPN	ERRCNT			; ANY ERRORS
	RET				; NO, RETURN
	CALL	ERROR			; REPORT LAST ERROR
	HRROI	T1,[ASCIZ\%ERROR DURING X29PAD.INIT\]
	PSOUT
	RET
	SUBTTL	ERROR HANDLERS AND OTHER ASSORTED STUFF

;ROUTINE TO PARSE A SINGLE CHARACTER AND SAVE IT @CH.ADR

.CHAR:	NOISE (to)
	MOVEI T2,CHFDB1			; POINT TO FDB's
	COMND
	ERCAL	FATAL			; THIS SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	HRRZ	T3,T3			; GET FDB USED
	CAIE	T3,CHFDB1		; OCTAL NUMBER?
	JRST	.CHAR2			; NO, GO ON
	JUMPGE	T2,.CHAR1		; IS IT A NEGATIVE NUMBER
	MOVEI	T1,.FHSLF		; YES, SET ERROR TO SMALL
	MOVEI	T2,FLINX2
	SETER
	CALLRE	ERROR			; GO GIVE ERROR AND ABORT
.CHAR1:	MOVEM	T2,CH.CHR		; SAVE THE NUMBER
	CAIG	T2,177			; IS IT LARGER THAN 127.
	JRST	.CHARC			; NO, GO CONFIRN
	MOVEI	T1,.FHSLF		; SET NUMBER TO LARGE ERROR
	MOVEI	T2,FLINX3
	SETER
	CALLRE	ERROR
.CHAR2:	SETZM	CH.CHR			; CLEAR CHARACTER BUFFER
	CAIE	T3,CHFDB2		; WAS IT A "CONTROL"
	JRST	.CHAR3			; NO, MUST HAVE BEEN DOUBLE QUOTES
	MOVEI	T2,140			; MAKE THE BUFFER MASK FOR CONTROL
	MOVEM	T2,CH.CHR
	MOVEI	T2,CHFDB3		; GET THE CHARACTER
	COMND
	ERCAL	FATAL			; THIS SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
.CHAR3:	MOVE	T2,CMDBLK+.CMABP	; GET BYTE POINTER TO ATOM BUFFER
	ILDB	T3,T2			; GET THE FIRST BYTE
	JUMPN	T3,.CHAR4		; ANYTHING?
	MOVEI	T1,.FHSLF		; ARG BLOCK TO SMALL
	MOVEI	T2,ARGX04
	SETER
	CALLRE	ERROR
.CHAR4:	TDZ	T3,CH.CHR		; IF CONTROL, MAKE IT SO
	MOVEM	T3,CH.CHR		; SAVE CHARACTER
	ILDB	T3,T2			; GET NEXT CHARACTER
	JUMPE	T3,.CHARC		; SHOULD BE ONLY ONE CHARACTER
	MOVEI	T1,.FHSLF		; ARG BLOCK TOO LONG
	MOVEI	T2,ARGX05
	SETER
	CALLRE	ERROR
.CHARC:	CONFIRM
	MOVE	T2,CH.CHR		; GET CHARACTER
	MOVEM	T2,@CH.ADR		; PUT IT WHERE IT BELONGS
	RET

CH.ADR:	0				; ADDRESS TO STORE CHARACTER AT
CH.CHR:	0				; TEMP STORAGE OF CHARACTER

CHRTAB:	CHRTBL,,CHRTBL			; ACTUAL,,MAXIMUM NUMBER OF ENTRIES
	TBL (CONTROL,,.CHAR)
CHRTBL==<.-CHRTAB>-1			; NUMBER OF ENTRIES IN THE TABLE

CHFDB1:	FLDDB. .CMNUM,CM%SDH,10,<octal ASCII code for character>,,CHFDB2
CHFDB2:	FLDDB. .CMKEY,,CHRTAB,,,CHFDB3
CHFDB3:	FLDDB. .CMQST,CM%SDH,,<any printing character in double quotes>
; THIS ROUTINE IS CALLED WITH LASTNE LOADED WITH THE ERROR CODE RETURNED
; BY THE GATEWAY ACCESS PACKAGE
; IF NETERR IS CALLED, A SHORT ERROR MESSAGE IS DISPLAYED
; IF NETINF IS CALLED, A LONG MESSAGE IS DISPLAYED

NETINF:	SETOM	ERRFLG			; SET THE INFO FLAG
NETERR:	PUSH	P,T1
	PUSH	P,P1
	PUSH	P,P2
	PUSH	P,P3
	PUSH	P,P4
	HRRZI	P2,1B18			; 
	SETZ	P3,			; ZERO COUNTER
	HRRZ	P1,LASTNE		; GET THE NETWORK ERROR CODES
NETER1:	TDNN	P1,P2			; IS THIS PARTICULAR BIT LIT?
	JRST	NETER2			; NO, TRY AGAIN
	MOVE	P4,P3			; YES, GET COUNTER
	IMULI	P4,2			; CONVERT TO AN INDEX
	SKIPE	ERRFLG			; LONG OR SHORT ERROR MESSAGE?
	AOS	P4			; LONG!
	MOVE	T1,NETETB(P4)		; GET STRING POINTER FROM TABLE
	CALL	.SOUT
	CALL	OCRLF
NETER2:	AOS	P3			; INCREMENT COUNTER
	LSH	P2,-1			; SHIFT TEST BIT RIGHT ONE PLACE
	CAIGE	P3,^D18			; HAVE WE DONE THIS ENOUGH TIMES?
	JRST	NETER1			; NO, ONE MORE TIME
	SETZM	ERRFLG			; CLEAR THE INFO FLAG
	POP	P,P4
	POP	P,P3
	POP	P,P2
	POP	P,P1
	POP	P,T1
	RET

SCRTCH:
	SETZ	S,			; INITIALIZE THE DATA
SCRTC1:	MOVEI	T2,[FLDDB. .CMKEY,,SCRTAB,,,CMCFM]
	SKIPA				; DON'T ALLOW CONFIRM
SCRTC2:	MOVEI	T2,[FLDDB. .CMKEY,,SCRTAB,,,GENRIC]
	HLRZ	T3,SCRTAB		; GET THE NUMBER OF TABLE ENTRYS
	SKIPN	T3			; ANY THING LEFT
SCRTC3:	MOVEI	T2,GENRIC		; NO, JUST CONFIRM
	COMND
	ERCAL	FATAL			; THIS SHOULD NEVER HAPPEN
	TXNE	T1,CM%NOP		; DID THE PARSE FAIL
	JRST	ERROR			; YES, REPORT THE ERROR AND RETURN
	HRRZ	T3,T3			; GET FDB USED
	CAIN	T3,GENRIC		; DID HE JUST TYPE A CRLF
	JRST	SCRTC7			; YES, DONE
	CAIN	T3,CMCFM		; DID HE TYPE A ILLEGAL cr
	JRST	SCRTC8			; YES, ILLEGAL COMBINATION
	HRRZ	T2,T2			; CLEAR LEFT HALF OF T2
	OR	S,(T2)			; SET BITS
	HRRZ	S,S			; CLEAR LEFT HALF OF DATA
	PUSH	P,T1			; SAVE T1
	MOVEI	T1,SCRTAB		; POINT TO THE TABLE
	TBDEL				; DELETE THIS ENTRY
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	MOVE	T2,(T4)			; GET THE COUNT OF LEGAL COMBINATIONS
	ADD	T2,T4			; MAKE T2 POINT TO ENTRYS IN TABLE
	SETZB	T3,SCRLGF		; CLEAR T3 AND THE LEGAL FLAG
SCRTC4:	HRRZ	T1,(T2)			; GET THIS COMBINATION
	CAMN	S,T1			; IS THIS AN EXACT MATCH
	SETOM	SCRLGF			; SET THE EXACT LEGAL FLAG
	AND	T1,S			; AND THEM
	CAMN	S,T1			; ALL BITS SET IN LEGAL COMBINATION
	OR	T3,(T2)			; INCLUDE THIS AS LEGAL
	SOS	T2			; DECREMENT ADDRESS
	CAME	T2,T4			; ALL DONE?
	JRST	SCRTC4			; NO, GO CHECK NEXT
	PUSH	P,S			; SAVE S
	MOVEI	T1,SCRTAB		; POINT TO SCRTAB
	HLRZ	T2,(T1)			; GET THE NUMBER OF ENTRYS
	ADD	T2,T1			; MAKE T2 POINT TO ENTRYS
SCRTC5:	CAMN	T2,T1			; CHECKED ALL ENTRYS?
	JRST	SCRTC6			; ALL DONE
	HRRZ	S,(T2)			; GET THIS ENTRY
	AND	S,T3			; CHECK IF ITS ALLOWED
	SKIPE	S			; IS IT ALLOWED?
	SOJA	T2,SCRTC5		; YES, TRY NEXT
	TBDEL				; DELETE THIS ENTRY
	ERCAL	FATAL			; SHOULD NEVER HAPPEN
	SOJA	T2,SCRTC5		; AND TRY NEXT ENTRY
SCRTC6:	POP	P,S			; RESTORE S
	POP	P,T1			; RESTORE T1
	JUMPE	S,SCRTC3		; IF NONE, JUST CONFIRM
	SKIPE	SCRLGF			; IS THIS A EXACT LEGAL COMBINATION?
	JRST	SCRTC2			; YES, ALLOW A CONFIRM
	JRST	SCRTC1			; NO, DON'T ALLOW A CONFIRM

SCRTC7:	SKIPE	LOGJFN			; ARE WE LOGGING?
	CALL	LOG			; YES, GO LOG
	SKIPE	.TAKEF			; ARE WE DOING A TAKE?
	CALL	.TECC			; YES, GO ECHO IF NECESSARY
	AOS	(P)			; SKIP RETURN
	RET

SCRTC8:	HRROI	T1,[ASCIZ\?Illegal combination\]
	CALL	.SOUTR
	MOVE	S,CMDBLK		; GET THE FLAGS FOR THE CMDBLK
	TXO	S,CM%NOP		; SET THE NO-OP FLAG
	TXZ	S,CM%EOC		; CLEAR THE CONFIRM FLAG
	MOVEM	S,CMDBLK		; SAVE IT
	HRROI	T1,-2			; GET RID OF CRLF
	ADJBP	T1,CMDBLK+4		; POINT BEHIND CRLF
	MOVEM	T1,CMDBLK+4		; NEW POINTER
	RET				; ^H WILL NOW WORK

SCRLGF:	0				; FLAG SAYING AN EXACT LEGAL MATCH

CMCFM:	FLDDB. .CMCFM,CM%SDH

SCRTAB:
DF.BRK==DFWTBL-BRKTBL
DF.LFI==DFWTBL-LFITBL
BRK.LF==BRKTBL-LFITBL
IFGE DF.BRK,<IFGE DF.LFI,<BLOCK DFWTBL+1>>
IFL DF.BRK,<IFGE BRK.LF,<BLOCK BRKTBL+1>>
IFL DF.LFI,<IFL BRK.LF,<BLOCK LFITBL+1>>
; FATAL ERROR ROUTINE

FATAL:
	SKIPN	.TAKEF			; YES, ARE WE DOING A TAKE
	JRST	FATAL1			; NO, ITS REALY FATAL
	MOVEI	T1,.FHSLF		; SEE WHAT ERROR IT WAS
	GETER
	HRRZ	T2,T2			; GET RIGHT HALF
	CAIE	T2,IOX4			; WAS IT EOF
	CAIN	T2,COMNX9		; EMPTY FILE?
	SKIPA
	JRST	FATAL1			; NO, REALLY A FATAL ERROR
	MOVEI	T1,CMRPRS		; FLAGS AND ADDRESS OF REPARSE ROUTINE
	MOVEM	T1,CMDBLK		; RESTORE COMAND BLOCK REPARSE
	HRROI	T1,[ASCIZ\X29PAD>\]	; CTRL/R BUFFER
	MOVEM	T1,CMDBLK+2		; UPDATE CTRL/R BUFFER
	JRST	.TFIN			; GO FINISH TAKE

FATAL1:
	SETZM	.TAKEF			; CLEAR ALL TAKES
	CALL	ERROR			; FIRST OUTPUT THE REASON THE JSYS DIED
	MOVEI	T1,.PRIOU		; RESTORE OUTPUT JFN
	MOVEM	T1,OUTJFN
	HRROI	T1,[ASCIZ\, JSYS at PC=\]
	CALL	.SOUT
	POP	P,T2			; GET THE PC BACK FROM THE STACK
	SUBI	T2,2			; BACKUP OVER THE ERCAL TO THE JSYS
	MOVX	T3,NO%MAG!10		; OUTPUT FREE FORMAT UNSIGNED OCTAL
	CALL	.NOUT
	ERJMP .+1			; THIS CAN'T HAPPEN
	HRROI	T1,CRLF
	CALL	.SOUT
	MOVEI	T1,.PRIIN		; FLUSH THE INPUT BUFFER
	RESET
	CFIBF
FATAL0:	HALTF				; RETURN TO EXEC SINCE WE'RE CRASHING
	HRROI	T1,[ASCIZ\?Can't continue\]
	CALL	.SOUTR
	JRST	FATAL0			; DISALLOW CONTINUE COMMAND


; ORDINARY JSYS ERROR ROUTINE

ERROR:
	AOS	ERRCNT			; INREMENT ERROR COUNT
	SKIPN	LOGJFN			; ARE WE LOGGING OR
	SKIPE	.TAKEF			; ARE WE DOING A TAKE
	JRST	ERRO1			; SPECIAL CASE
	HRROI	T1,[ASCIZ\Error: \]
	ESOUT
	MOVEI	T1,.PRIOU		; ERROR MESSAGE TO PRIMARY OUTPUT
	HRLOI	T2,.FHSLF		; THIS FORK'S LAST ERROR
	SETZ	T3,			; NO LIMIT
	ERSTR
	ERJMP	.+1			; SHOULDN'T HAPPEN
	ERJMP	.+1			; DITTO
	HRROI	T1,CRLF
	PSOUT
	RET

ERRO1:	SKIPE	LOGJFN			; ARE WE LOGGING
	CALL	LOG
	CALL	.TECC			; GO ECHO IF NECESSARY
	HRROI	T1,[ASCIZ\
?Error: \]
	CALL	.SOUT
	MOVE	T1,OUTJFN		; GET OUTPUT JFN
	HRLOI	T2,.FHSLF		; THIS FORK'S LAST ERROR
	SETZ	T3,			; NO LIMIT
	ERSTR
	ERJMP	.+1			; SHOULDN'T HAPPEN
	ERJMP	.+1			; DITTO
	HRROI	T1,CRLF
	JRST	.SOUT

.SOUTR:	CALL	.SOUT			; ROUTINE TO PRINT STRING WITH CRLF
OCRLF:	HRROI	T1,CRLF			; ROUTINE TO TYPE A <CR><LF>
.SOUT:	PUSH	P,T2			; SAVE T2
	PUSH	P,T3			; SAVE T3
	MOVE	T2,T1			; PUT POINTER IN T2
	SETZ	T3,			; TERMINATE ON A NUL BYTE
	SKIPE	T1,LOGJFN		; ARE WE LOGING
	CALL	LSOUT			; GO OUTPUT TO LOG
	MOVE	T1,OUTJFN		; GET OUTPUT JFN
	SOUT
	POP	P,T3			; RESTORE T3
	MOVE	T1,T2			; PUT UPDATED STRING POINTER IN T1
	POP	P,T2			; RESTORE T2
	RET

CRLF:	ASCIZ\
\

LSOUT:
	PUSH	P,T2			; SAVE POINTER
	SOUT				; PRINT STRING
	HLL	T2,(P)			; MAKE LEFT SIDE OF POINTERS THE SAME
	SUB	T2,(P)			; GET LOCATIONS
	MOVM	T2,T2			; MAKE POSITIVE
	AOJ	T2,			; GIVE IT A EXTRA
	IMULI	T2,5			; FIVE BYTES PER WORD
	ADDM	T2,L.CNT		; UPDATE COUNT
	SKIPL	L.CNT			; TIME TO UPDATE?
	CALL	L.SAVE			; YES, GO UPDATE LOG
	POP	P,T2			; RESTORE T2
	RET

.NOUT:
	SKIPN	T1,LOGJFN		; ARE WE LOGING
	JRST	.NOUT1			; NO, JUST PRINT TO OUTPUT JFN
	NOUT				; YES OUTPUT LOG
	ERJMP .+1
	MOVEI	T1,14			; APROX COUNT
	ADDM	T1,L.CNT		; UPDATE COUNT
	SKIPL	L.CNT			; TIME TO UPDATE LOG?
	CALL	L.SAVE			; YES, DO IT NOW
.NOUT1:	MOVE	T1,OUTJFN		; GET OUTPUT JFN
	NOUT
	RET
	AOS	(P)			; SKIP RETURN
	RET

.BOUT:
	PUSH	P,T1			; SAVE T1
	SKIPN	T1,LOGJFN		; ARE WE LOGGING
	JRST	.BOUT1			; NO, JUST DO BOUT
	BOUT				; YES,OUTPUT IT
	AOSL	L.CNT			; TIME TO OUTPUT?
	CALL	L.SAVE			; YES, DO IT NOW
.BOUT1:	MOVE	T1,OUTJFN		; GET OUTPUT JFN
	BOUT				; PRINT STRING
	POP	P,T1			; RESTORE T1
	RET

.JFNS:
	PUSH	P,T1			; SAVE T1
	SKIPN	T1,LOGJFN		; ARE WE LOGGING
	JRST	.JFNS1			; NO, JUST OUTPUT TO OUTPUT JFN
	JFNS				; YES, OUTPUT TO LOG FILE
	CALL	L.SAVE			; UPDATE LOG NOW
.JFNS1:	POP	P,T1			; RESTORE OUTPUT JFN
	JFNS
	RET


REEN:	SETOM	REENF			; SET REENTER FLAG
	JRST	START+1

REENF:	0

; ENTRY VECTOR

EVEC:	JRST	START			; START ENTRY POINT
	JRST	REEN			; REENTER ENTRY POINT
VERSIO:	BYTE	(3)VWHO(9)VMAJOR(6)VMINOR(18)VEDIT
EVECL==.-EVEC

	END	<EVECL,,EVEC>