/* GPFax v2.20 & Trapdoor v1.83 Fax Monitor */
if ~show('L',"rexxsupport.library") then do
   if addlib('rexxsupport.library',0,-30,0) then
      call time(R)
      else do
        say "[2B ** REXXSupport.Library unavailable - Aborting...[B"
        exit 10
   end
end
if ~showlist('P','REXX_GPFAX') then do
   say "[2B ** Cannot find GPFax AREXX port - Aborting...[B"
   exit 10
   end
call open out,"con:175/12/640/150/GPFax Monitor v1.0"
if ~result then do
  say "[2B ** Cannot open CON Window - Aborting...[B"
  exit 10
  end
endif
openport("FaxMon")
num=0
comm=" "
call writeln out,"GPFax Monitor activated: "time(C)
/* Idle and process loop */
do forever
call writeln out,"[1m*Awaiting Command*[0m"
waitpkt("FaxMon")
num=getpkt("FaxMon")
comm=upper(getarg(num))
call writeln out,"[B[7m TASK:[0m "comm
if comm="NOTIFY" then do
  reply(num,0)
  options results
  address rexx_gpfax
  reportlog R 3
    if left(result,2)="OK" then do
      reportlog R 4
      name=trim(result)
      reportlog R 2
      pages=trim(result)
      reportlog R 5
      info=trim(result)
      call writeln out,"[7;32mFAXIN:[0;32m "name" ("pages" pages) ["info"]"
      reportlog R 1
      fname=trim(result)
      call writeln out,"[7;32m FILE:[0;32m "fname"[0m"
      viewfax result
    end
end
if comm="VIEWLAST" then do
  reply(num,0)
  call writeln out,"[BViewing last fax received..."
  options results
  address rexx_gpfax
  viewlast
end
if comm="PRINTLAST" then do
  reply(num,0)
  call writeln out,"[BPrinting last fax received..."
  options results
  address rexx_gpfax
  printlast
end
if comm="QUIT" then do
  reply(num,0)
  call writeln out,"[BExiting Fax Monitor..."
  address command "wait 1"
  exit 0
end
num=0
comm=" "
end

