@echo off
goto start

REM Revised 5/24/01: Removed use of TAME (BITFax likes memory space)
REM   and added item to disable/enable cache (your commands will prob
REM   be different, specific to your cache program
REM  Also requires use of the newer "BITFAX 'S/R' DesqView" version



REM ***************** Documentation *******************************
REM 
REM ***Purpose: Allow use of FAX card, modem, &/or answering maching
REM    on a single line, without any switching-device
REM
REM ***Requires: 1) Charles Eglinton's excellent shareware utility 
REM              called REMOTE CONTROL (latest is REMCTL58.ZIP)
REM           2) Todd Miller's great DOS utility: WAIT.com
REM              available as WAITBAT.ZIP
REM           3) DesqView
REM           4) FAX card with TSR-type software, eg: BitFAX v3.0
REM                with its specific 'DesqView' version
REM
REM ***Why:
REM 
REM  Why want 2 separate 1-ring calls to activate FAX? Because having
REM  a 1-call requirement obligates the FAX to wait the time defined
REM  in the WAIT.com switch line...anyone calling voice will get FAX!
REM  So, having a requirement of 2 means one can reset the sequence
REM  merely by calling again and ringing a few rings!
REM  Also, its unlikely that an unknowing outside party would hangup
REM  twice with 1-ring each time.
REM
REM ** How to setup:
REM          Just read thru this bat file and make any directory/drive
REM          changes to be consistent with your own system.  My own
REM          approach, for clarity, is to include all drive/directory
REM          changes to be written here, even if not nec for the logic
REM          of the batch file... this makes things clear, and, as a
REM          habit, lets one move steps around within a bat file with 
REM          less chance for the file 'losing its way' on execution.
REM
REM      Setup DV's window : ans. 'Y' to "Close on Exit? ".
REM      DV's window must be setup for communications, i.e, it can NOT
REM      be allowed to swap out!
REM
REM * By Jon Anderson, Boston Gas BBS
REM   617-235-6303  * USR DS * 24hrs/day * Anes/Med/Science/Engineering
REM
REM  **************************************************************
REM
REM   You're free, of course, to edit-out all REM'd lines, which are
REM   ignored by DOS.
REM 
REM ****************** end of documentation ***********************

:start
e:
:TOP
REM remove any fax tsr from any earlier event:
e:
cd\bitfax
flash /f?
flash /d
RMV_RECV
flash /a
REM this makes an errorlevel dep. on how many rings before hangup:
:cycle
cd\remctl58
RC 3 ATS0=0
IF ERRORLEVEL 3 GOTO 3
IF ERRORLEVEL 2 GOTO 2
IF ERRORLEVEL 1 GOTO HALFWAY
IF ERRORLEVEL 0 GOTO ABORT
GOTO TOP
:HALFWAY
REM The wait.com used here will show the errorlevel made by RC.com:
REM Keep this under a few seconds..the calling party can dial fast!...
wait 00:00:02
cd\remctl58
REM Gets here ONLY if it was the 2nd 'single ring'.. Anything other than
REM a single prev. ring goes to TOP or ABORT (& same via :2 & :3)
RC 3 ATS0=0
IF ERRORLEVEL==3 GOTO 3
IF ERRORLEVEL 2 GOTO 2
IF ERRORLEVEL 1 GOTO 1
IF ERRORLEVEL 0 GOTO ABORT
GOTO TOP
:1
REM We're now here 'cause it was the 2nd single ring..., 
REM  and now FLUSH OUT YOUR CACHE AND DISABLE IT!...:
flash /f?
flash /d
REM Now we'll load the tsr:
cd\bitfax
REM So we receive into the right dir...
set bitfax=e:\bitfax
recvfax 3
REM must keep 1 min. here, as recvfax is resident,will keep control
REM as long as fax is comming in ??
c:\wait 00:05:00
REM Return environ. so faxdoor  can have it after we're done...
set bitfax=e:\faxdoor3
if errorlevel 1 goto end
flash /a
GOTO TOP
:2
REM Put anything you want done on 2 ring hangups here
GOTO TOP
:3
REM Put anything you want done on 3 ring hangups here
GOTO TOP
:ABORT
:end
REM don't forget to enable your cache, for sure....:
flash /a
REM keep the window open for other uses, but without faxing:
REM (and change prompt in that case...)
echo                           *
echo Hit CTRL-C to keep window open, but NO FAX's CAN BE REC'D!...
echo                           *
wait 00:00:10
if errorlevel 1 goto stay
exit
:stay
set prompt=-$p-$g
