
;**************************************************************************
;
;                    Microsoft Mail Script File
;
;       Filename:XIRC56.MDM
;       Date    :Jun. 20, 1996 R.M
;       Script  :Standardscript file for Xircom Modem 56(Global Access)  
;                and Microsoft Mail Remote.
;       Version :V1.1
;
;     This script file contains the standard modem setup strings used by
;  the External, Transmit and Listen programs.  There are five procedures
;  defined in this script file for setting up the modem and for connecting
;  to a remote External machine.
;
;     The modem setup strings used here will be adequate for most people
;  but there may be some changes required if you are dialing overseas and
;  require a longer wait for Carrier Detect (S7 register) or if you wish
;  to change the speaker volume.  Note that if you used the -Innn option 
;  in version 1.0 or 2.0 that you will have to modify the S7 register and
;  recompile this script file.
;
;     Consult your modem manual for more information on setup options.
;
;  Script procedures defined:
;       INITIALIZE
;       RESET
;       CALL
;       ANSWER
;       DISCONNECT
;
;  Return codes for External, Transmit, Listen:
;       0  - OK
;       1  - CONNECT 
;       2  - RING
;       3  - NO CARRIER
;       4  - ERROR
;       5  - CONNECT 1200
;       6  - NO DIALTONE
;       7  - BUSY
;       8  - NO ANSWER
;       9  - NOT DEFINED
;      10  - CONNECT 2400
;      11  - CONNECT 4800
;      12  - CONNECT 9600 
;      13  - CONNECT 14400
;      14  - CONNECT 19200
;      58  - CONNECT 28800
;      86  - CONNECT 16800
;      18  - CONNECT 57600
;      24  - CONNECT 7200
;      25  - CONNECT 12000
;      56  - CONNECT 24000
;      55  - CONNECT 21600
;      57  - CONNECT 26400 
;      59  - CONNECT 31200
;      60  - CONNECT 33600
;      72  - CONNECT 36000
;      73  - CONNECT 38000
;      74  - CONNECT 40000
;      75  - CONNECT 42000
;      76  - CONNECT 44000
;      77  - CONNECT 46000
;      78  - CONNECT 48000
;      79  - CONNECT 50000
;      80  - CONNECT 52000
;      101 - CONNECT 29333	
;      102 - CONNECT 30666
;      103 - CONNECT 33333
;      104 - CONNECT 34666
;      105 - CONNECT 37333	
;      106 - CONNECT 38666		
;      107 - CONNECT 41333
;      108 - CONNECT 42666		
;      109 - CONNECT 45333	
;      110 - CONNECT 46666		
;      111 - CONNECT 49333
;      112 - CONNECT 50666 
;      113 - CONNECT 53333	
;      114 - CONNECT 54666	
;
;**************************************************************************
INITIALIZE:
display "*** INITIALIZING  ***"
display "***  PLEASE WAIT   ***"
	title "Xircom Modem 56(Global Access)"   

	 baud 57600              ; set the baud rate
	display "   Baud Rate : 57600"
	$attempts = 5

init_retry:
	sendln "AT&FE0W0S95=1V0"           ; reset modem to default settings
	wait 2
	waitrsp 1      
	if ("0" isin response)
	    {
	    goto reset_okay
	    }
	if ("OK" isin response)
	    {
reset_okay:
	    sendln "AT&FE0L3M1X3W0V0"
	    wait 2
	    waitrsp 3
																												       if ("0^M" isin response)
		{
;               send S register codes - S37 sets MAX DCE connection speed                
		sendln "ATS0=0S7=90S9=7S10=50W0S95=1"
		waitrsp 3
		if (response = "0^M")
		    return 0
		}
	     }
	dec $attempts
	if ($attempts > 0)
		goto init_retry

	return 4


