home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol285 / wsfile.prg < prev    next >
Encoding:
Text File  |  1986-12-22  |  4.3 KB  |  162 lines

  1. **    Last revision: April 17, 1986 at 20:28
  2. * wsfile.cmd
  3. CLEAR 
  4. STOR 'Y' TO command
  5. @ 10,10 SAY 'This Module will make a special MailMerge file for WordStar'
  6. @ 11,10 SAY 'Do you wish to continue (Y/N) ? '
  7. @ 11,48 GET command PICTURE '!'
  8. READ
  9. DO WHILE AT(command,'YN')=0
  10. @ 11,48 GET command PICTURE '!'
  11. READ
  12. ENDD               
  13. IF command = 'Y'                       
  14.  STOR .t. TO continue
  15. ELSE
  16.  STOR .f. TO continue
  17. ENDI
  18. DO WHIL continue
  19.  STOR 1 TO counter
  20.  CLEAR 
  21. STOR 'C' TO dri
  22. @ 10,10 SAY 'On what drive do you want the file ?'
  23. @ 10,70 GET dri PICTURE '!'
  24. READ
  25. DO WHILE AT(dri,'CAB')=0
  26. @ 10,70 GET dri PICTURE '!'
  27. READ
  28. ENDD                                    
  29. STOR '      ' TO file_dat
  30. @ 11,10 SAY 'Enter Name of the WordStar-MailMerge file  '              
  31. @ 11,70 GET file_dat PICTURE '!!!!!!'
  32. READ
  33. DO WHILE file_dat = '      '
  34. @ 11,70 GET file_dat PICTURE '!!!!!!'
  35. READ
  36. ENDDO
  37. STOR dri+':'+file_dat TO file_dat
  38. STOR 'W' TO prg
  39. @ 12,10 SAY 'Will the printing be with <W>ordstar or <N>ewword ?'
  40. @ 12,70 GET prg PICTURE '!'
  41. READ
  42. DO WHILE AT(prg,'NW')=0
  43. @ 12,70 GET prg PICTURE '!'
  44. READ
  45. ENDDO
  46. IF prg = 'N'
  47. STOR ' ' TO ending
  48. ELSE
  49. STOR ',' TO ending
  50. ENDI
  51. CLEAR     
  52.  STOR UPPER(file_dat) TO file_dat
  53.  STOR SUBSTR(file_dat,1,8) TO file_dat
  54.  STOR file_dat+'.DOC'  TO file_doc
  55.  STOR file_dat+'.DAT'  TO file_dat
  56.  @ 03,10 SAY  'Creating WordStar-MailMerge Document file:  '+file_doc
  57.  SET CONSOLE OFF
  58.  SET ALTERNATE TO &file_doc
  59.  SET ALTERNATE ON
  60.  ? '.OP'
  61.  ? '.DF '+file_dat
  62.  ? '.RV '+' last-name, first-name, mr, dear, title, company1, company2, street, suite-apt, city, state, zip'
  63.  ? '.. for title, company1, company2  use &title/O&, &company1/O&, &company2/O&'
  64.  ? '.. to automatically omit empty data fields'
  65.  SET ALTERNATE OFF
  66.  SET CONSOLE ON
  67.  @ 05,10 SAY  ' Creating WordStar-MailMerge Data file:  '+file_dat
  68.  ?
  69.  ?
  70.  ?? 'Writing record #     '
  71.  SET CONSOLE OFF
  72.  SET ALTERNATE TO &file_dat
  73.  SET ALTERNATE ON
  74. * select database file and start at first record
  75.  GO TOP
  76. * repeat until end of file
  77.  DO WHIL .NOT. EOF()
  78. * if there is a chance of a comma in a field then trim and put in quotes
  79.   IF send <> 'Y'
  80. * if it is NOT a company address then...
  81. * make blanks for these first 3 variables
  82.    STOR ' ' TO titleline
  83.    STOR ' ' TO coname1
  84.    STOR ' ' TO coname2
  85.    STOR CHR(34)+TRIM(address)+CHR(34) TO street
  86.    STOR CHR(34)+TRIM(city)+CHR(34) TO cityto
  87.    STOR st TO stto
  88.    STOR zip TO zipto
  89. * if a field is empty then store it as a blank variable...
  90. * but trim and put quotes around a non-empty field
  91.    IF apt = ' '
  92.     STOR ' ' TO room
  93.    ELSE
  94.     STOR CHR(34)+TRIM(apt)+CHR(34) TO room
  95.    ENDI
  96.   ELSE
  97. * if it is a company address etc do the following...
  98.    STOR CHR(34)+TRIM(caddress)+CHR(34) TO street
  99.    STOR CHR(34)+TRIM(ccity)+CHR(34) TO cityto
  100.    STOR cst TO stto
  101.    STOR czip TO zipto
  102.    IF title = ' '
  103.     STOR ' ' TO titleline
  104.    ELSE
  105.     STOR CHR(34)+TRIM(title)+CHR(34) TO titleline
  106.    ENDI
  107.    IF company1 = ' '
  108.     STOR ' ' TO coname1
  109.    ELSE
  110.     STOR CHR(34)+TRIM(company1)+CHR(34) TO coname1
  111.    ENDI
  112.    IF company2 = ' '
  113.     STOR ' ' TO coname2
  114.    ELSE
  115.     STOR CHR(34)+TRIM(company2)+CHR(34) TO coname2
  116.    ENDI
  117.    IF suite = ' '
  118.     STOR ' ' TO room
  119.    ELSE
  120.     STOR CHR(34)+TRIM(suite)+CHR(34) TO room
  121.    ENDI
  122.   ENDI send letter to office
  123. * now write data to the WS MailMerge file
  124. * the first 4 variables are raw field names that must contain data...
  125. * and can contain commas ; so trim them  and enclose in quotes
  126. * all other variables have been 'fixed' in the above IF statements
  127.   ?
  128.   ?? CHR(34)+TRIM(lastname)+CHR(34) +','
  129.   ?? CHR(34)+TRIM(fname)+CHR(34) +','
  130.   ?? CHR(34)+TRIM(mr)+CHR(34) +','
  131.   ?? CHR(34)+TRIM(dear)+CHR(34) +','
  132.   ?? titleline +','
  133.   ?? coname1 +','
  134.   ?? coname2 +','
  135.   ?? street +','
  136.   ?? room +','
  137.   ?? cityto +','
  138.   ?? stto +','
  139.   ?? zipto +ending
  140.   SKIP
  141. * tell em that you are busy
  142.   SET CONSOLE ON
  143.   SET ALTERNATE OFF
  144.   SET CONSOLE ON
  145.   ?? STR(COUNTER,5)
  146.   SET CONSOLE OFF
  147.   SET ALTERNATE ON
  148.   STOR COUNTER + 1 TO COUNTER
  149.  ENDD while not EOF
  150.  STOR .f. TO continue
  151. ENDD continue
  152. SET ALTERNATE OFF
  153. SET CONSOLE ON
  154. STOR '?' TO command
  155. STOR ' ' TO printer
  156. STOR ' ' TO disk
  157. STOR '            ' TO filename
  158. RETURN
  159.  
  160.  
  161.  
  162.