;
; THIS FILE SHOULD BE USE WITH C-KERMIT 6.0 AND UP ONLY
;
;   Kermit script that sends a numeric message to a pager
;
;   Based on the script by: 
;	Jacob Lundqvist jaclu@ibk.se, 1997-01-10
;
;   By: Mathieu Patenaude 1998-08-21
;
;	- Modified for C-Kermit 6.0
; 

def \%a \&@[2] 	; modem tty line
def \%b \&@[3]	; Telephone number ex 580-4321
def \%c \&@[4]	; The numeric message


;======================================================
;
; Macro deffinitions
;
;======================================================

;  No such device
;
define NO_DEV {
	echo ERROR: no such device: \%1
	set exit status 1
	hangup
	quit
}

; Check if device exists
;
define CHECK_DEV {
	if < \Ffiles(\%1) 1 NO_DEV \%1
}

; Define the serial line and the modem
;
define SET_COMM {

	set line \%a		; The ttyX line to use (serial line)
	set speed 1200		; The bbs
	output ATZ\13		; Reset and make shure the modem is responding
	input 5 OK		; Should receive OK from modem
	xif fail {
		echo
		echo No communication with the modem
		quit
	} else {
		echo
		echo Modem is responding
	}
}

; Call the pager
;
define SEND_MSG {
	output {ATD\%b,,,,\%c#;\13}
	input 60 OK
	xif fail {
		echo
		echo Error Dialing the modem
		echo Error Sendig the numeric message
		output {ATH0\13}
		output {ATZ\13}
		quit
	} else {
		echo
		echo Numeric Message: \%c sent
		output {ATH0\13}
		output {ATZ\13}
	}
}

;======================================================
;
; Main
;
;======================================================

set exit warning off

CHECK_DEV \%a

; Set modem and line params
;
SET_COMM


; Send Message
;
SEND_MSG

;  Exit kermit
;
set exit status 0
quit
