Faxing from Alpha Five Version 5 using Winfax and DDE
by Russ Boehle
Many businesses today rely on faxing to move data back and forth. Faxing is a relatively old technology, but many find it much more reliable than email. If your fax program indicates that a fax has been successfully transmitted, you can be reasonably sure that it has been printed out on the recipients fax machine. Email on the other hand is subject to often numerous mail servers and people who often do not check their email. Emails sometimes do not arrive at their destination and there is no realtime feedback that they have not arrived.
There have been frequent requests for faxing capabilities to be integrated into Alpha Five and this will probably be added in a future release. The information contained here will allow you to fax now. I am sure that if Alpha Software writes a faxing routine in the future it will be better and easier.
I have set up a routine for faxing from Alpha Five using dynamic data exchange (DDE) with Winfax. Winfax is the most popular faxing software currently available. It is inexpensive and networkable. If you do a search on a shopping site, such as Pricewatch.com, you will see that a number of vendors are selling Winfax very inexpensively. You will need Winfax Pro10.02. Do not use version 10.00 as it is buggy. Version 10.02 is buggy also, but less so. Winfax can be installed on one machine that acts as a fax server and can control a maximum of 2 modems, or it can be installed on a standalone machine. The workstations that will fax through the server are set up as clients. Two modems on a server can handle a lot of faxes and will be sufficient for many smaller organizations. The Winfax documentation thoroughly explains how to set this up so I won't repeat it here. One word of advice though, don't use Winmodems, software controlled modems, with Winfax. You WILL have problems. I use US Robotics 5610B modems. I am sure that there are others that work with Winfax but these are hardware modems and have been very effective for me. (If you use the 5610B’s be sure to download the latest firmware)
In this article I will show the steps to successfully fax from Alpha Five using a fax number and name taken from a form. All of this can be done with action scripting, except for the script that actually activates Winfax. You can download the tables, forms, and scripts used here from the Alpha Software website Code Library.
The first screen shot shows a table called Co_Info. I use this table to store company information that doesn't change, such as your company's name and address, and in this case, the default text that will go on the fax cover page. You can set up multiple fields if you use faxing for purchase orders or quotes or invoices etc. You will have to modify the FAX_DDE script however for each new field. The Co_Info table can either be linked in a set (using the link field) to the table containing the form that you will be faxing from or you can put all the field values in Co_info into variables with an autoexec script that runs when you start Alpha Five. The text in this field does not normally change.
The second screen shot shows the Fax_Test_Form. This is the form that is faxed when you press the Button "Set Vbls Send Fax". This form is based on the Fax_test_set.set. In actual use you would probably put the faxing button on a form where you had entered data that you wanted to send to someone, this form is for testing only. The name field is the name of the person that the fax is being set to. This field will be put on the Fax cover page, if there is one, and also on the header of the fax itself. The title, address, and state fields are not used in this example and are not relevant to this exercise. The faxno field will hold the fax number that is to be faxed to. I normally set up Winfax to "Dial as entered". If it is set up this way you will want to put in exactly the digits that you want the phone to dial, including a "1" if necessary. You will see a place in the FAX_DDE code where you can manipulate the faxno string if necessary to add a "1" but I am not using that here.
Pressing the Print button will print the report "Fax_Test" to a printer or allow you to preview it. You could select the Winfax driver from the printer selection box and then select a recipient or enter a phone number manually and then send the fax. This is time consuming and prone to error but you can try it to see that the result is exactly the same as activating Winfax using Alpha Five and DDE.
The radio button field allows you to select the cover page as None, Default, or Custom. If none is selected, then the report is faxed without a cover page. If Default is selected, then the Default message is inserted into the Cover Page that has been selected as the default in the Winfax Pro setup. If Custom is selected, then the message that is typed in the memo field is inserted into the default Cover Page. The optional cover message is a normal memo field but could also be a character field if you don't need much field length. This field however cannot be a rich text memo field as Winfax will not accept RTF text.
The above screen shot shows the on push events for the Faxing button. First it "sets variables to field values - fields on a form". This sets the variable vname to the name on the form and vfaxno to the faxno on the form. Shown below is a screen shot of the Action Scripting Genie showning where the form fields Faxno and Name are set to the global variables vFaxno and vName.
Once these variables are set then the Fax button Action Script plays the FAX_DDE script which is shown later. The FAX_DDE script puts the information in these variables into Winfax through DDE and faxes the report "Fax_Test" to the recipient. In this case I have set up the report record selection to print the records defined by current(recno())=recno() as shown below.
This will only print the current record. If the report you are printing is to print some other selection of records you can run a query using Action Scripting and put that on the Fax button before the script FAX_DDE is run. The report will then print with the order and filter that you have selected.
Additional criteria should be set to none.
In the report setup select Winfax as the printer for this report.
This is the FAX_DDE script. It is pretty much over commented but I will add a few more comments anyway. Note that there is no error checking in this script. You may want to add it depending on how you apply the script.
'Here the report name and cover message are dimmed for later use.
dim vreport_name as c
dim vcover_message as c '"0" No coverpage, "1" use default message from
'coinfo table, "2" use message from memo field
'This select is based on the radio button on the form which has 3 possible values, 0,1,2.
'Select cover page message
select
case topparent:What_cov_mess.value = "0"
vcover_message = " "
case topparent:What_cov_mess.value = "1"
vcover_message = topparent:Fax_cover_txt.value
case topparent:What_cov_mess.value = "2"
vcover_message = topparent:Cover_mess.value
end select
' In the poke part of this where there are 3 commas (,,,) you can add values for time
'to schedule send job and a persons name. The vname could represent Company
'if you need it.
'This takes the fax number and removes any characters that are not numbers from it.
vfaxno = remspecial(vfaxno)
'see if the number is 7 or 10 digits, if 10 put a 1 before it
'If Winfax is setup as "Dial as entered" this is not necessary
'if len(vfaxno) > 7 then
' vfaxno = vfaxno
' else
'if len(vfaxno)=10
' vfaxno = "1"+vfaxno
'end if
'Note that the report name has an underscore in it. Winfax will NOT read this
'the same as fax test with a space.
'Note that in this case I have hard coded the report name in.
'This also could be derived from a listbox 'or various other methods.
'You could also us a label definition here.
vreport_name="fax_test"
channel = dde_initiate("FAXMNG32", "CONTROL")
'The goidle command stops Winfax from doing anything while you are trying
'to send it a fax job.
dde_execute(channel, "GoIdle")
dde_terminate(channel)
channel = dde_initiate("FAXMNG", "TRANSMIT")
'If you have specified no cover page, skip over the cover page poke.
if topparent:What_cov_mess.value = "0"
goto Nocover
else
goto cover
end if
Cover:
'This takes whatever you have selected for cover page text and puts it into the
'default cover page as defined in the Winfax setup.
'Below is the input for the coverpage
dde_poke(channel, "Sendfax", "fillcoverpage(\""+vcover_message+"\")")
Nocover:
'Here we take the fax number and recipient variables and put them into the poke.
'Below is the input for faxno and recipient name
dde_poke(channel, "SendFax", "recipient(\""+var->vfaxno+"\",,,\""+var->vname+"\")")
'This just shows the Syntax for this poke, thanks to Selwyn
'dde_poke(channel, "SendFax", "recipient(\""+fax_no+"\",,,\""+name+"\")")
'Code below sets the coverpage, you must enter the full path or can
'use a listbox for user selection.
'If you don't want to use the default cover page you can put in
'some other cover page path to use it.
'This is optional.
'dde_poke(channel, "Sendfax", "setcoverpage(\""+"C:\winfax\cover\covername.cvp"+"\")")
'This was not tested but I assume options are 0 or 1 to show or not show.
'Here you can optionally select whether to show the send screen.
'This can also be selected from the
'Winfax setup options which is easier.
'dde_poke(channel, "Sendfax", "showsendscreen(\""+"0"+"\")")
'This also not tested but will set resolution to HIGH or LOW
'dde_poke(channel, "Sendfax", "resolution(\""+"HIGH"+"\")")
'This prints the report put into the variable previously
print_report(vreport_name)
'You could print a letter (or label) by using this instead of report.
'print_letter(letter_name )
dde_terminate(channel)
'Active Mode - Winfax controller will start if not already running
'Sends the fax and terminates DDE
channel = dde_initiate("FAXMNG", "CONTROL")
'Now we activate Winfax again, and it will fax whatever we have entered above.
dde_execute(channel, "GoActive")
dde_terminate(channel)
Shown below is the same script with everything that is not essential removed, assuming that the variables are set externally and "What_cov_mess_value" is set to 0, 1, or 2 externally. If you never want or always want a cover page the whole section dealing with cover pages can also be eliminated.
'Set externally
'Vreport
'vcover_message
'Vreport_Name
'what_cov_mess.value (you can use a variable here also)
select
case topparent:What_cov_mess.value = "0"
vcover_message = " "
case topparent:What_cov_mess.value = "1"
vcover_message = topparent:Fax_cover_txt.value
case topparent:What_cov_mess.value = "2"
vcover_message = topparent:Cover_mess.value
end select
channel = dde_initiate("FAXMNG32", "CONTROL")
dde_execute(channel, "GoIdle")
dde_terminate(channel)
channel = dde_initiate("FAXMNG", "TRANSMIT")
if topparent:What_cov_mess.value = "0"
goto Nocover
else
goto cover
end if
Cover:
dde_poke(channel, "Sendfax", "fillcoverpage(\""+vcover_message+"\")")
Nocover:
dde_poke(channel, "SendFax", "recipient(\""+var->vfaxno+"\",,,\""+var->vname+"\")")
print_report(vreport_name)
dde_terminate(channel)
channel = dde_initiate("FAXMNG", "CONTROL")
dde_execute(channel, "GoActive")
dde_terminate(channel)
That's all there is to it. The techniques shown here can be used to fax a report, letter or label from anywhere in Alpha Five with minor modifications to this procedure. Essentially the whole process can be boiled down setting 4 variables and running the script. The procedure is the same whether you are running Winfax locally or are set up for network faxing. The faxes that you send are recorded in the users Winfax outbox along with the status as shown below.
Successfully sent faxes are indicated with a check mark, faxes that fail have a red X as shown. Winfax will also keep a copy of all faxes sent if you want this and have the disk space.
This procedure will not replace an Alpha add in, which hopefully is coming in the future, and will have a lot more flexibility, but it will allow faxing until the real thing arrives. This can also be done with object linking and embedding which is more powerful. I haven't had the time to investigate this approach.
Russ Boehle is president of NESSteel Inc., a specialty steel distributor and processor headquartered in Stafford Springs, CT. One of his passions is Alpha database software which he has been using since Alpha Four version 2. NESSteel currently runs on Alpha Four versoin 6 but Russ is working, as time permits, to migrate to Alpha Five Version 5. With no formal training in computers, Russ is self taught, starting with an old IBM PS2-30 which incidentally came with no operating system installed. His college training in engineering was before personal computers. Aware that he needed to computerize his business, and finding that what was commercially available was not very good, Russ tried various database programs and found that Alpha Four was perfect for him and his business.
You can reach Russ at russcb@earthlink.net
[PRINTER FRIENDLY VERSION]
|