home *** CD-ROM | disk | FTP | other *** search
- ** Last revision: April 17, 1986 at 18:54
- * wsfile1.cmd
- * this program will take data from the main data base
- * it will select the proper mailing address
- * depending upon if the letter is to go to office or home
- * then it will write the Wordstar DAT file, (but not the DOC file)
- * This program allows you to select starting letter and number of records.
- CLEAR
- ? 'This Module will make a special MailMerge file for WordStar'
- ?
- ? 'It is designed to write a write a limited number of records'
- ? 'and not create a document file. If you want all records and'
- ? 'a document file, run option 5.'
- ?
- ? ' Do you wish to continue (Y/N) ? '
- SET CONSOLE OFF
- WAIT TO command
- SET CONSOLE ON
- IF command = 'Y' .OR. command = 'y'
- STOR .t. TO continue
- ELSE
- STOR .f. TO continue
- ENDI
- GO TOP
- DO WHIL continue
- STOR 0 TO fnumber
- STOR 1 TO counter
- CLEAR
- ACCE 'Enter Name of the WordStar-MailMerge file ' TO file_dat
- * make the proper WordStar file names
- STOR UPPER(file_dat) TO file_dat
- STOR SUBSTR(file_dat,1,8) TO file_dat
- STOR file_dat+'.DOC' TO file_doc
- STOR file_dat+'.DAT' TO file_dat
- * get a starting and ending points in file
- STOR 'A' TO stletter
- @ 05,12 SAY 'Letter of alphabet at which to start report'
- @ 05,57 GET stletter PICTURE '!'
- READ
- @ 07,12 SAY 'Total number of records to write'
- @ 07,57 GET fnumber PICTURE '##'
- READ
- * goto starting point or next if no find
- SEEK stletter
- DO WHIL (EOF() .OR. BOF())
- STOR 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ' TO ALPHABET
- STOR AT(stletter,ALPHABET) + 1 TO NEXL
- STOR SUBSTR(ALPHABET,NEXL,1) TO stletter
- SEEK stletter
- RELE alphabet, nexl
- ENDD
- SET CONSOLE ON
- @ 15,10 SAY ' Creating WordStar-MailMerge Data file: '+file_dat
- ?
- ?
- ?? 'Writing record # '
- SET CONSOLE OFF
- SET ALTERNATE TO &file_dat
- SET ALTERNATE ON
- * select database file and start at first record
- * repeat until end of file
- DO WHIL (fnumber >0 .AND.(.NOT. EOF()))
- * if there is a chance of a comma in a field then trim and put in quotes
- IF send <> 'Y'
- * if it is NOT a company address then...
- * make blanks for these first 3 variables
- STOR ' ' TO titleline
- STOR ' ' TO coname1
- STOR ' ' TO coname2
- STOR CHR(34)+TRIM(address)+CHR(34) TO street
- STOR CHR(34)+TRIM(city)+CHR(34) TO cityto
- STOR st TO stto
- STOR zip TO zipto
- * if a field is empty then store it as a blank variable...
- * but trim and put quotes around a non-empty field
- IF apt = ' '
- STOR ' ' TO room
- ELSE
- STOR CHR(34)+TRIM(apt)+CHR(34) TO room
- ENDI
- ELSE
- * if it is a company address etc do the following...
- STOR CHR(34)+TRIM(caddress)+CHR(34) TO street
- STOR CHR(34)+TRIM(ccity)+CHR(34) TO cityto
- STOR cst TO stto
- STOR czip TO zipto
- IF title = ' '
- STOR ' ' TO titleline
- ELSE
- STOR CHR(34)+TRIM(title)+CHR(34) TO titleline
- ENDI
- IF company1 = ' '
- STOR ' ' TO coname1
- ELSE
- STOR CHR(34)+TRIM(company1)+CHR(34) TO coname1
- ENDI
- IF company2 = ' '
- STOR ' ' TO coname2
- ELSE
- STOR CHR(34)+TRIM(company2)+CHR(34) TO coname2
- ENDI
- IF suite = ' '
- STOR ' ' TO room
- ELSE
- STOR CHR(34)+TRIM(suite)+CHR(34) TO room
- ENDI
- ENDI send letter to office
- * now write data to the WS MailMerge file
- * the first 4 variables are raw field names that must contain data...
- * and can contain commas ; so trim them and enclose in quotes
- * all other variables have been 'fixed' in the above IF statements
- ?
- ?? CHR(34)+TRIM(lastname)+CHR(34) +','
- ?? CHR(34)+TRIM(fname)+CHR(34) +','
- ?? CHR(34)+TRIM(mr)+CHR(34) +','
- ?? CHR(34)+TRIM(dear)+CHR(34) +','
- ?? titleline +','
- ?? coname1 +','
- ?? coname2 +','
- ?? street +','
- ?? room +','
- ?? cityto +','
- ?? stto +','
- ?? zipto +','
- SKIP
- * tell em that you are busy
- SET CONSOLE ON
- SET ALTERNATE OFF
- SET CONSOLE ON
- ?? STR(COUNTER,5)
- SET CONSOLE OFF
- SET ALTERNATE ON
- STOR COUNTER + 1 TO COUNTER
- STOR fnumber-1 TO fnumber
- ENDD WHILE not eof
- STOR .f. TO continue
- ENDD continue
- SET ALTERNATE OFF
- SET CONSOLE ON
- STOR '?' TO command
- STOR ' ' TO printer
- STOR ' ' TO disk
- STOR ' ' TO filename
- RETURN
-
-
-