home *** CD-ROM | disk | FTP | other *** search
-
- SCRIPT TestFAX; (* demonstrate script access to FAX server *)
-
- VAR fax_server : Number;
- NumberToDial : String;
-
- (*.................................................*)
-
- FUNC SendLiteralMessage(hDLL:Number; msg,cmd:String; num:Number):Number;
- BEGIN
- RETURN SendMessage(fax_server,msg,cmd,num);
- END;
-
- (*.................................................*)
-
- PROC test1();
- /* demonstrates changing one of the FAX server variables. SAVE-SETTINGS
- makes the change permanent, otherwise it would be lost when you send
- the END-SESSION message.
- */
- BEGIN
- SendLiteralMessage(fax_server,"SET-OREF","my reference",0);
- SendLiteralMessage(fax_server,"SAVE-SETTINGS","",0);
- END;
-
- (*.................................................*)
-
- PROC test2(cover_sheet:Flag; Fn:String; Phone:String);
- /* demonstrates actually sending a FAX.
- */
- VAR imported_name:String;
- rslt:Number;
-
- BEGIN
- /* the source file must be converted to FAX image first. This isn't
- * done transparantly by SEND because conversion is a relatively
- * slow task, and if you want to send the same FAX to multiple
- * destinations a lot of time can be saved doing it this way.
- * The IMPORT message takes care of the conversion.
- */
-
- /* SET-DETAIL and SET-REFORMAT control variables used in the conversion
- * process, so these messages must be sent before using the IMPORT
- * command, if you don't want to use the options set up in the FAX
- * server menu.
- */
- /* assume normal resolution FAX */
- SendLiteralMessage(fax_server, "SET-DETAIL", "", 0);
- /* assume no text reformatting */
- SendLiteralMessage(fax_server, "SET-REFORMAT", "", 0);
-
- imported_name := Fn;
- IF SendMessage(fax_server, "IMPORT", imported_name, 0)<>0 THEN
- /* note that IMPORT returns the name of the newly created FAX
- * file in the string argument of the message.
- */
- RETURN;
- END;
-
- /* tell the FAX server which file to send, and which number to dial. */
- SendMessage(fax_server, "SET-FILETOSEND", imported_name, 0);
- SendMessage(fax_server, "SET-NUMBER", Phone, 0);
-
- /* Ok, now that the FAX conversion is done, do we want to include
- * a cover sheet? Supply the FAX server with the details if so.
- */
- IF cover_sheet THEN /* if the user wants a cover sheet added */
- /* in real life, you could read cover sheet info from a file */
- SendLiteralMessage(fax_server, "SET-COVERSHEET", "", 1);
- SendLiteralMessage(fax_server, "SET-FROM", "me", 0);
- SendLiteralMessage(fax_server, "SET-TO", "your company", 0);
- SendLiteralMessage(fax_server, "SET-ATTN", "you", 0);
- SendLiteralMessage(fax_server, "SET-OREF", "our reference", 0);
- SendLiteralMessage(fax_server, "SET-YREF", "your reference", 0);
- SendLiteralMessage(fax_server, "SET-SUBJECT", "testing the FAX server!", 0);
- ELSE
- /* tell FAX server to disable cover sheet generation. */
- SendLiteralMessage(fax_server, "SET-COVERSHEET", "", 0);
- END;
-
- /* Ok, we've converted the input file to FAX format, we've generated
- * the cover sheet... anything left to do? Ah yes - better send the
- * FAX!
- */
- rslt := SendLiteralMessage(fax_server, "SEND", "", 0);
-
- IF rslt=0 THEN
- Write("FAX was sent OK.|");
- ELSE
- Write("FAX server reported error ",rslt,".|");
- END;
- END;
-
- (*.................................................*)
-
- PROC test3(fax_name:String);
- /* demonstrates printing a received FAX.
- */
- BEGIN
- /* print pages 1-99 */
- SendLiteralMessage(fax_server, "PRINT", fax_name+" 1-99", 0);
- END;
-
- (*.................................................*)
-
- PROC test4();
- /* demonstrates receiving a FAX.
- */
- VAR ring:Number;
- fax_name:String;
- rslt:Number;
- Done:Flag;
-
- BEGIN
- /* It is up to the receiving script to recognise when there might be
- * an incoming call. It is NOT normal for you to enable auto-answer
- * mode to handle this. Instead you should look for the "RING"
- * response sent by Hayes compatible modems. Normally you would use
- * the script WatchFor() feature for that, polling Received()
- * for it throughout your script. For the purpose of this demo
- * it is all handled here in a tight loop.
- */
-
- Done := FALSE;
- Write("Waiting for a call...");
- ring := WatchFor("RING");
- REPEAT
- IF Received(ring) THEN
- Write("|");
- /* ok, phone is ringing - better answer it! */
- rslt := SendMessage(fax_server, "RECEIVE", fax_name, 0);
- Done := TRUE;
- WatchAgain(ring); /* reset received flag */
- END;
- UNTIL Done; /* this demo stops after receiving one FAX. */
-
- ClrWatch(ring); /* for the demo, we won't need this WatchFor again. */
-
- /* if a fax is received, its name will have been placed in the
- * "fax_name" string argument to the RECEIVE message. If the FAX is
- * ok then why not print it now?
- */
- IF rslt=0 THEN /* if FAX ok */
- Write("FAX ",fax_name," received OK.|");
- test3(fax_name); /* print fax */
- ELSE
- Write("FAX receive error ",rslt,".|");
- END;
- END;
-
- (*.................................................*)
-
- PROC test5(fax_name,img_name:String);
- /* demonstrates exporting a FAX to TIFF or PCX format. The output format
- * is controlled by the extension used in img_name (ie. .PCX for PCX
- * files, .TIF for TIFF files).
- */
- BEGIN
- /* export pages 1-99 */
- SendLiteralMessage(fax_server, "EXPORT",
- fax_name+" "+img_name+" 1-99",
- 0);
- END;
-
- (*.................................................*)
-
- BEGIN
- /* the FAX Server .DLL is the biggest Odyssey DLL so far, so in order
- * to give it plenty of room you should unload any fancy terminal
- * emulations etc. You don't need them for FAXing anyway.
- */
- Emulate("TTY"); /* load the simplest terminal possible */
-
- /* Now load the FAX server DLL - if it exists!
- */
- fax_server := LoadDLL("FAXSERV.DLL");
- IF fax_server<16 THEN
- Write("Could not find FAXSERV.DLL in the Odyssey directory!|");
- Write("Error code was: ",fax_server,"|");
- ELSE
- SendLiteralMessage(fax_server,"INIT","",0); (* always do this *)
-
- /* uncomment one of the tests below */
-
- /*
- Test1(); /* setting a FAX server variable */
- */
-
- NumberToDial := "0123-456789";
- IF NumberToDial="0123-456789" THEN
- (* user hasn't modified the phone number *)
- Write("|The TESTFAX script has a statement on line 189 which sets the FAX number|");
- Write("to dial for this test. Please modify that line before trying this script|");
- Write("again.||");
- ELSE
- Test2(TRUE, "testfax.scr", NumberToDial); /* sending a fax */
- END;
-
- /*
- Test3("faxrecv\test.fax"); /* printing a FAX */
- */
-
- /*
- Test4(); /* receive a fax */
- */
-
- /*
- Test5("faxrecv\test.fax","test.tif"); /* export to .TIF */
- Test5("faxrecv\test.fax","test.pcx"); /* .....or .PCX */
- */
-
- SendLiteralMessage(fax_server,"END-SESSION","",0); (* always do this *)
- fax_server := UnLoadDLL(fax_server); (* and this too *)
- END;
- END;
-
-