! (c) copyright 1994, Fred Morris, Seattle, WA. You may post this file
! to your favorite ftp site or on-line service one time, provided
! that you e-mail me telling me where.  You may share this file with
! your friends or clients provided that you do not charge them for it
! per se. Exceptions: Elliotte Harold, you have to ask before you
! even use it;  Adam Engst, you can do anything you want with it;
! InterConn, you can include this script with InterSLIP if you wish.
! Contact me via e-mail at m3047@halcyon.com,  or finger that account
! for additional information.  Yeah, I am a guru, but I believe in the
! cult of experience and I don't suffer fools;  you've been warned,
! think carefully before importuning me with questions that you could
! have answered on your own in the time it takes you to compose e-mail
! and me to answer it.
!
! Fred's zen way InterSLIP dialing script.  It's simple.  It's easy to
! understand.  It won't cook your breakfast.  It does what it does
! and that's it.  Retry on busy was added at Adam Engst's request.
! Written as a reaction to the pompous and intricate-to-the-point-of
! -fragility crap that modem manufacturers and Apple itself ship.
! Your modem must be configured to send CONNECT and BUSY responses for
! this script to work correctly.  See your modem documentation if
! you're not sure how your modem sets up by default.  The script
! assumes that your modem uses "AT" to initiate command sequences and
! that it recognizes "+++" as the attention sequence and that "ATH"
! will hang up the line.
!
! The InterSLIP documentation has pretty good explanations of the
! commands used here (and some others as well).  Apple's own CCL
! scripts use the same commands (more or less).  To edit an Apple
! CCL, use a disk editor to change the type of the file from 
! "mlts" to "TEXT" and the creator (if you wish) from "slnk" to
! "ttxt",  then edit with any text file editor.  Change the type
! and creator back before trying to use the script.  ARAPS 2.0 doesn't
! display notes;  total bogosity, Apple, it ain't gonna sell ARA
! development kits if I can do anything about it.  If you have to hack
! an ARA script, my best debugging suggestion is to use exit -1 to
! generate breaks.  Or order the development kit from APDA. Not that
! I'd do that, but maybe some sucker will.
!
! *****************************************************************
! This section of the script is executed when you click the connect
! button.
@originate			! Standard CCL label for this section
!
! We will come back here if BUSY is detected.
@label 5			! Creates "line number" 5 for use as a
                            	! branch destination.
!
! Display status for the user.
note "initializing modem"	! note displays the quoted string in the
				! InterSLIP status area.
!
! Initialize the modem.
write "^4\13"			! write sends a string to the modem.
				! ^4 substitutes the initialization string
				! specified in the InterSLIP setup;  this
				! may be specific to InterSLIP or InterConn.
				! Possible bug: it didn't seem to like
				! multiple substitutions in the same string.
				! \13 sends a carriage return.
pause 20			! pause waits.  I think the unit is 10ths
				! of a second,  but I'm probably wrong.
!
! Tell the user what number we're dialing and then dial it.
note "dialing ^1"		! ^1 substitutes the dial string specified
				! in the InterSLIP setup.
write "atdt^1\13"		! ACE - changed to "atdt"
!
! Wait for Godot..
matchstr 1 5 "BUSY"		! matchstr sets a trigger on the specified
				! string.  the first number is some sort
				! of trigger identifier.  the second number
				! is the "line number" to branch to if
				! the trigger goes off. the last parameter
				! is the string to trigger on.
matchstr 2 20 "CONNECT"		
matchread 500			! matchread puts the script into a receptive
				! mode with the matchstr triggers active.
				! the parameter is how long to wait for one
				! of the triggers to fire.
!
! If neither "CONNECT" nor "BUSY" is seen in 50 seconds, we fall through
! to here.
@label 10
note "Dial Failed!"
exit -1				! exit terminates execution of the script at
				! this point. if the parameter is -1 there
				! has been an error.  if the parameter is 0
				! then the script finished successfully.
!
! We jump here if "CONNECT" is seen.
@label 20
note "dialed successfully"
exit 0
!
! *****************************************************************
! I never use answer mode with InterSLIP.  I doubt you do, either.
@answer				! This is the standard label where execution
				! would begin if auto-answer was supported.
exit -1
!
! *****************************************************************
! This section of the script is executed when you click the disconnect
! button.
@hangup				! This is the standard CCL label where
				! execution is to begin when hanging up the
				! modem.
!
! Tell the user what's happening.
note "hanging up modem"
!
! Get the modem's attention.
write "+++"
pause 60
!
! Tell it to hang up the phone.
write "ath\13"
!
! We're happy now.
exit 0