The FXTXTSCAN process scans a nominated folder for text files deposited there by a customer-supplied program, extracts the fax number and other variables from the text, and generates an FS file to fax the ASCII document or another nominated document.  To allow customization of the text extraction, the fields to extract can be specified using 'regular expressions' to match patterns in the text file.  Some useful information about regular expressions can be found at http://www.regular-expressions.info.

The setup screen for this process selects the folder to be scanned and the USR file which will be used to send the document.

The file extension scanned for defaults to .TXT.  However you can specify another extension by using an environment variable FX_TEXT_EXT to specify the extension (with initial '.').

The USR file should include FS template items on $fs_template commands.  These commands, and USR $var_def commands are scanned for a substring REGEX: followed by a regular expression, all  in double-quotes.  The regular expression must create a subexpression (backreference) using either the special names FAXNUM or EMAILTO (which specify the destination and also cause the text file itself to be included in the message) or the special name ROUTETO (which specifies the receiver name) or any other name which must match the variable name with which the regular expression is associated.

The commands scanned are:

The regular expression on a $fax_phone command is assumed to produce a named subexpression (backreference) with name FAXNUM. In this case the text file will be used as the file to be faxed, unless an ASCII_TEMPLATE variable definition is present in the USR file, in which case the file is converted to TIF (without any variable expansion) using the nominated ASCII_TEMPLATE file.  An example of a regular expression might be:

 

    $fs_template $fax_phone "REGEX:^ *FAX# (?<FAXNUM>(?:\d|-|\+|\(|\)| )*)"

The regular expression on a $email_address command is assumed to produce a named subexpression (backreference) with name EMAILTO.  In this case the text file will be the e-mail body.

The regular expression on a $fax_receiver command is assumed to produce a named subexpression (backreference) with name ROUTETO.  For example:

 

    $fs_template $fax_receiver "REGEX:TO\: *(?:ATTN )?(?<ROUTETO>.*(?= FROM))"

The regular expression on a $var_def command is assumed to produce a named subexpression (backreference) which must have a name which is the same as the variable name: For example:

 

    $var_def SENDTO "REGEX:TO\: *(?:ATTN )?(?<SENDTO>.*(?= FROM))"

The regular expression is used to scan the whole multi-line text file and the ^ and $ symbols can be used to indicate the start and end of a line rather than the start and end of the text. Leading and trailing spaces are trimmed from the resulting value before it replaces the REGEX: expression on the command placed in the FS file.

As the FS file is created the text file is moved to the CALLBACK\TEMP folder (with the converted TIF file if applicable), from which it will be referenced in the FS file.  You should arrange to delete these files at intervals, for example using the CFHK utility.

If you do not require the text file itself to be faxed or e-mailed, do not use the FAXNUM regular expression on the $fax_phone template item or the EMAILTO regular expression on the $email_address template item.  Instead use a normal variable and a regular expression with a different name, for example:

$var_def FAXPHONE "REGEX: .... (?<FAXPHONE> .... )"

$fs_template $fax_phone @FAXPHONE

A variable named SCAN_PATH is always added to the FS, containing the name of the folder which is scanned for text files.  This can be used to locate an attachment file which is placed in the scanned folder alongside the text file.  If this variable is used on a $fax_filename or $email_attach command, the file is moved to CALLBACK\TEMP and the command is adjusted to reference the new pathname.  Only CFG variables and variables extracted from regular expressions are expanded on this command.  For example:

$var_def PDFFILE "REGEX: .... (?<PDFFILE> ....)"

$fs_template $fax_filename "@SCAN_PATH\@PDFFILE"

might become in the resulting FS file:

$var_def PDFFILE "123456.PDF"

$fax_filename "@FFREQ\TEMP\123456.PDF"

The FS file is written to the specified TOSEND folder, unless the USR file contains an $fs_template $fax_pre-process command, in which case the FS file is written to PREPROC.