RESET:
display "***    RESET    ***"
display "*** PLEASE WAIT ***"
	baud 57600              ; set the baud rate
	display "   Baud Rate : 57600"

	clearrsp               ; clear out any ring signals
	sendln "AT&FE0W0S95=1V0"           ; reset modem to default settings
	waitrsp 4
	sendln "AT&FE0L3M1X3W0V0"
	waitrsp 3
	sendln "ATS0=0S7=90S9=7S10=50W0S95=1"
	waitrsp 3

	if (response = "0^M")
	     return 0
	else
	     return 4



CALL:
display "*** CALL ***"

	$ret = 8               ; set default ret code to "no answer"

	waitrsp 2              ; check to see if the phone is ringing

	if (response = "2^M") {                         ; if there are any 
	  display ">>>Incoming Call - Abort Send<<<"    ; calls coming in,
	  return $ret                                   ; don't dial out
	}

	clearrsp               ; clear the response buffer 

	echo 0                 ; do not display phone number

	sendln "ATD" + dial_mode + phone_number  ; execute the dial up 

	echo 1                 ; turn echo back on

	waitrsp 120            ; wait until the modem responds (max 2 minutes)
	  {
       if ("57^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 26400 <<<"
	  return 12
	  }
	else if ("56^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 24000 <<<"
	  return 12
	  }
	else if ("55^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 21600 <<<"
	  return 12
	  }   
	else if ("25^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 12000 <<<"
	  return 12
	  }
	else if ("24^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 7200 <<<"
	  return 12
	  }
	else if ("18^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 57600 <<<"
	  return 12
	  }
	else if ("86^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 16800 <<<"
	  return 12
	  }
	else if ("58^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 28800 <<<"
	  return 12
	  }
	else if ("14^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 19200 <<<"
	  return 12
	  }
	else if ("13^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 14400 <<<"
	  return 12
	  }
	else if ("12^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 9600 <<<"
	  return 12
	  }
	else if ("11^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 4800 <<<"
	  $ret = 11
	  }
	else if ("10^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 2400 <<<"
	  $ret = 10
	  }
	else if ("7^M" isin response)
	  {
	  display ">>> Busy <<<"
	  $ret = 7            ; busy
	  }
	else if ("5^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 1200 <<<"
	  $ret = 5
	  }
	else if ("3^M" isin response)
	  {
	  display ">>> NO CARRIER <<<"
	  $ret = 8             ; no answer or no connect
	  }
	else if ("40^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 300 <<<"
	  $ret = 40
	  }

	else if ("59^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 31200 <<<"
	  $ret = 12
	  }

	else if ("60^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 33600 <<<"
	  $ret = 12
	  }
	else if ("72^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 36000 <<<"
	  $ret = 12
	  }
	else if ("73^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 38000 	<<<"
	  $ret = 12
	  }
	else if ("74^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 40000 <<<"
	  $ret = 12
	  }
	else if ("75^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 42000 <<<"
	  $ret = 12
	  }
	else if ("76^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 44000 <<<"
	  $ret = 12
	  }
	else if ("77^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 46000 <<<"
	  $ret = 12
	  }
	else if ("78^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 48000 <<<"
	  $ret = 12
	  }
	else if ("79^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 50000 <<<"
	  $ret = 12
	  }
	else if ("80^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 52000 <<<"
	  $ret = 12
	  }
;**********************************added v90 result codes 10/28/98*********
	else if ("101^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 29333	<<<"
	  $ret = 12
	  }

	else if ("102^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 30666	 <<<"
	  $ret = 12
	  }

	else if ("103^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 33333 <<<"
	  $ret = 12
	  }

	else if ("104^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 34666 <<<"
	  $ret = 12
	  }

	else if ("105^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 37333 <<<"
	  $ret = 12
	  }

	else if ("106^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 38666 <<<"
	  $ret = 12
	  }

	else if ("107^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 41333 <<<"
	  $ret = 12
	  }

	else if ("108^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 42666 <<<"
	  $ret = 12
	  }

	else if ("109^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 45333	<<<"
	  $ret = 12
	  }
	
	else if ("110^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 46666 <<<"
	  $ret = 12
	  }

	else if ("111^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 49333 <<<"
	  $ret = 12
	  }

	else if ("112^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 50666 <<<"
	  $ret = 12
	  }

	else if ("113^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 53333 <<<"
	  $ret = 12
	  }

	else if ("114^M" isin response)
	  {
	  baud 57600
	  display ">>> CONNECT 54666 <<<"
	  $ret = 12
	  }



	}
	return $ret            ; return connect baud rate to application 
	


