@echo 0
@rem ****************************************************************************
@rem ****                                                                   *****
@rem ****   dial.scr - Dials the telephone number on Hayes(tm)-compatible   *****
@rem ****              Modems.                                              *****
@rem ****                                                                   *****
@rem ****************************************************************************

@if "%DialStringPrefix%" == ""
@  echo "\aDIAL.SCR: Error:  Dial String Prefix not set. See the Options/Modem Settings... menu command for details.\r\n"
<
@endif

@if "%TelephoneNumber%" == ""
@   echo "\a** DIAL.SCR: Error:  Telephone Number not set. See the Options/Script Settings... menu command for details.\r\n"
<
@endif


@echo "** Initializing the Modem...\r\n"

@send "ATZ\r"
@if not @wait "OK" 3
@  rem It's OK, modem may be set to V0.
@endif

@if "%ModemInitString%" != ""
@  send "%ModemInitString%\r"
@  if not @wait "OK" 10
@      echo "\r\n** DIAL.SCR: Error:  Modem not responding\r\n"
<  
@  endif
@endif

@echo "\r\n** Dialing %TelephoneNumber%...\r\n"

@:Redial
@    send "%DialStringPrefix%%TelephoneNumber%\r\n"
@    if not @branch "Waiting for CONNECT" 60 "CONNECT" Connect "BUSY" Busy "NO CARRIER" NoCarrier
@:NoCarrier
@:Busy
@       send "\r"
@       echo "\r\n** No answer.\r\n"
@       wait 5
@       echo "** Redialing %TelephoneNumber%...\r\n"
@       goto Redial
@    endif 
@:Connect

@wait "\n" ; Wait for the end of line
@echo "\r\n** Connected\r\n"

@if "%NetworkScript%" != ""
@echo "** Establishing Network Connection...\r\n"
@"<%NetworkScript%"
@endif

