/* tobee.tc - lrb - 11/13/08 /* 1 char tt(4725),ntt(4725) /* 11/12/08 char td(5000),ver(10),tf(45),tdf(12),tdfnext(12) char crlf(2),lf(1),dq,pw(4),red,blue,white,lo,hi,vls(1) int eof,ct,tts,tds,debug,vebug,vl,stt,tdc /* 11/12/08 /* 2 tobee [ /* 3 stt=tt crlf(0)=13;crlf(1)=10;crlf(2)=0;lf(0)=10;lf(1)=0;dq=34 strcpy(pw,"|/-\") strcpy(ntt,"Toby Rules!");strcat(ntt,crlf);strcat(ntt,crlf) strcpy(ver,"1.0.5.g");red='1';blue='4';white='7';lo='0';hi='1' strcpy(vls,"|") /* 4 hilo hi;color blue pl "Toby Speak Version ";ps ver;pl "" hilo lo /* 6 pl "Enter name of file to translate and, optionally, verbose." pl "filename.typ [verbose] " char tfi(45) if (gs(tfi)) strcpy(tf,tfi) else strcpy(tf,"tobee.txt") pl "";strcat(tf," ") debug=index(tf,strlen(tf),"debug",5) vebug=index(tf,strlen(tf),"verbose",7) strcpy(tdf,"tobee.dic") tf(index(tf,strlen(tf)," ",1)-1)=0 /* 7 while (1) [ if (loaddic()==-1) [ pl "Error loading ";ps tdf;ps " dictionary.";pl "" exit ] if (index(tdf,12,"tobee.dic",9)) [ if ((tts=readfile(tf,tt,tt+4725,1))>0) [ /* 11/12/08 strcat(tt,crlf) strcat(ntt,tt);strcpy(tt,ntt);ntt(0)=0 ] else [ pl "Error loading file ";ps tf;sak exit ] ] trantobee /* 7a if (vl) strcpy(tdf,tdfnext) ] ] /* 8 loaddic [ pl "";pl "Loading dictionary ...";pl "" /* 9 int i memset td,5000,0 /* 11/12/08 if ((tds=readfile(tdf,td,td+5000,1))>0) [ if (td(tds-1)==10) td(tds-1)=0 /* 11/12/08 char rb;rb=93 strcpy(tdfnext,"") vl=index(td,100,vls,1) if (vl) [ for (i=vl;td(i)!=rb;++i) tdfnext(i-vl)=td(i) tdfnext(i-vl)=0 ] pl "Dictionary loaded!";pl "" tdc=tdc+countch(td,td+tds,'~') /* 11/12/08 char wwws(40),wws(40),ws(40),sws(40);int idx;ct=0 strcpy(wwws,"still->ztill") char msg(1000) /* 11/12/08 char dqs(1);dqs(0)=dq;dqs(1)=0 char rbs(1);rbs(0)=rb;rbs(1)=0 /* 11/12/08 strcpy(msg,"x+=");strcat(msg,dqs) while (!vl) [ cnormal if (strlen(msg)>950) [ /* 11/12/08 pl "Add other words later!";break ] pl "To add to the ";ps tdf;ps " dictionary, enter a string like " hilo hi;color white;ps wwws;hilo lo pl "Press Enter to exit : " gs(wws) if (!index(wws,strlen(wws),rbs,1)) [ /* 11/12/08 tolower(wws) ] strcpy(wwws,wws) idx=index(wws,strlen(wws),"->",2) if (idx) [ strcpy(sws,"_") strcpy(ws,wws+idx+1) wws(idx-1)=0;strcat(sws,wws) strcat(sws,"_") strcat(wws,"_->~") strcat(wws,ws) strcat(wws,"_") ws(0)=0 strcat(ws,"_") strcat(ws,wws) ] if (!strlen(wws)) break if (index(td,strlen(td),sws,strlen(sws))==0) [ ++ct;strcat(msg," ");strcat(msg,ws) ] if (index(wws,strlen(wws),rbs,1)) [ /* 11/12/08 strcat(msg," ");strcat(msg,wws) ] ] if (ct) [ strcat(msg,dqs);strcat(msg,";");strcat(td,msg) tdc=tdc+countch(msg,msg+strlen(msg),'~') /* 11/12/08 tds=strlen(td) if (writefile(tdf,td,td+tds-1,1)>0) [ ct=0;hilo hi;color red pl tdf;ps " now has";pn tdc;ps " words!" /* 11/12/08 pl "Your word(s) have been added to the dictionary!" pl "";pl "Please email TSI (Toby Speak International)" ps " (bradley_lee_r@sbcglobal.net)";pl "the following message:" pl "";pl msg if (writefile("tobee.msg",msg,msg+strlen(msg)-1,1)>0) [ pl "which you will find in the file tobee.msg." pl "";beep(440,2);hilo lo;sak;pl "" ] else pl "Error writing tobee.msg file" ] else [pl "Error writing ";ps tdf] ] return 1 ] else return -1 ] /* 10 trantobee [ int dbsp dbsp=index(tt,strlen(tt)," ",2) if (dbsp) [pl "Eliminating double spaces from input ...";pl "";pl ""] while (dbsp) [ putchar pw(++ct%4);putchar 8;strcpy(ntt,tt+dbsp+1) strcpy(tt+dbsp,ntt) dbsp=index(tt,strlen(tt)," ",2) ] if (ct) [ ct=0;ntt(0)=0 ps " ";sak;pl "" ] /* 11 pl "";pl "";ps tt;pl "" /* 12 eof=0 if (index(tdf,12,"tobee.dic",9)) pl "" sak pl "" /* 13 pl "Please be patient while I translate ..." pl "Using";pn tds;ps " byte dictionary " /* 11/12/08 ps tdf;ps " ...";pl "";chide while (eof!=1) doit /* 13a if (!(vebug+debug)) [putchar(8);ps " "] if (!vl) [ pl "";pl "";ps ntt cnormal sak;pl "" char wmk(200) strcpy(wmk,"Translation by ") strcat(wmk,"Toby Speak Version ");strcat(wmk,ver) strcat(wmk,crlf);strcat(ntt,wmk) pl "The dictionary has";pn tdc;ps " words!";pl "" /* 11/12/08 if (debug) pl ntt int i,j;i=index(tf,strlen(tf),".",1) if (!i) [strcat(tf,".");i=strlen(tf)] char tfo(32),tfh(32);for (j=0;j0) if (writefile(tfh,ntt,ntt+strlen(ntt)-1,1)>0) [ pl "";hilo hi;color white ps "See ";ps tfo;ps " and ";ps tfh;ps " for output." pl "";beep(880,2);beep(0,2);beep(880,8);hilo lo sak;pl "" ] else pl "Error writing output files" exit ] if (eof==1) [tt=stt;strcpy(tt,ntt);strcpy(ntt,"")] ] /* 14 doit [ /* 15 if (!(vebug+debug)) [putchar pw(++ct%4);putchar(8)] /* 16 int n,nc /* 17 nc=index(tt,strlen(tt),crlf,2) n=index(tt,strlen(tt)," ",1) /* 18 if (debug) [pl "nc=";pn nc;pl "n=";pn n;getchar] /* 19 int csw /* 11/13/08 if ((n>nc)*nc) [n=nc;csw=1] if (n==0) [n=nc;csw=1] /* 20 char wws(100),ws(100) wws(0)=ws(0)=0 if (debug) [pl "n=";pn n;getchar] int j for (j=0;j");int scp for (j=0;j ";ps ws ] /* 27 tt=tt+n-1 /* 27a if (csw==0) ++tt while (tt(0)==13) [strcat(ntt,crlf);tt=tt+2] if ((tt(0)==' ')*(tt(1)==13)) [ ++tt while (tt(0)==13) [strcat(ntt,crlf);tt=tt+2] ] /* 27c if (tt(0)==0) eof=1 ]