ANSWER:
display "*** ANSWER ***"
	$ret = 8               ; set default ret code to "no answer"

	waitrsp 1              ; see if phone is ringing 

	if (response = "2^M")  ; 2 is numeric form of "RING" 
	{
	  if (listen = 1)    ; see if Listen program is running or not
	      sendln "ATD"   ; answer phone in originate mode (Listen)
	  else
	      sendln "ATA"   ; answer the phone normally

	  waitrsp 120        ; wait for return code from modem (max 2 minutes)
	   
	  if ("57^M" isin response)
		{
		baud 57600
		display ">>> CONNECT 26400 <<<"
		return 12
		}
	  else if ("56^M" isin response)
		{
		baud 57600
		display ">>> CONNECT 24000 <<<"
		return 12
		}
	  else if ("55^M" isin response)
		{
		baud 57600
		display ">>> CONNECT 21600 <<<"
		return 12
		}   
	  else if ("25^M" isin response)
		{
		baud 57600
		display ">>> CONNECT 12000 <<<"
		return 12
		}
	  else if ("24^M" isin response)
		{
		baud 57600
		display ">>> CONNECT 7200 <<<"
		return 12
		}
	  else if ("18^M" isin response)
		{
		baud 57600
		display ">>> CONNECT 57600 <<<"
		return 12
		}
	  else if ("86^M" isin response)
		{
		baud 57600
		display ">>> CONNECT 16800 <<<"
		return 12
		}
	  else if ("58^M" isin response)
		{
		baud 57600
		display ">>> CONNECT 28800 <<<"
		return 12
		}
	  else if ("14^M" isin response)
		{
		baud 57600
		display ">>> CONNECT 19200 <<<"
		return 12
		}
	  else if ("13^M" isin response)
		{
		baud 57600
		display ">>> CONNECT 14400 <<<"
		return 12
		}
	  else if ("12^M" isin response)
		{
		baud 57600
		display ">>> CONNECT 9600 <<<"
		return 12
		}
	  else if ("11^M" isin response)
		{
		baud 57600
		display ">>> CONNECT 4800 <<<"
		$ret = 11
		}
	  else if ("10^M" isin response)
		{
		baud 57600
		display ">>> CONNECT 2400 <<<"
		$ret = 10
		}
	  else if ("7^M" isin response)
		{
		display ">>> Busy <<<"
		$ret = 7             ; busy
		}
	  else if ("5^M" isin response)
		{
		baud 57600
		display ">>> CONNECT 1200 <<<"
		$ret = 5
		}
	  else if ("3^M" isin response)
		{
		display ">>> NO CARRIER <<<"
		$ret = 8             ; no answer or no connect
		}
	  else if ("1^M" isin response)
		{     
		baud 57600
		display ">>> CONNECT SPEED UNKNOWN <<<"
		$ret = 1
		}
	  else if ("59^M" isin response)
	  	{
	  	baud 57600
	  	display ">>> CONNECT 31200 <<<"
	  	$ret = 12
	  	}
	  else if ("60^M" isin response)
	  	{
	  	baud 57600
	  	display ">>> CONNECT 33600 <<<"
	  	$ret = 12
	  	}
	 else if ("72^M" isin response)
	      {
	      baud 57600
	      display ">>> CONNECT 36000 <<<"
	      $ret = 12
	      }
	 else if ("73^M" isin response)
	      {
	      baud 57600
	      display ">>> CONNECT 38000 <<<"
	      $ret = 12
		}
	else if ("74^M" isin response)
	  	{
	      baud 57600
	      display ">>> CONNECT 40000 <<<"
	      $ret = 12
	  	}
	else if ("75^M" isin response)
	  	{
	      baud 57600
	      display ">>> CONNECT 42000 <<<"
	      $ret = 12
	  	}
	else if ("76^M" isin response)
	      {
	      baud 57600
	      display ">>> CONNECT 44000 <<<"
	      $ret = 12
	      }
	else if ("77^M" isin response)
	      {
	      baud 57600
	    display ">>> CONNECT 46000 <<<"
	    $ret = 12
	      }
	else if ("78^M" isin response)
	      {
	      baud 57600
	      display ">>> CONNECT 48000 <<<"
	      $ret = 12
	      }
	else if ("79^M" isin response)
	      {
	      baud 57600
	      display ">>> CONNECT 50000 <<<"
	      $ret = 12
	      }
	else if ("80^M" isin response)
	      {
	      baud 57600
	      display ">>> CONNECT 52000 <<<"
	      $ret = 12
	      }
;**********************************added v90 result codes 10/28/98*********
	else if ("101^M" isin response)
	      {
	      baud 57600
	      display ">>> CONNECT 29333	<<<"
	      $ret = 12
	      }

	else if ("102^M" isin response)
	      {
	  	baud 57600
	  	display ">>> CONNECT 30666	 <<<"
	 	 $ret = 12
	      }

	else if ("103^M" isin response)
	      {
	  	baud 57600
	  	display ">>> CONNECT 33333 <<<"
	  	$ret = 12
	  	}

	else if ("104^M" isin response)
	  	{
	  	baud 57600
	  	display ">>> CONNECT 34666 <<<"
	  	$ret = 12
	  	}

	else if ("105^M" isin response)
	  	{
	  	baud 57600
	  	display ">>> CONNECT 37333 <<<"
	  	$ret = 12
	  	}

	else if ("106^M" isin response)
	  	{
	  	baud 57600
	  	display ">>> CONNECT 38666 <<<"
	  	$ret = 12
	  	}

	else if ("107^M" isin response)
	  	{
	  	baud 57600
	  	display ">>> CONNECT 41333 <<<"
	  	$ret = 12
	  	}

	else if ("108^M" isin response)
	  	{
	  	baud 57600
	  	display ">>> CONNECT 42666 <<<"
	  	$ret = 12
	  	}

	else if ("109^M" isin response)
	  	{
	  	baud 57600
	  	display ">>> CONNECT 45333	<<<"
	  	$ret = 12
	  	}
	
	else if ("110^M" isin response)
	  	{
	  	baud 57600
	  	display ">>> CONNECT 46666 <<<"
	  	$ret = 12
	  	}

	else if ("111^M" isin response)
	  	{
	  	baud 57600
	  	display ">>> CONNECT 49333 <<<"
	  	$ret = 12
	  	}

	else if ("112^M" isin response)
	  	{
	  	baud 57600
	  	display ">>> CONNECT 50666 <<<"
	  	$ret = 12
	  	}

	else if ("113^M" isin response)
	  	{
	  	baud 57600
	  	display ">>> CONNECT 53333 <<<"
	  	$ret = 12
	  	}

	else if ("114^M" isin response)
	  	{
	  	baud 57600
	  	display ">>> CONNECT 54666 <<<"
	  	$ret = 12
	  	}


	}

	return $ret            ; return connect baud rate to application 
	


DISCONNECT:
display "*** DISCONNECT  ***"
display "*** PLEASE WAIT ***"
	wait 2             ; wait 2 seconds 
	DTR 0              ; drop DTR to reset modem 
	wait 2             ; some modems require a delay here
	DTR 1              ; raise DTR 
	clearrsp           ; clear response buffer

	return 0           ; always return OK 





