** Last revision: April 17, 1986 at 20:28 * wsfile.cmd CLEAR STOR 'Y' TO command @ 10,10 SAY 'This Module will make a special MailMerge file for WordStar' @ 11,10 SAY 'Do you wish to continue (Y/N) ? ' @ 11,48 GET command PICTURE '!' READ DO WHILE AT(command,'YN')=0 @ 11,48 GET command PICTURE '!' READ ENDD IF command = 'Y' STOR .t. TO continue ELSE STOR .f. TO continue ENDI DO WHIL continue STOR 1 TO counter CLEAR STOR 'C' TO dri @ 10,10 SAY 'On what drive do you want the file ?' @ 10,70 GET dri PICTURE '!' READ DO WHILE AT(dri,'CAB')=0 @ 10,70 GET dri PICTURE '!' READ ENDD STOR ' ' TO file_dat @ 11,10 SAY 'Enter Name of the WordStar-MailMerge file ' @ 11,70 GET file_dat PICTURE '!!!!!!' READ DO WHILE file_dat = ' ' @ 11,70 GET file_dat PICTURE '!!!!!!' READ ENDDO STOR dri+':'+file_dat TO file_dat STOR 'W' TO prg @ 12,10 SAY 'Will the printing be with ordstar or ewword ?' @ 12,70 GET prg PICTURE '!' READ DO WHILE AT(prg,'NW')=0 @ 12,70 GET prg PICTURE '!' READ ENDDO IF prg = 'N' STOR ' ' TO ending ELSE STOR ',' TO ending ENDI CLEAR 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 @ 03,10 SAY 'Creating WordStar-MailMerge Document file: '+file_doc SET CONSOLE OFF SET ALTERNATE TO &file_doc SET ALTERNATE ON ? '.OP' ? '.DF '+file_dat ? '.RV '+' last-name, first-name, mr, dear, title, company1, company2, street, suite-apt, city, state, zip' ? '.. for title, company1, company2 use &title/O&, &company1/O&, &company2/O&' ? '.. to automatically omit empty data fields' SET ALTERNATE OFF SET CONSOLE ON @ 05,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 GO TOP * repeat until end of file DO WHIL .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 +ending 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 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