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

  1. **    Last revision: April 17, 1986 at 18:54
  2. * wsfile1.cmd
  3. * this program will take data from the main data base
  4. * it will select the proper mailing address
  5. * depending upon if the letter is to go to office or home
  6. * then it will write the Wordstar  DAT file, (but not the DOC file)
  7. * This program allows you to select starting letter and number of records.
  8. CLEAR
  9. ? 'This Module will make a special MailMerge file for WordStar'
  10. ?
  11. ? 'It is designed to write a write a limited number of records'
  12. ? 'and not create a document file. If you want all records and'
  13. ? 'a document file, run option 5.'
  14. ?
  15. ? ' Do you wish to continue (Y/N) ? '
  16. SET CONSOLE OFF
  17. WAIT TO command
  18. SET CONSOLE ON
  19. IF command = 'Y' .OR. command = 'y'
  20.  STOR .t. TO continue
  21. ELSE
  22.  STOR .f. TO continue
  23. ENDI
  24. GO TOP
  25. DO WHIL continue
  26.  STOR 0 TO fnumber
  27.  STOR 1 TO counter
  28.  CLEAR
  29.  ACCE 'Enter Name of the WordStar-MailMerge file  ' TO file_dat
  30. * make the proper WordStar file names
  31.  STOR UPPER(file_dat) TO file_dat
  32.  STOR SUBSTR(file_dat,1,8) TO file_dat
  33.  STOR file_dat+'.DOC'  TO file_doc
  34.  STOR file_dat+'.DAT'  TO file_dat
  35. * get a starting  and ending points in file
  36.  STOR 'A' TO stletter
  37.  @ 05,12 SAY 'Letter of alphabet at which to start report'
  38.  @ 05,57 GET stletter PICTURE '!'
  39.  READ
  40.  @ 07,12 SAY 'Total number of records to write'
  41.  @ 07,57 GET fnumber PICTURE '##'
  42.  READ
  43. * goto starting point or next if no find
  44.  SEEK stletter
  45.  DO WHIL (EOF() .OR. BOF())
  46.   STOR 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ' TO ALPHABET
  47.   STOR AT(stletter,ALPHABET) + 1 TO NEXL
  48.   STOR SUBSTR(ALPHABET,NEXL,1) TO stletter
  49.   SEEK stletter
  50.   RELE alphabet, nexl
  51.  ENDD
  52.  SET CONSOLE ON
  53.  @ 15,10 SAY  ' Creating WordStar-MailMerge Data file:  '+file_dat
  54.  ?
  55.  ?
  56.  ?? 'Writing record #     '
  57.  SET CONSOLE OFF
  58.  SET ALTERNATE TO &file_dat
  59.  SET ALTERNATE ON
  60. * select database file and start at first record
  61. * repeat until end of file
  62.  DO WHIL (fnumber >0 .AND.(.NOT. EOF()))
  63. * if there is a chance of a comma in a field then trim and put in quotes
  64.   IF send <> 'Y'
  65. * if it is NOT a company address then...
  66. * make blanks for these first 3 variables
  67.    STOR ' ' TO titleline
  68.    STOR ' ' TO coname1
  69.    STOR ' ' TO coname2
  70.    STOR CHR(34)+TRIM(address)+CHR(34) TO street
  71.    STOR CHR(34)+TRIM(city)+CHR(34) TO cityto
  72.    STOR st TO stto
  73.    STOR zip TO zipto
  74. * if a field is empty then store it as a blank variable...
  75. * but trim and put quotes around a non-empty field
  76.    IF apt = ' '
  77.     STOR ' ' TO room
  78.    ELSE
  79.     STOR CHR(34)+TRIM(apt)+CHR(34) TO room
  80.    ENDI
  81.   ELSE
  82. * if it is a company address etc do the following...
  83.    STOR CHR(34)+TRIM(caddress)+CHR(34) TO street
  84.    STOR CHR(34)+TRIM(ccity)+CHR(34) TO cityto
  85.    STOR cst TO stto
  86.    STOR czip TO zipto
  87.    IF title = ' '
  88.     STOR ' ' TO titleline
  89.    ELSE
  90.     STOR CHR(34)+TRIM(title)+CHR(34) TO titleline
  91.    ENDI
  92.    IF company1 = ' '
  93.     STOR ' ' TO coname1
  94.    ELSE
  95.     STOR CHR(34)+TRIM(company1)+CHR(34) TO coname1
  96.    ENDI
  97.    IF company2 = ' '
  98.     STOR ' ' TO coname2
  99.    ELSE
  100.     STOR CHR(34)+TRIM(company2)+CHR(34) TO coname2
  101.    ENDI
  102.    IF suite = ' '
  103.     STOR ' ' TO room
  104.    ELSE
  105.     STOR CHR(34)+TRIM(suite)+CHR(34) TO room
  106.    ENDI
  107.   ENDI send letter to office
  108. * now write data to the WS MailMerge file
  109. * the first 4 variables are raw field names that must contain data...
  110. * and can contain commas ; so trim them  and enclose in quotes
  111. * all other variables have been 'fixed' in the above IF statements
  112.   ?
  113.   ?? CHR(34)+TRIM(lastname)+CHR(34) +','
  114.   ?? CHR(34)+TRIM(fname)+CHR(34) +','
  115.   ?? CHR(34)+TRIM(mr)+CHR(34) +','
  116.   ?? CHR(34)+TRIM(dear)+CHR(34) +','
  117.   ?? titleline +','
  118.   ?? coname1 +','
  119.   ?? coname2 +','
  120.   ?? street +','
  121.   ?? room +','
  122.   ?? cityto +','
  123.   ?? stto +','
  124.   ?? zipto +','
  125.   SKIP
  126. * tell em that you are busy
  127.   SET CONSOLE ON
  128.   SET ALTERNATE OFF
  129.   SET CONSOLE ON
  130.   ?? STR(COUNTER,5)
  131.   SET CONSOLE OFF
  132.   SET ALTERNATE ON
  133.   STOR COUNTER + 1 TO COUNTER
  134.   STOR fnumber-1 TO fnumber
  135.  ENDD WHILE not eof
  136.  STOR .f. TO continue
  137. ENDD continue
  138. SET ALTERNATE OFF
  139. SET CONSOLE ON
  140. STOR '?' TO command
  141. STOR ' ' TO printer
  142. STOR ' ' TO disk
  143. STOR '            ' TO filename
  144. RETURN
  145.  
  146.  
  147.