/* FaxScript For MultiFax And ZVT				*/

options results

signal on break_c
signal on halt
signal on syntax

options failat 50

say "FaxScript For MultiFax And ZVT"

/*
 * MultiFax must be running and in a 'quiet' status.
 * The Spooler must be started with the option '-rx' and
 * with automatic answer disabled,
 * and the MFRexx program has to be running.
 *
 * Since I don't know exactly how MultiFax reacts I guessed
 * using 'CommandSer' at this point - I just know that MultiFax relies
 * on a carrier negotiation and I don't know wether MultiFax needs the
 * response of the modem or not.
 */

/*
 * Let ZVT establish a connection
 */

 address 'ZVT.1' CommandSer "ATA"
 if result="NO CARRIER" then
  do
   setvars(5)
   exit
  end

/*
 * ZVT stays inactive, let MultiFax receive a fax
 */

 address 'MultiFaxRexx' 'receive 4'
 setvars(0)
 exit




/*
 * Maybe I'll put some more sophisticated check here... At this time
 * I have no idea how to check the return values...
 * Up to this point this script does nothing else but receiving the fax.
 */

setVars: procedure
	parse arg error

	if error=0 then
		do
		address zvt.1 'setlength ' || 1
		address zvt.1 'setname ' || unknown_file
		end
	else		/* No fax here. */
		do
		address zvt.1 'setlength ' || 0
		address zvt.1 'setname no_file'
		end
	return rc


error:
	call Debug("Error" rc "at line" sigl)
	return rc

break_c:
halt:
	call Debug("CTRL_C at line" sigl)
	exit 20

syntax:
	call Debug("Syntax error" rc "at line" sigl)
	return rc


Debug: procedure
	parse arg info

	firstLine = sourceline(1)
	parse var firstLine '/*' title '*/'
	say title ':' info
	return
