/* mailmerg.tc - tct - 2/28/2010 /* split char string s delimited by char string d into int array t split int t(0);char s(0),d(0) [ int y,ix,tx,sl int ds ds=strlen(d) t(0)=s;sl=strlen(s) while (sl-tx) [ ix=index(s+tx,sl-tx,d,ds) tx=tx+ix+ds-1 t(++y)=s+tx s(tx-ds)=0 ] return y ] mail char prefix(0) [ pl "";ps "mailmerg.tc - tct - 2/28/2010";pl "" pl "";ps "please visit http://primepuzzle.com/tc/mail-merge.html";pl "" char t(1000),m(3000),of(3000),ofile(25),wrk(300),crlf(2),post(2) int ti(10),mi(20),di(10),ts,ms,cs,rok1,rok2,wok1,i,j,k crlf(0)=13;crlf(1)=10 if ((rok1=readfile("template.txt",t,t+1000-1,1))<0) [ps "error reading template file";exit] strcat(t,"$") ts=split(ti,t,"$") if ((rok2=readfile("mail.dat",m,m+3000-1,2))<0) [ps "error reading mail file";exit] m(rok2-2)=0;strcat(m,crlf) ms=split(mi,m,crlf) for (i=0;i=10) [post(0)='0'+i/10;k=1] post(k)='0'+i%10;strcat(ofile,post);strcat(ofile,".LTR") /* unit needs to be 1 for some reason ... if ((wok1=writefile(ofile,of,of+strlen(of)-1,1))<0) [ps "error writing output file";exit] pl "file ";ps ofile;ps " written." ] pl "" ]