home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / voice.zip / V_MBXLAN.CMD < prev    next >
OS/2 REXX Batch file  |  1996-09-09  |  28KB  |  773 lines

  1. /* V_MBXLAN.CMD - Voice/Fax Answer Script for FaxWorks/PMfax (REXX) */
  2. /* 
  3.                   Keller Group Inc.  September 9, 1996
  4.    You may freely use or modify this script for use with licensed
  5.         products which are developed by Keller Group Inc.
  6.       For new scripts or to share your scripts with others,
  7.                  see http://www.kellergroup.com
  8. */
  9. /*******************************************************************
  10. V_MBXLAN.CMD - Advanced voice/fax mailbox system - LAN Private Mode
  11.  
  12. For use with the following Keller software configurations:
  13.   LAN Private Mode (retrieval from private fax logs)
  14.  
  15. Features:
  16.  
  17.   Callers can:
  18.      select a LAN user by their "extension"
  19.      hear both a "company" greeting and the extension's "personal" greeting
  20.      send a fax (to an extension, or by default to the server),
  21.      leave a voice message (to an extension, or by default to the server),
  22.      listen to an announcement, or
  23.      enter extension and private password to enter remote retrieval mode
  24.  
  25.   In the password-protected remote retrieval mode, you can do:
  26.      greeting modification - remotely update your personal greeting message
  27.      password modification - remotely modify your personal access code
  28.      voice retrieval - get voice messages by phone
  29.      fax retrieval - get fax messages, or send them to a fax number
  30.      log retrieval - get a fax of your log (or the last part of it)
  31.      "fax on demand" from log - retrieve voice and fax items from your log
  32.  
  33.  
  34. DESCRIPTION:
  35. -----------
  36. This script plays your outgoing message (OGM).  The caller can enter
  37. the "extension" (Route ID) of a LAN user followed by the '#' key to
  38. hear that user's personal outgoing message and then record a message
  39. or send a fax directly to them.  If the caller doesn't enter any
  40. extension or enters '0#' or '#', the caller can record a message to
  41. the "receptionist" (the administrative router of the LAN system).
  42.  
  43. The caller can press the # or * key to skip the outgoing message and
  44. immediately record their message, otherwise the script will provide a
  45. beep and record the caller's message if no further action is taken.
  46.  
  47. If the call is from a fax device and your fax hardware detects the
  48. caller's fax (CNG) tones, the script automatically receives the fax.
  49.  
  50. If the caller enters '2' during playing of the outgoing message, the
  51. script plays the "announcement" and then returns to the outgoing
  52. message again so that the caller can leave a message on the same
  53. call.  If a LAN user's extension is selected, the LAN user's personal
  54. announcement is played, otherwise the system's main announcement is
  55. played.
  56.  
  57. If the caller enters '9' during or immediately after the playing of
  58. the OGM and then enters the user-configurable access code followed by
  59. the # key, the script enters its "remote retrieval" mode so the
  60. caller can hear received voice messages, have received faxes sent to
  61. them via fax, and other features.  When in this mode, the keys on the
  62. telephone do the following:
  63.  
  64.    1 - HELP       - Play help message which describes these commands
  65.    2 - SET CODE   - Changes LAN user's private access code (default: 42)
  66.    3 - GREETING   - Enter new outgoing message (change greeting)
  67.  
  68.    4 - PREV MSG   - Play previous voice message
  69.    5 - REPLAY MSG - Play current voice message (again)
  70.    6 - NEXT MSG   - Play next voice message
  71.  
  72.    7 - GET FAXES  - Retrieve new fax messages by fax
  73.    8 - GET LOG    - Retrieve fax log by fax
  74.    9 - FOD LOG    - Retrieve voice/fax msgs from log ("fax-on-demand")
  75.  
  76.    0 - TOP        - Return to top level and play outgoing message again
  77.  
  78.  
  79. USAGE INSTRUCTIONS:
  80. ------------------
  81. You must be using the program with supported voice/fax hardware to
  82. use this script.  Consult the README.DOC file for tested voice/fax
  83. hardware and recommended configuration settings for your hardware.
  84. Before using this script, first test your system with our built-in
  85. voice answering machine feature by enabling "Voice" and setting the
  86. "Answer script" to * (an asterisk character) on the Voice page of the
  87. Settings notebook.  If you are using supported voice/fax hardware
  88. with the proper configuration settings, you can then use
  89. "Fax/Receive/All calls" mode to answer calls, play the outgoing
  90. message (OGM), and record a voice message (or receive a fax).
  91.  
  92. Then, to change to this advanced script, specify the full pathname of
  93. this file in the "Answer script" field on the Voice page of the
  94. settings notebook.
  95.  
  96. NOTE: The script expects to find the LIB_FOD.CMD file and its Wave
  97. audio files in the fax program (EXE) directory.  The script also uses
  98. Wave files from the c:\mmos2\sounds directory for special effects.
  99.  
  100. SCRIPT VARIABLES:
  101. ----------------
  102. The following script variable is used by this script.  Script
  103. variables are set on the Voice page of the Fax Server's Settings
  104. Notebook.
  105.  
  106. General:
  107.  
  108.     OGM - Pathname of the main "outgoing message" which is played
  109.     to the caller.  By default, the program sets OGM to be the
  110.     file OGM.WAV in the fax server's program directory.
  111.     Example: OGM = C:\FAX\OGM.WAV
  112.     [LAN users can also place a personal OGM.WAV file in their fax
  113.     data directory or record one using remote access command '3'.]
  114.  
  115.     CODE - Access code for retrieving messages or changing
  116.     settings from the fax server's log.  By default, the program
  117.     sets CODE to be 42.  You can change this to be any number of up
  118.     to 5 digits in length.
  119.     Example: CODE = 42
  120.     [LAN users can also set a personal access code for their mailbox
  121.     using the '2' command when they call in, and this personal value
  122.     is saved in the ACCESS.COD file in their fax directory.  If no
  123.     personal access code is set, the default value is 42.]
  124.  
  125.     CALLER - (optional, default "Person") - Name of the person/company
  126.     who will be using the access code to retrieve messages/faxes
  127.     by phone.  This is used for addressing faxes when the caller
  128.     uses the access code for remote retrieval.  
  129.     Example: CALLER = Your Company Inc.
  130.  
  131.     LOGMAXLINE - (optional, default 56) - Maximum number of log
  132.     entries, from the end of the log, to be sent to the caller
  133.     when they retrieve the log by fax.  If set to 0, then
  134.     the entire log is sent.
  135.     Example: LOGMAXLINE = 120
  136.  
  137.  
  138. VOICE PROMPT FILES:
  139. ------------------
  140. The script expects to find the following Wave audio files in the fax
  141. program (EXE) directory.  The script also uses Wave files from the
  142. c:\mmos2\sounds directory for special effects.
  143.  
  144. To record or modify your own voice prompt files, use your OS/2
  145. Multimedia microphone and record voice prompts using the "Fax/New
  146. message" command then save them to a .WAV file with the "Fax/Save
  147. file/Wave" command.  You can also use the OS/2 Digital Audio program
  148. to record, save, edit and modify the Wave files (be sure to use
  149. "Type" of Mono, 8-bit, 11.025 kHz).
  150.  
  151.     OGM.WAV - The main "outgoing message" as recorded with the
  152.     Utilities/Outgoing message command.
  153.  
  154.     ENTR_COD.WAV - Short: "Enter code."
  155.     Long: "Please enter your access code and the # key."
  156.  
  157.     ENTR_CMD.WAV - Short: "Enter command."
  158.     Long: "To play current message press 5, to play next message
  159.     press 6, to play previous message press 4...."
  160.  
  161.     ENTR_MSG.WAV - Short: "Enter message, then press # key."
  162.     Long: "Please leave your message at the beep.  Press # key to end."
  163.  
  164.     ANNOUNC.WAV - Short: "No announcement."
  165.     Long: "Our annoucement for this week is...."
  166.  
  167.     HELP.WAV - "Press 3 to change outgoing message, 4 for previous..."
  168.  
  169.     NO_MSGS.WAV - Short: "No more messages."
  170.  
  171. And used by any fax retrieval actions (LIB_FOD.CMD procedure):
  172.  
  173.     ENTR_DOC.WAV - Short: "Enter document number and # key, or
  174.     press the # key if done."
  175.     Long: "Please enter the document number followed by the # key,
  176.     or press the # key if done.  To receive an index of available
  177.     documents, enter document 1000."
  178.  
  179.     HOW_FAX.WAV - Short: "Enter 1 if calling from fax machine, 2
  180.     if not."
  181.     Long: "If you are calling from your fax machine and are ready
  182.     to receive the fax press 1, to send the fax to a different
  183.     number press 2." 
  184.  
  185.     ENTR_FAX.WAV - Short: "Enter fax number and # key."
  186.     Long: "Please enter your fax number followed by the # key,
  187.     including 1 and area code if this is not a local call." 
  188.  
  189.     NO_FILE.WAV - Short: "File not found."
  190.     Long: "That document was not found, please try again."
  191.  
  192.     WAIT.WAV - Short: "Please wait."
  193.     Long: "Please wait while we process your request."
  194.  
  195.     THANKYOU.WAV - Short: "Thank you."
  196.  
  197. TO MODIFY THE SCRIPT:
  198. --------------------
  199. The script is REXX and uses calls from the Keller REXX API which are
  200. automatically loaded into the OS/2 REXX environment by the retail
  201. versions of Keller's fax products (version 3.0 and later).  See the
  202. Reference Manual for documentation of the FxRx and FxLn calls.  You
  203. may modify the script as desired, and then use it as the "Answer
  204. script" with Keller fax software products.
  205.  
  206. Note - For voice message retrieval, this script uses the RCVD/N_RCVD
  207. mode of FxRxFind, which means that it will report only those voice
  208. messages which have been received but not already played at the
  209. computer and not previously retrieved via phone.  If desired, you can
  210. change this to use READ/N_READ mode which will report all voice
  211. messages which have not been previously retrieved via phone (even
  212. those that have been played at the computer).  You can also retrieve
  213. any desired voice message, whether or not it has been played or
  214. retrieved, using the "fax log" and "fax-on-demand" features in this
  215. script which allow you to play any voice message by its index number.
  216.  
  217. Note - For fax message retrieval, this script uses the RCVD/N_RCVD
  218. mode of FxRxFind, which means that it will report only those faxes
  219. which have been received but not already viewed at the computer and
  220. not previously retrieved via phone.  If desired, you can change this
  221. to use READ/N_READ mode which will report all faxes which have not
  222. been previously retrieved via phone (even those that have been viewed
  223. at the computer).  You can also retrieve any desired fax, whether or
  224. not it has been viewed or retrieved, using the "fax log" and
  225. "fax-on-demand" features in this script which allow you to retrieve
  226. any fax by its index number.  In version 3 of the fax program,
  227. viewing a received fax changes its status from Rcvd to Read, but
  228. printing of faxes does NOT change the status, so you can auto-print
  229. all received faxes at the computer and still retrieve them as "Rcvd"
  230. faxes by phone. 
  231.  
  232. HOW TO PROVIDE FORWARDING, PAGING, ETC. ON A PER-USER BASIS:
  233. -----------------------------------------------------------
  234. Some users may wish to provide actions which are automatically
  235. invoked when a fax or voice message is routed to a LAN user's private
  236. fax directory.  For example, you could have all received faxes
  237. forwarded to a fax number or emailed.  One way of doing this is by
  238. using the "Notify Command" field on the Option/Settings dialog of the
  239. FxRDR program on the fax server.  This command is executed whenever a
  240. fax is routed to a LAN user, so you can write a REXX program which is
  241. passed the UserID and then uses the REXX API commands (including
  242. FxRxSelect to select the LAN user's fax log using the UserID) to take
  243. appropriate actions whenever a fax or message is routed.  The
  244. V_MBX.CMD script shows how to do fax forwarding and email, and the
  245. Notify Command features are documented in the LAN Guide.
  246.  
  247. TO USE WITH MULTILINE VERSIONS:
  248. ------------------------------
  249. This script can be used with multiline versions of Keller fax
  250. software.  All lines are handled identically, so calls can be
  251. received on any of your "receive" lines.  If you prefer to have
  252. different lines be handled differently you can modify the script to
  253. test the LID variable.  For example, to have line 1 immediately jump
  254. to the "please enter your message" prompt, you could add a line like
  255. the following after the "call FxLnInit" line in the script: "if LID =
  256. 1 then signal voice" where "voice" is a label in the script.
  257.  
  258. *******************************************************************/
  259.  
  260.   call FxLnInit
  261.  
  262.   VOXDIR = FxRxPath( 'EXE' )    /* get voice prompts from exe dir */
  263.   LIBDIR = FxRxPath( 'EXE' )    /* get REXX subroutines from exe dir */
  264.   FODPROCEDURE = LIBDIR||'lib_fod.cmd'  /* use this external procedure */
  265.  
  266.   /* default values for script variables */
  267.   if CALLER = 'CALLER' then CALLER = 'Person'
  268.   if LOGMAXLINE = 'LOGMAXLINE' then LOGMAXLINE = 56
  269.  
  270.   DEFAULTCODE = '42'        /* default access code */
  271.  
  272. hello:
  273.   USERID = ''            /* if blank, use the fax server's log */
  274.   USERDIR = ''
  275.  
  276.   /* If using Brooktrout, you may need to use certain lines for fax since */
  277.   /* it has trouble hearing calling fax CNG tones when you are using      */
  278.   /* voice and DTMF commands. For example... */
  279.   /* if LID = 1 then signal fax */
  280.  
  281.   call FxRxSelect ''
  282.   call FxLnMsg 'OGM'                /* show in status window */
  283.     if result = 'NOTOK' then signal byebye
  284.   call FxLnPlay OGM                /* play greeting prompt */
  285.     if result = 'NOTOK' then signal byebye
  286.     if result = 'FAX' then signal fax
  287.     if result = 'DATA' then signal data
  288.  
  289.   digits = GetExtension( 5, 10, 5 )        /* get extension or number */
  290.     if digits = 'NOTOK' then signal byebye
  291.     if digits = 'FAX' then signal fax
  292.     if digits = 'DATA' then signal data
  293.  
  294.   if digits = '' | digits = '0' then signal voice  
  295.   if digits = 2 then signal announce        /* use key value... */
  296.   if digits = 9 then signal accesscode
  297.  
  298.   /* else they must have entered an extension... */
  299.   call FxRxSelect digits
  300.  
  301.   if result = 'NOTOK' then signal hello
  302.  
  303.   /* else it is 'OK', meaning it is a valid LAN user */
  304.   USERID = digits
  305.   USERDIR = FxRxPath( 'LOG' )
  306.   if stream(USERDIR||'OGM.WAV', 'C', 'QUERY EXISTS' ) <> ''
  307.   then call FxLnPlay USERDIR||'OGM.WAV'
  308.   call FxRxSelect ''  
  309.  
  310.   call FxLnDtmf 1, 3, 'digits'            /* get key, if any... */
  311.     if result = 'NOTOK' then signal byebye
  312.     if result = 'FAX' then signal fax
  313.     if result = 'DATA' then signal data
  314.     if result <> 'DTMF' then signal voice
  315.  
  316.   if digits = 2 then signal announce        /* use key value... */
  317.   if digits = 3 then signal fax
  318.   if digits = 9 then signal accesscode
  319.  
  320.  
  321. voice:                    /* take voice message, hangup */
  322.   call FxLnMsg "Record Msg"
  323.   call FxLnTone 1850
  324.     if result = 'NOTOK' then signal byebye
  325.   call FxLnDtmf     /* flush buffer */
  326.   call FxLnRecord
  327.     if result = 'NOTOK' then signal byebye
  328.     if result = 'FAX' then signal fax
  329.     if result = 'DATA' then signal data
  330.   /* caller can hang up or press a key to end recording */
  331.   call FxLnTone 1850, 1850, 1850
  332.   if USERID <> '' then do
  333.     LREC.!Owner_ID = '#'||USERID    /* route to extension, if any */
  334.   end
  335.   signal out
  336.  
  337.  
  338. fax:                    /* receive fax and hangup */
  339.   call FxLnReceive
  340.   if USERID <> '' then do
  341.     LREC.!Owner_ID = '#'||USERID    /* route to extension, if any */
  342.   end
  343.   signal out
  344.  
  345.  
  346. data:                    /* report data call, hangup */
  347.   call FxLnMsg 'Data call, oh well...'
  348.   LREC.!Status = '*Data!'   /* log status of call */
  349.   signal out
  350.  
  351.  
  352. announce:                /* play annoucement, restart */
  353.   call FxLnMsg "Announcement"
  354.   call FxRxSelect USERID
  355.   if stream(FxRxPath('LOG')||'ANNOUNC.WAV', 'C', 'QUERY EXISTS' ) <> ''
  356.   then call FxLnPlay FxRxPath('LOG')||'ANNOUNC.WAV'
  357.   else call FxLnPlay VOXDIR||'ANNOUNC.WAV'
  358.   call FxRxSelect ''
  359.   signal hello
  360.  
  361.  
  362. accesscode:
  363.   if USERID <> '' then do
  364.     call FxRxSelect USERID    /* work from the private log, if found */
  365.   end
  366.   call FxLnMsg 'Code ???'        /* get & check access code */
  367.   call FxLnPlay VOXDIR||'ENTR_COD.WAV'
  368.     if result = 'NOTOK' then signal byebye
  369.   digits = GetNumber( 6, 10 )
  370.  
  371.   if USERID = '' then do
  372.     if digits <> CODE then signal evil
  373.   end
  374.   else do
  375.     if digits <> FetchCode() then signal evil
  376.   end
  377.  
  378.   call FxLnMsg 'Code Mode'
  379.   call FxLnVout 'Valid code entered'
  380.   call FxRxBeep 354, 393, 295, 354, 0, 393
  381.  
  382.   call FxRxFind 'MSG', 'N_RCVD'        /* get # of new voice msgs */
  383.   if result = 'NOTOK' then do
  384.     call FxLnPlay 'c:\mmos2\sounds\BOING.wav'
  385.     signal byebye
  386.   end
  387.   n = result
  388.  
  389.   /* if no messages... stay in command mode for other (fax) commands */
  390.   if n = 0 then do
  391.         call FxLnPlay VOXDIR||'NO_MSGS.WAV'
  392.         if result = 'NOTOK' then signal byebye
  393.   end
  394.  
  395.   i = n                /* Play 1 beep for each voice message */
  396.   call FxLnMsg 'Code Mode' n 'messages'
  397.   call FxLnVout 'Beep' n 'times'
  398.   do while i > 0
  399.     call FxLnTone 2100
  400.     i = i - 1
  401.   end
  402.  
  403.   call FxLnVout 'Enter message loop'
  404.   i = 0
  405.   j = 0
  406.   do forever
  407.     call FxLnMsg 'Waiting for next command'
  408.     call FxLnPlay VOXDIR||'ENTR_CMD.WAV'
  409.     call FxLnDtmf 1, 30, 'digits'
  410.     if result <> 'DTMF' then do
  411.       signal goodbye
  412.     end
  413.     else do
  414.       call FxLnMsg 'Code Mode command' digits
  415.       call FxLnVout 'Command' digits 'entered'
  416.  
  417.  
  418.       if digits = '1' then do            /* 1 = Play help msg */
  419.         call FxLnVout 'Help message'
  420.         call FxLnPlay VOXDIR||'HELP.WAV'
  421.       if result = 'NOTOK' then signal byebye
  422.         iterate
  423.       end
  424.  
  425.  
  426.       if digits = '2' & USERID <> '' then do    /* 2 = change access code */
  427.         /* Only access codes for LAN users are changed through this. */
  428.         /* For the fax server, use the CODE script variable on Voice page. */
  429.         call FxLnVout 'Change access code for' USERID
  430.         call FxLnMsg 'Code Mode command' digits
  431.         call FxLnPlay VOXDIR||'ENTR_COD.WAV'
  432.           if result = 'NOTOK' then signal byebye
  433.         code1 = GetNumber( 6, 10 )
  434.         call FxLnPlay VOXDIR||'ENTR_COD.WAV'
  435.           if result = 'NOTOK' then signal byebye
  436.         code2 = GetNumber( 6, 10 )
  437.         if code1 = code2 then do
  438.           call SaveCode code1
  439.           call FxLnPlay VOXDIR||'THANKYOU.WAV'
  440.         end
  441.         else do
  442.           call FxLnVout 'New code mismatch:' code1 'vs' code2
  443.           call FxLnPlay 'c:\mmos2\sounds\BOO.wav'
  444.         end
  445.         iterate
  446.       end
  447.  
  448.  
  449.       if digits = '3' then do            /* 3 = Enter outgoing msg */
  450.         call FxLnVout 'Enter outgoing message for' USERID
  451.         call FxLnPlay VOXDIR||'ENTR_MSG.WAV'
  452.       if result = 'NOTOK' then signal byebye
  453.         call FxLnTone 1850
  454.       if result = 'NOTOK' then signal byebye
  455.         call FxLnDtmf        /* flush buffer */
  456.         if USERID = ''
  457.         then call FxLnRecord OGM
  458.         else call FxLnRecord USERDIR||'OGM.WAV'
  459.       if result = 'NOTOK' then signal byebye
  460.         call FxLnTone 1850, 1850, 1850
  461.         call FxLnDtmf        /* flush buffer */
  462.         if USERID = ''
  463.         then call FxLnPlay OGM
  464.         else call FxLnPlay USERDIR||'OGM.WAV'
  465.       if result = 'NOTOK' then signal byebye
  466.         iterate
  467.       end
  468.  
  469.  
  470.       if digits = '4' then do            /* 4 = Previous msg */
  471.         call FxLnVout 'Play previous message' i
  472.         if i <= 1
  473.     then call FxLnPlay VOXDIR||'NO_MSGS.WAV'
  474.     else do
  475.       i = i - 1
  476.           call FxLnMsg 'Code Mode command' digits 'Msg' list.i
  477.         call FxLnPlay list.i
  478.       end
  479.         iterate
  480.       end
  481.  
  482.  
  483.       if digits = '5' then do            /* 5 = Replay msg */
  484.         call FxLnVout 'Replay message' i
  485.         if i <= 0
  486.     then digits = '6'    /* replay = next if just starting */
  487.     else do
  488.           call FxLnMsg 'Code Mode command' digits 'Msg' list.i
  489.       call FxLnPlay list.i
  490.           iterate
  491.     end
  492.       end
  493.  
  494.  
  495.       if digits = '6' then do            /* 6 = Next message */
  496.         call FxLnVout 'Play next message' i j
  497.         if i = n 
  498.     then call FxLnPlay VOXDIR||'NO_MSGS.WAV'
  499.     else do
  500.         i = i + 1
  501.         if i > j then do
  502.         call FxRxFind 'MSG', 'RCVD', 'LREC'
  503.         call FxLnVout 'Found' LREC.!ID
  504.         list.i = FxRxIndexToFax( LREC.!ID )    /* use pathname! */
  505.             /* Need path rather than index since FxRxSelect switch */
  506.             /* applies to FxRx calls, but not FxLn calls. */
  507.         j = i
  508.       end
  509.           call FxLnMsg 'Code Mode command' digits 'Msg' list.i
  510.         call FxLnPlay list.i
  511.         end
  512.         iterate
  513.       end
  514.  
  515.  
  516.       if digits = '7' then do            /* 7 = send rcvd faxes */
  517.         call FxLnVout 'Send rcvd faxes'
  518.         call FxLnMsg 'Code Mode command' digits
  519.         call FxRxFind 'FAX', 'N_RCVD'        /* get # of new faxes */
  520.         if result = 'NOTOK' then do
  521.           call FxLnPlay 'c:\mmos2\sounds\BOING.wav'
  522.           signal byebye
  523.         end
  524.         nfax = result
  525.         if nfax = 0 then do
  526.           call FxLnPlay VOXDIR||'NO_MSGS.WAV'
  527.           if result = 'NOTOK' then signal byebye
  528.         end
  529.         else do
  530.           ifax = nfax        /* Get faxes into list and beep per fax */
  531.           faxlist = ''
  532.           flist = ''
  533.           call FxLnMsg 'Code Mode' nfax 'faxes'
  534.           call FxLnVout 'FaxBeep' nfax 'times'
  535.           do while ifax > 0
  536.             call FxLnTone 2100
  537.             ifax = ifax - 1
  538.             call FxRxFind 'FAX', 'RCVD', 'LREC'
  539.             call FxLnVout 'Found' LREC.!ID
  540.             /* Note use of filenames rather than ID values.  This is done */
  541.             /* because FxLnSend, which could be used in the FOD procedure,*/
  542.             /* cannot be given IDs from an FxRxSelect LAN user directory. */
  543.             faxlist = AddToCsvList( FxRxIndexToFax( LREC.!ID ), faxlist )
  544.             flist = flist LREC.!ID
  545.           end
  546.           /* call our FOD procedure to do the faxing */
  547.           FODPARAMS = "FxRxPath( 'LOG' ), VOXDIR, , CALLER, faxlist," ,
  548.             "'As you requested, your received faxes are attached:' flist," ,
  549.             "'Remote fax retrieval...'"
  550.           interpret 'call' "'"||FODPROCEDURE||"'" FODPARAMS
  551.           if result = 'BYEBYE' then signal BYEBYE
  552.           if result = 'OUT' then signal OUT
  553.         end
  554.         iterate
  555.       end
  556.  
  557.  
  558.       if digits = '8' then do            /* 8 = send log */
  559.         call FxLnVout 'Send log'
  560.         call FxLnMsg 'Code Mode command' digits
  561.         call FxLnPlay VOXDIR||'WAIT.WAV'
  562.       if result = 'NOTOK' then signal byebye
  563.         call SendLog
  564.           if result = 'BYEBYE' then signal BYEBYE
  565.           if result = 'OUT' then signal OUT
  566.         iterate
  567.       end
  568.  
  569.  
  570.       if digits = '9' then do            /* 9 = FOD from log */
  571.         call FxLnVout 'FOD from log'
  572.         call FxLnMsg 'Code Mode command' digits
  573.         FODPARAMS = "FxRxPath( 'LOG' ), VOXDIR, , CALLER, , ," ,
  574.                "'FOD Retrieval...'"
  575.         interpret 'call' "'"||FODPROCEDURE||"'" FODPARAMS
  576.           if result = 'BYEBYE' then signal BYEBYE
  577.           if result = 'OUT' then signal OUT
  578.         iterate
  579.       end
  580.  
  581.  
  582.       if digits = '0' then do            /* 0 = back to top level */
  583.         call FxLnVout 'Return to HELLO'
  584.     signal hello
  585.       end
  586.  
  587.  
  588.       if digits = '*' | digits = '#' then do
  589.         signal goodbye
  590.       end
  591.  
  592.  
  593.       /* otherwise, if none were matched... */
  594.       call FxLnVout 'Unknown command' i
  595.       call FxLnPlay 'c:\mmos2\sounds\EEERRUPP.wav'
  596.       iterate
  597.  
  598.     end
  599.   end
  600.  
  601.  
  602. goodbye:
  603.   call FxLnVout 'Exit Code Mode'
  604.   call FxLnPlay VOXDIR||'THANKYOU.WAV'
  605.   call FxLnPlay 'c:\mmos2\sounds\DRUMROLL.wav'
  606.   signal byebye
  607.  
  608.  
  609. evil:
  610.   call FxLnVout 'Bad code entered:' digits 'vs' CODE
  611.   call FxLnPlay 'c:\mmos2\sounds\BOO.wav'
  612.   call FxRxBeep 1318, 1396, 1318, 1090, 1318, 1396, 1318, 1090
  613.   signal byebye
  614.  
  615.  
  616. byebye:                    /* called for error cases */
  617.   LREC.!Status = ''            /* don't log anything */
  618.   signal out
  619.  
  620.  
  621. out:                    /* clean up and quit */
  622.   call FxLnTerm
  623.   exit
  624.  
  625.  
  626. /************************ Procedures ************************/
  627.  
  628.  
  629. GetNumber: procedure
  630.   /* Gets DTMF input until # or * key or "digits" are entered. */
  631.   /* TimeOut is seconds to wait for each digit (default 15).       */
  632.   parse arg digits, TimeOut
  633.   number = ''
  634.   if TimeOut = '' then TimeOut = 15  /* default to 15 seconds */
  635.   do digits
  636.     call FxLnDtmf 1, TimeOut, 'newkey'
  637.       if result <> 'DTMF' | newkey = '#' | newkey = '*' then leave
  638.     number = number||newkey
  639.   end
  640.   return number
  641.  
  642.  
  643. GetExtension: procedure
  644.   /* Gets DTMF input until # or * key or "digits" are entered. */
  645.   /* TimeOut is seconds to wait for first digit (default 15).   */
  646.   /* NextTime is seconds to wait for subsequent digits (default TimeOut)*/
  647.   /* Returns 'FAX' or 'DATA' or 'NOTOK' results or the number. */
  648.   parse arg digits, TimeOut, NextTime
  649.   number = ''
  650.   if TimeOut = '' then TimeOut = 15  /* default to 15 seconds */
  651.   if NextTime = '' then NextTime = TimeOut
  652.   do digits
  653.     call FxLnDtmf 1, TimeOut, 'newkey'
  654.       if result = 'FAX' | result = 'DATA' | result = 'NOTOK' then return result
  655.       if result <> 'DTMF' | newkey = '#' | newkey = '*' then leave
  656.     number = number||newkey
  657.     TimeOut = NextTime
  658.   end
  659.   return number
  660.  
  661.  
  662. TmpFile: procedure
  663.   /* Generate a unique base file name using seconds since midnight */
  664.   return 'TMP'||time( S )
  665.  
  666.  
  667. AddToCsvList: procedure
  668.   /* returns a comma-separated value list with item added */
  669.   parse arg item, list
  670.   if list = ''
  671.     then list = item
  672.     else list = list||','||item
  673.   return list
  674.  
  675.  
  676. SendLog:    /* sends the log file by fax */
  677.   tmp1 = VOXDIR||TmpFile()||'.TXT'
  678.   tmp2 = VOXDIR||TmpFile()||'.FAX'
  679.   log = FxRxPath( 'LOG' )||'fax.log'
  680.  
  681.   call LineOut tmp1, 'Fax Log   ' Date('W') ' '||Date('N') ' ' Time('C')
  682.   call LineOut tmp1, ''
  683.   call LineOut tmp1, ,
  684.        'Type ID      Date    Time  Pg Status Elpsd  Name/RemoteID/CallerID'
  685.   call LineOut tmp1, ''
  686.  
  687.   if LOGMAXLINE <= 0 then do /* send the entire fax log */
  688.     do while Lines( log ) > 0
  689.       record = LineIn( log )        /* read a record from log */
  690.       if FxRxParseLog( record, 'lrec' ) = OK then do
  691.         call LogRpt tmp1
  692.       end
  693.     end
  694.   end
  695.   else do /* send the last x lines from the log */
  696.     head = 1
  697.     tail = 1
  698.     do while Lines( log ) > 0    /* collect last x lines */
  699.       buf.head = LineIn( log )
  700.       head = head + 1
  701.       if head > LOGMAXLINE then head = 1
  702.       if head = tail then tail = tail + 1
  703.       if tail > LOGMAXLINE then tail = 1
  704.     end
  705.     if tail <> head & FxRxParseLog( buf.head, 'lrec' ) = OK then do
  706.       call LogRpt tmp1
  707.     end
  708.     do while tail <> head
  709.       if FxRxParseLog( buf.tail, 'lrec' ) = OK then do
  710.         call LogRpt tmp1
  711.       end
  712.       tail = tail + 1
  713.       if tail > LOGMAXLINE then tail = 1
  714.     end
  715.   end
  716.   rc = LineOut( log )            /* close the files */
  717.   rc = LineOut( tmp1 )
  718.   call FxRxTextToFax tmp1, tmp2        /* convert text to fax */
  719.   /* call our FOD procedure to do the faxing */
  720.   FODPARAMS = "FxRxPath( 'LOG' ), VOXDIR, , CALLER, tmp2," ,
  721.           "'As you requested, the log is attached.', 'Log retrieval...'"
  722.   interpret 'call' "'"||FODPROCEDURE||"'" FODPARAMS
  723.   fodresult = result
  724.   call FxLnVout 'Deleting:' tmp1
  725.   'DEL "'||tmp1||'"'
  726.   call FxLnVout 'Deleting:' tmp2
  727.   'DEL "'||tmp2||'"'
  728.   return fodresult
  729.  
  730.  
  731. LogRpt:
  732.   /* Using global lrec., write a report line to a file */
  733.   parse arg Rfile
  734.  
  735.   if BitTest( lrec.!Flags, 256 ) then mtype = 'MSG'
  736.   else if BitTest( lrec.!Flags, 512 ) then mtype = 'Txt'
  737.   else if BitTest( lrec.!Flags, 1024 ) then mtype = 'Dat'
  738.   else mtype = 'Fax'
  739.  
  740.   if lrec.!Company = ''
  741.   then namestr = lrec.!Name
  742.   else namestr = lrec.!Name||', '||lrec.!Company
  743.  
  744.   if lrec.!Pages = 0
  745.   then pagestr = ''    /* don't show 0 pages */
  746.   else pagestr = lrec.!Pages
  747.       
  748.   call LineOut Rfile, mtype left( lrec.!ID, 6 ) ,
  749.          left( lrec.!Date, 9 ) left( lrec.!Time, 5 ) ,
  750.          right( pagestr, 2 ) left( lrec.!Status, 6 ) ,
  751.          right( lrec.!Elapsed, 5) ' '||strip( left( namestr, 46 ) )
  752.   return
  753.  
  754.  
  755. BitTest: procedure
  756.   /* Given a number and a bit number, return 1 if bit is set */
  757.   parse arg value, bit
  758.   return (value % bit) // 2
  759.  
  760. SaveCode:
  761.   /* Save access code to file ACCESS.COD in user's log directory */
  762.   parse arg newcode
  763.   call LineOut USERDIR||'access.cod', newcode, 1
  764.   call LineOut USERDIR||'access.cod'        /* close file */
  765.   return
  766.  
  767. FetchCode:
  768.   /* Returns the access code for the current USERID */
  769.   newcode = LineIn( USERDIR||'access.cod', 1 )
  770.   call LineOut USERDIR||'access.cod'        /* close file */
  771.   if newcode = '' then newcode = DEFAULTCODE
  772.   return newcode
  773.