; ----- Dial TELENET and connect
;	R.McG; 7/89, Chicago
; ----------------------------------------------------------------
; Usages:
;	  S0 ------> Destroyed
;
; Requires:
;	  This script does not FCALL any other script
;
; This script may be FCALLED
; ----------------------------------------------------------------
;	Make connection to TELENET.  The dialing directory (or current
;	.. setting define parity and speed).
;
	LEGEND " Dialing Telenet... "
	DEFTIME "60"            ; Wait 60 seconds for an incoming string
	IF NOT LINKED		; If script not invoked from Alt-D
	   DIAL "10"            ; Call dial dir entry number 10 (Telenet)
	   IF FAILED		; IF esc out
	      EXIT		; terminate script
	      ENDIF		; End if failed
	   ENDIF		; End if not linked
;
;	Make connection according to the dialing directory's parity/speed
;	.. i.e: parity and speed make a difference in how we connect
;
	COMPARMS S0			; Get current settings
	IF STRCMP "N" S0(5:5)           ; If no parity
	   IF STRCMP "2400" S0(0:3)     ; If 2400 baud connect Send @D<cr>
	      PAUSE 5			;    Wait for the modem to settle
	      TRANS "@"                 ;    Send @D<cr> slowly
	      PAUSE 1			;    Wait a moment
	      TRANS "D"                 ;    Set to 8N1
	      PAUSE 1			;    Wait a moment
	      TRANS "!"                 ;    Set to 8N1
	   ELSE 			; ELSE 300/1200 (send <cr>D<cr>)
	      PAUSE 5			;    Wait for the modem to settle down
	      TRANSMIT "!D"             ;    Transmit Carriage return <CR> D
	      PAUSE 1			;    Wait 1 sec
	      TRANSMIT "!"              ;    .. (8 bit identifier)
	      ENDIF
	ELSE				; ELSE even or odd parity
	   IF STRCMP "2400" S0(0:3)     ; If 2400 baud connect Send @D<cr>
	      PAUSE 5			;    Wait for the modem to settle
	      TRANS "@"                 ;    Send @D<cr> slowly
	      PAUSE 1			;    Wait a moment
	      TRANS "D"                 ;    Set to 8N1
	      PAUSE 1			;    Wait a moment
	      TRANS "!"                 ;    Set to 8N1
	   ELSE 			; ELSE 300/1200 (send <cr><cr>)
	      PAUSE 5			;    Wait for the modem to settle down
	      TRANSMIT "!"              ;    Transmit Carriage return <CR>
	      PAUSE 2			;    Wait 1 sec
	      TRANSMIT "!"              ;    Transmit Carriage return <CR>
	      ENDIF
	   ENDIF
;
;	Send terminal identification
;
	WAITFOR "TERMINAL="     ; Wait for the prompt
	TRANSMIT "D1!"          ; Set terminal type
	WAITFOR "@"             ; Wait for next prompt
	SET BSUPPRESS OFF	; Turn off blank line suppression
	SET MASK ON		; Turn on high bit mask
	SET CDISPLAY ON 	; Display ctl chars
;
;	Exit - this script may be called
;
	IF FCALLED
	   FRETURN
	   ENDIF
;
;	If we exit here, sound alarm
;
	ALARM			; Sound alarm - we're done
	EXIT
