DOCUMENT #765
===========================================================================
FAX from an R:BASE application
===========================================================================
PRODUCT: R:BASE VERSION : 3.1 or higher
===========================================================================
CATALOG: General Information AREA : General Information
===========================================================================
An increasingly important piece of customer information stored in many
databases today is the customer's FAX phone number. You can use this data
to automatically send FAXes from your R:BASE application. You can FAX to
one person or to hundreds of people at once, FAX the same article or
different articles, and continuously poll the database and send documents
as your sales staff request them.
If your computer has a modem installed, you may have the ability to send
FAXes as part of the modem software. Check the documentation that came with
your modem. There are also separate FAX boards that can be purchased. The
FAX software you use determines the options and how you send the FAX. The
general procedure is to use R:BASE to create a transmission file or data
for the FAX software, then use the R:BASE ZIP command to invoke the FAX
software and transmit the FAX. You need to send the FAX software at the
least, the name of the file to transmit and the FAX phone number.
For example, the GammaFAX software that we use accepts a filename that
contains a series of GammaFAX commands. The file has RETRY 2 to tell it to
try and send the FAX a second time if it can't connect, the keyword SEND
followed by the filename or list of files to transmit, and the keyword DIAL
followed by the FAX phone number. Depending on how the number is stored in
your database and the requirements of your FAX software, you may need to
append "91" to the beginning of the number. The "9" is if your phone system
requires that for an outside line, the "1" is for long distance. Your FAX
software will also specify how the phone number is sent -- as a continuous
stream of numbers or separated by spaces or dashes-- 2067469350 or
206 746 9350 or 206-746-9350.
The ExpressFax software that is part of the MTEZ communications software
included with Zoomfaxmodem sends faxes using the CASSEND utility. The
CASSEND utility requires the filename and the phone number as command
line parameters. It does not use a transmission file, but expects the
data on the command line. Your FAX software determines how you configure
your application.
Generally, you can FAX ASCII text files or graphic image files. The graphic
files are usually sent as a cover page or for sending on letterhead. Again,
the FAX software you use determines the customization you can do.
ExpressFax, for example, lets you specify a graphics file for the cover
page and has options for specifying letterhead and signature files.
Alternatively, an R:BASE report can be used to generate a cover page that
has the name and address of the person receiving the FAX on it. The
document transmitted can be an ASCII file created by a word processor or
it can be the output from an R:BASE report or SELECT command. The file
names include a drive and directory specification to explicitly locate the
file if necessary.
Depending on your operating system, the application can run in the
background, it can be left running on another computer to continuously
poll the database and send faxes, it can be a menu choice to FAX as
requested or it can be set up to do batch sending of faxes.
Batch send
Some FAX software sends to a group of people from an ASCII delimited file.
For example, ExpressFax reads a file in the following format:
"John Smith","Consolidated Computers","206 746 9350"
You can easily generate an ASCII delimited file like this in R:BASE. You
can do it using a report, using the SELECT or UNLOAD command, or using the
Import/export utility (FileGateway). Once the file has been generated, call
up your FAX software with this file name and the file name of the document
to transmit. See the article "Working with ASCII Files" in this issue of
the Exchange for more information on creating delimited ASCII files.
In an R:BASE application, to send the same file to a group of people, use
DECLARE CURSOR to move through the list one by one, creating the
transmission file or data and sending FAXes individually. Here's an example
of code you might use.
DECLARE C1 CURSOR FOR SELECT custid, company, faxphone FROM customer +
WHERE send='Y'
OPEN C1
FETCH C1 INTO VCustid ind1, VCompany ind2, VFaxPhone ind3
WHILE SQLCODE <> 100 THEN
--create the transmission file FOR GammaFAX
SET V VSendFile = ('C:\FAXLIB\Cover.txt' & 'C:\FAXLIB\MarSpec.txt')
SET V VNumToDial = ('DIAL 91'+.VFaxPhone)
OUT faxsend.dat
WRITE 'RETRY 2'
WRITE 'SEND' .VSendFile
WRITE .VNumToDial
OUT SCREEN
-- execute the FAX software with the transmission file
ZIP GCL faxsend.dat
-- set up command line parameters for ExpressFax
-- to send the parametres correctly, place everything in one variable
SET V VSend = ('ZIP CASSEND' & 'C:\FAXLIB\MarSpec.txt' & .VFaxPhone)
-- execute the FAX software with the transmission data
&VSend
-- get the next customer
FETCH C1 INTO VCustid ind1, VCompany ind2, VFaxPhone ind3
ENDWH
You can add prompts to your application to request the file to send or to
specify the group of people to send to.
Poll database for requests
At Microrim, our sales department application has an option for a
salesperson to request a FAX to be sent to a specific customer. A
separate machine is set up to continuously poll the database looking for
FAX requests. As it finds one, it sends the requested FAX, marks it sent
and keeps looking. A library of documents is stored on the network. The
salesperson records the customer ID number, and a document number to be
sent. The application retrieves the customer address and FAX phone number,
and full file name for the document. Using this data it creates a
transmission file like for a batch send, and FAXes the document.
Excerpts from the program we use are shown below (most of the error
checking has been removed for readability and space considerations). They
show how the database is queried, creating and sending the transmission
file. Unique file names are created and each request is sent individually.
*( TSFaxIt.CMD
*
* Copyright (c) Microrim, Inc. 1992, 1993. All rights reserved.
* Description: This command file is used for the automated FAX
* system for the Telesales group. They insert
* records into the table FAXRequests while using
* their app. This command file polls that table
* periodically and extracts records that have not
* been sent. It takes the info and runs the GLC
* utility from GammaFax.
*
* Inputs: None.
*)
SET LINES = 0
SET ERROR VAR PErrVar
-- Ensure that this utility is pointing to the appropriate directory
-- on the C: drive.
C:
CD \FAXLIB
F:
-- Stay in the loop and keep polling
LABEL TopPoll
-- Write the instructions on how to exit from the polling loop
SET V VAbortMsg = (CTR('Hit [ESC] [ESC] to abort FAX processing',60))
CLS FROM 2,1 TO 2,80 BLACK
WRI .VAbortMsg AT 2 10 LIGHT CYAN ON BLACK
-- Check for the lastkey, looking for a Esc
IF (CHKKEY(0)) = 1 THEN
IF (GETKEY(0)) = '[ESC]' THEN
BEEP
PAU 2 USI 'Aborting FAX processing'
GOTO ExitRout
ENDI
ENDI
-- CHECK THE FaxRequests TABLE
-- Use the SELECT INTO statement to see if there are fax reqs pending
CLE V I%
SET V VCheckTime = .#TIME
WRI 'Checking for pending FAXes at ' .VCheckTime .#DATE
SELECT CustId, FaxItem#, FREmployee#, RequestDate INTO +
VCustId ICustId, +
VFaxItem# IFaxItem#, +
VFREmployee# IFREmployee#, +
VRequestDate IRequestDate +
FROM FaxRequests WHERE RequestDate = .#DATE AND
FaxDate IS NULL AND LIMIT = 1
-- Get the company name information
SELECT CCompany, CFrstNm, CLstNm INTO +
VCompany ICompany, +
VFrstNm IFrstNm, +
VLstNm ILstNm +
FROM Customer WHERE CustId = .VCustId
-- Now get the employee's name
SELECT EFrstNm, ELstNm INTO +
VEFrstNm IEFrstNm, +
VELstNm IELstNm +
FROM Employees WHERE Employee# = .VFREmployee#
-- Start by generating the cover sheet.
-- Create a unique file name for this request's cover
SET V VTCustId = (CTXT(.VCustId)), +
VTFREmployee# = (CTXT(.VFREmployee#)), +
VFileExt = ('.'+.VTFREmployee#), +
VCoverPage = ('C:C'+.VTCustId + .VFileExt), +
VReqFile = ('C:R'+.VTCustId + .VFileExt), +
-- Output to the fax cover sheet file named above then print cover
OUT .VCoverPage
PRI FaxCover WHERE CustId = .VCustId AND RequestDate = .#DATE AND +
FaxDate IS NULL
OUT SCR
OUT .VReqFile
PRINT FaxReqIn WHERE CustId = .VCustId AND RequestDate = .#DATE +
AND FaxDate IS NULL
OUT SCR
-- the FaxReqIn report is set up like this:
-- variables are defined to specify the files to send
-- vfaxfile = faxfile in faxitems where faxitem#=.vfaxitem#
-- vfilelist = (.vcoverpage & .vfaxfile)
-- everything is located on report footer lines
-- RF RETRY 2
-- RF SEND <.vfilelist> locate the variable with the list of files to send
-- RF DIAL 91 locate the FAX phone number column
-- Now, zip to the Gamma Fax GCL utility providing the name of the
-- request file.
ZIP GCL .VReqFile
SET V VSavErr = .PErrVar
-- If the error var is not zero then exit
IF .VSavErr <> 0 THEN
BEEP
PAU 2 USI 'ERROR in running the GCL utility!'
GOTO ExitRout
ENDI
-- Finally, update the FaxRequests Table with today's date
-- to indicate that it has been sent
UPDATE FaxRequests SET FaxDate = .#DATE WHERE CustId = .VCustId +
AND RequestDate = .#DATE AND FaxDate IS NULL
SET V VSavErr = .PErrVar
IF VSavErr <> 0 THEN
BEEP
PAU 2 USI 'Error in UPDATE command'
GOTO ExitRout
ENDI
-- Pause for 40 seconds to let GammaFAX have a little CPU time
--PAU FOR 40 USI 'Pausing to give Queue manager time to process'
GOTO TopPoll
LABEL ExitRout
RET
GammaFAX is a trademark of and available from Gamma Link, 1314 Chesapeake
Terrace, Sunnyvale, CA 94089, 408-744-1400
ExpressFax is a trademark of and available from WordPerfect Corp., 1555 N.
Technology Way, MS K1369, Orem, UT 84057-2399, 801-451-5151