home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Fax / AFAX1431.LHA / AmigaFax / REXX / faxdbase.rexx next >
Encoding:
OS/2 REXX Batch file  |  1995-07-14  |  2.6 KB  |  135 lines

  1. /* faxdbase.rexx
  2.  *
  3.  * D.Varley 14JUL95
  4.  * Example faxing from database list, written for John Block
  5.  * This uses code from other examples, could call as functions,
  6.  * but code placed inline for example.
  7.  * His database format is:
  8.  *   firstname lastname
  9.  *   blank
  10.  *   number
  11.  *   blank
  12.  * etc
  13.  */
  14.  
  15. /* Change these variables as required */
  16.  
  17. dbname = "dbase.txt"    /* Your database text file */
  18. fxinc  = "t:file.afx"    /* Your precompiled fax file, etc */
  19. from   = "786530"    /* Your own number */
  20. resol  = "Fine:"    /* Fax resolution */
  21. retries = 3        /* Times to retry sending */
  22.  
  23. /* These should be ok as is... */
  24.  
  25. fxtmp  = "t:fxtmp"    /* Temporary fax text file */
  26.  
  27. /* Open database file */
  28.  
  29. if ~open(fi,dbname,R) then do
  30.     say "Can't open " || dbname
  31.     exit
  32.     end
  33.  
  34. /* Loop through all entries, building faxes and spool files */
  35.  
  36. do while ~eof(fi)
  37.  
  38.     /* Read in a data record
  39.      * Note that this area should be changed according to
  40.      * your data format.
  41.      */
  42.  
  43.     name = strip(readln(fi))    /* Name */
  44.     dummy = readln(fi)        /* Blank line */
  45.     number = strip(readln(fi))    /* Number */
  46.     dummy = readln(fi)        /* Blank line */
  47.  
  48.     if name = "" then exit
  49.  
  50.     /* open fax header file */
  51.  
  52.     if ~open(fo,fxtmp,'W') then do
  53.         say "Can't open " || fxtmp
  54.         exit
  55.         end
  56.  
  57.     /* Write fax text file */
  58.  
  59.     writeln(fo,".FCOM")
  60.  
  61.     /* Write include for you address, etc here */
  62.  
  63.     parse var name first last
  64.  
  65.     s =  "Attention: " || name
  66.     writeln(fo,s)
  67.     writeln(fo,"")
  68.  
  69.     /* If first name > 1 letter, write "Dear name,"
  70.      * else assume initial, write "Dear Sir"
  71.      */
  72.  
  73.     if length(first) > 1 then do
  74.         s = "Dear " || first || ","
  75.         end
  76.     else do
  77.         s =  "Dear Sir,"
  78.         end
  79.     writeln(fo,s)
  80.     writeln(fo,".INC " || fxinc)
  81.     close(fo)
  82.  
  83.  
  84.     /* Get Fax-file name */
  85.  
  86.     sfnum = 0;
  87.     do sfnum = 0 to 1000
  88.         ffname = "FAXSPOOL:S_"||sfnum||".AFX"
  89.         if ~exists(ffname) then leave
  90.         if sfnum >= 999 then do
  91.             say "Error: Can't get fax file"
  92.             exit(999)
  93.         end
  94.     end
  95.  
  96.     /* Build the fax file */
  97.  
  98.     address command "afax:c/mkafax " || fxtmp || " " || ffname
  99.  
  100.     /* Get spool-file name */
  101.  
  102.     sfnum = 0;
  103.     do sfnum = 0 to 1000
  104.         sfname = "FAXSPOOL:F_"||sfnum||".SPL"
  105.         if ~exists(sfname) then leave
  106.         if sfnum >= 999 then do
  107.             say "Error: Can't get spool file"
  108.             exit(999)
  109.         end
  110.     end
  111.  
  112.     /* Write the spool file */
  113.  
  114.     if ~open('sfile', sfname, 'W') then do
  115.         say "Error: Can't open "||sfname
  116.         exit
  117.         end
  118.  
  119.     writeln('sfile', "From: "||from)      
  120.     writeln('sfile', "To: "||number)        
  121.     writeln('sfile', "Source: No File")   
  122.     writeln('sfile', "Fax: "||ffname)       
  123.     writeln('sfile',  resol)               
  124.     writeln('sfile', "Retries: "||retries)
  125.  
  126.     close('sfile')
  127.  
  128.     say ffname||" Spooled to "||number||" using Spool File "||sfname
  129. end
  130.  
  131. say "All Done !"
  132. say "Make sure spooler is running."
  133.  
  134.  
  135.