! Original script by Fred Morris
! Modifications and comments by Adam C. Engst
! 21-Feb-94 = Added redial feature (ACE)

@originate
! Initialize mode from string in InterSLIP configuration
note "Initializing modem"
write "^4\13"
pause 20
! Dial modem from number in InterSLIP configuration
note "Dialing ^1"
write "atdt^1\13"
! Check only for BUSY or CONNECT, then redial or connect
matchstr 1 10 "BUSY"
matchstr 2 20 "CONNECT"
matchread 500

@label 10
! The line is busy, so let's redial the modem indefinitely
! This will also redial after the (matchread 500) timeout if you get endless rings
note "Line busy, redialing ^1"
! First hang up and reinitialize modem from string in InterSLIP configuration
write "+++"
pause 60
write "ath\13"
write "^4\13"
! Then go back and dial again using phone number in InterSLIP configuration
jump originate

@label 20
! Everything worked fine, you're connected now
note "Dialed successfully"
exit 0

@answer
@hangup
! Hang up the modem and reinitialize from string in InterSLIP configuration
! The only way to get here is to manually click the Disconnect button
note "Hanging up modem"
write "+++"
pause 60
write "ath\13"
write "^4\13"
exit 0