home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol110 / wsfile.acg < prev    next >
Encoding:
Text File  |  1984-04-29  |  3.8 KB  |  158 lines

  1.  
  2. * wsfile.cmd  03/14/83 hmvt      
  3.  
  4. * this program will take data from the main data base
  5. * it will select the proper mailing address
  6. * depending upon if the letter is to go to office or home
  7. * then it will write the Wordstar Data file and a DOC file,
  8. * which should be placed at the start of the document to be merged.
  9. * in those cases where an item may not appear, on the merged document
  10. * (titleline, company1, company2) use &titleline/O&, &company1/O& and
  11. * &company2/O&. This file automatically creates a ',' for omit data
  12. * per mailmerge requirements.
  13.  
  14. ERASE
  15. ?'This Module will make a special MailMerge file for WordStar'
  16. ?
  17. ?' Do you wish to continue (Y/N) ? '
  18.  
  19. SET CONSOLE OFF
  20. WAIT TO command
  21. SET CONSOLE ON
  22.  
  23. IF command = 'Y' .OR. command = 'y' 
  24.   STORE t TO continue
  25. ELSE
  26.   STORE f TO continue
  27. ENDIF
  28.  
  29. DO WHILE continue
  30.  
  31. ERASE
  32. ACCEPT 'Enter Name of the WordStar-MailMerge file  ' TO file:dat
  33.  
  34. * make the proper WordStar file names
  35. STORE !(file:dat) TO file:dat
  36. STORE $(file:dat,1,8) TO file:dat
  37. STORE file:dat+'.DOC'  TO file:doc
  38. STORE file:dat+'.DAT'  TO file:dat
  39.  
  40. @ 03,10 SAY  'Creating WordStar-MailMerge Document file:  '+file:doc
  41. SET CONSOLE OFF
  42. SET ALTERNATE TO &file:doc
  43. SET ALTERNATE ON
  44.  
  45. ?'.OP'
  46. ?'.DF '+file:dat
  47. ?'.RV '+' last-name, first-name, mr, dear, title, company1, company2, street, suite-apt, city, state, zip'
  48. ?'.. for title, company1, company2  use &title/O&, &company1/O&, &company2/O&'
  49. ?'.. to automatically omit empty data fields'
  50.  
  51. SET ALTERNATE OFF
  52.  
  53. SET CONSOLE ON
  54. @ 05,10 SAY  ' Creating WordStar-MailMerge Data file:  '+file:dat
  55. ?
  56. ?
  57. ?? 'Writing records '
  58. SET CONSOLE OFF
  59. SET ALTERNATE TO &file:dat
  60. SET ALTERNATE ON
  61.  
  62. * select database file and start at first record
  63. GOTO TOP
  64.  
  65. * repeat until end of file
  66. DO WHILE .NOT. EOF
  67.  
  68.  
  69. * if there is a chance of a comma in a field then trim and put in quotes
  70.  
  71. IF send <> 'Y'
  72.   * if it is NOT a company address then... 
  73.   * make blanks for these first 3 variables
  74.   STORE ' ' TO titleline
  75.   STORE ' ' TO coname1
  76.   STORE ' ' TO coname2
  77.   STORE CHR(34)+TRIM(address)+CHR(34) TO street
  78.   STORE CHR(34)+TRIM(city)+CHR(34) TO cityto
  79.   STORE st TO stto
  80.   STORE zip TO zipto
  81.  
  82. * if a field is empty then store it as a blank variable...
  83. * but trim and put quotes around a non-empty field
  84.  
  85.   IF apt = ' '
  86.     STORE ' ' TO room
  87.   ELSE
  88.     STORE CHR(34)+TRIM(apt)+CHR(34) TO room
  89.   ENDIF
  90. ELSE
  91. * if it is a company address etc do the following...
  92.   STORE CHR(34)+TRIM(caddress)+CHR(34) TO street
  93.   STORE CHR(34)+TRIM(ccity)+CHR(34) TO cityto
  94.   STORE cst TO stto
  95.   STORE czip TO zipto
  96.   IF title = ' '
  97.     STORE ' ' TO titleline
  98.   ELSE
  99.     STORE CHR(34)+TRIM(title)+CHR(34) TO titleline
  100.   ENDIF
  101.   IF company1 = ' '
  102.     STORE ' ' TO coname1
  103.   ELSE
  104.     STORE CHR(34)+TRIM(company1)+CHR(34) TO coname1
  105.   ENDIF
  106.   IF company2 = ' '
  107.     STORE ' ' TO coname2
  108.   ELSE
  109.     STORE CHR(34)+TRIM(company2)+CHR(34) TO coname2
  110.   ENDIF
  111.   IF suite = ' '
  112.     STORE ' ' TO room
  113.   ELSE
  114.     STORE CHR(34)+TRIM(suite)+CHR(34) TO room
  115.   ENDIF
  116.  
  117. ENDIF send letter to office
  118.  
  119. * now write data to the WS MailMerge file
  120. * the first 4 variables are raw field names that must contain data...
  121. * and can contain commas ; so trim them  and enclose in quotes
  122. * all other variables have been 'fixed' in the above IF statements
  123.  
  124.  ? 
  125.  ??  CHR(34)+TRIM(lastname)+CHR(34) +','
  126.  ??  CHR(34)+TRIM(fname)+CHR(34) +','
  127.  ??  CHR(34)+TRIM(mr)+CHR(34) +','
  128.  ??  CHR(34)+TRIM(dear)+CHR(34) +','
  129.  ??  titleline +','
  130.  ??  coname1 +','
  131.  ??  coname2 +','
  132.  ??  street +','
  133.  ??  room +','
  134.  ??  cityto +','
  135.  ??  stto +','
  136.  ??  zipto +','
  137.  SKIP
  138. * tell em that you are busy 
  139. SET CONSOLE ON
  140. ?? '*'
  141. SET CONSOLE OFF
  142.  
  143. ENDDO while not EOF
  144.  
  145. STORE f TO continue
  146. ENDDO continue
  147.  
  148. SET ALTERNATE OFF
  149. SET CONSOLE ON
  150. RELEASE file:dat,file:doc,continue,length
  151.  
  152. * put back the original variables
  153. STORE '?' TO command
  154. STORE ' ' TO printer
  155. STORE ' ' TO disk
  156. STORE '            ' TO filename
  157. STORE t TO more
  158.