home *** CD-ROM | disk | FTP | other *** search
- 10 pdev=4:def fnc(x)=int((x+2)/3)*3
- 20 deffnz(v)=v*-1*((v+.01)-int(v+.01)>=.02)-int(v+.01)*((v+.01)-int(v+.01)<.02)
- 120 dim c(16),n$(16),t$(32),nn$(10),m$(18),r$(100),cv(8),cc(11),cc$(11)
- 130 forj=1to16:readc(j):nextj:forj=1to16:readn$(j):next
- 140 forj=1to18:readm$(j):next:forj=1to8:readcv(j):next
- 150 forj=1to11:readcc(j):next:forj=1to11:readcc$(j):next
- 160 print"[147]"tab(12)"recipe converter":input"recipe title";t$
- 170 s1=0:input" original recipe serves";x$:s1=val(x$):ifs1<1then170
- 180 s2=0:input" number of adjusted servings";x$:s2=val(x$):ifs2<1then180
- 190 input"output to s[146]creen or p[146]rinter (s/p) p[157][157][157]";d$
- 200 pdev=-3*(d$="s")-4*(d$="p")
- 210 print" input recipe lines, type '*' to quit.":nl=0
- 220 inputs$:ifs$="*"then350
- 230 gosub400:ifnt>=2then250
- 240 print"don't understand this line.":goto220
- 250 s$=t$(1):gosub460:ifexthenprint"an amount must come first":goto220
- 260 v=x:s$=t$(2):z=2:gosub460:ifex=0thenz=3:v=v+x
- 270 ifz>nt then240
- 280 p$=t$(z):gosub540
- 290 gosub 660:goto300
- 300 ifz>ntthen340
- 310 for j=z to nt:x$=x$+" "+t$(j)
- 320 if(j=z)and(j=nt)and(p=0)and(v>1)and(right$(t$(j),1)<>"s")thenx$=x$+"s"
- 330 next
- 340 nl=nl+1:r$(nl)=x$:goto220
- 350 close3:open3,pdev
- 360 print#3:print#3:print#3:w=80:ifpdev=3thenw=40:print#3,"[147]"
- 370 print#3,spc((w-len(t$))/2*-(len(t$)<=w))t$
- 380 x$="(serves"+str$(s2)+")":print#3,spc((w-len(x$))/2)x$:print#3:print#3
- 390 forj=1tonl:print#3,r$(j):next:print#3:close3:end
- 400 nt=0:j=1:a$="":f=1
- 410 if j>len(s$)then on f goto 450,440
- 420 b$=mid$(s$,j,1):ifb$=" "thenj=j+1:on f goto 410,440
- 430 a$=a$+b$:j=j+1:f=2:goto410
- 440 nt=nt+1:t$(nt)=a$:a$="":f=1:goto 410
- 450 return
- 460 x=0:nn=0:j=1:a$="":f=1:ex=0
- 470 if j>len(s$)then on f goto 510,500
- 480 b$=mid$(s$,j,1):if(b$>="0"andb$<="9")orb$="."thena$=a$+b$:j=j+1:f=2:goto470
- 490 if b$<>"/"then ex=1:return
- 500 nn=nn+1:nn$(nn)=a$:a$="":j=j+1:f=1:goto 470
- 510 if nn>2 or val(nn$(1))=0then ex=1:return
- 520 x=val(nn$(1)):if nn>1 then x=x/val(nn$(2))
- 530 return
- 540 l=len(p$):x$=mid$(p$,l):ifx$="." then ifl>1 thenp$=left$(p$,l-1)
- 550 l=len(p$):x$=mid$(p$,l):ifx$="s" then ifl>1 thenp$=left$(p$,l-1)
- 560 p=0:forj=1to18:ifp$=m$(j)thenp=fnc(j):return
- 570 nextj:return
- 580 data 1,2,4,8,12,24,36,48,64,96,128,144,192,384,768,3072
- 590 data 1/4 tsp,1/2 tsp,1 tsp,2 tsp,1 tbsp,2 tbsp,3 tbsp,1/4 cup,1/3 cup
- 600 data 1/2 cup,2/3 cup,3/4 cup,1 cup,1 pint, 1 quart, 1 gallon
- 610 data t,tsp,teaspoon,tb,tbsp,tablespoon,c,cp,cup,p,pt,pint
- 620 data q,qt,quart,g,gal,gallon
- 630 data 4,12,192,384,768,3072,0,0
- 640 data 0,.125,.25,.333333,.375,.5,.625,.666666,.75,.875,1
- 650 data ,,1/8,1/4,1/3,3/8,1/2,5/8,2/3,3/4,7/8,1
- 660 v=fnz(v)*(s2/s1):ifp=0thengosub880:return
- 670 z=z+1:j=fnc(p)/3:if(j<6)or(s1>s2)then690
- 680 v=fnz(v):gosub880:x$=x$+" gallon"+mid$("s",1,-1*(v<>1)):gosub780:return
- 690 v=fnz(v+.005*-1*(int(v)=v))*cv(j):x$="":vv=v*-1*(v>383or(p=9ands1<s2)):vx=v
- 700 j=1
- 710 ifc(j)<=vthenj=j+1:ifj<17then710
- 720 ifj=17thenv=v/3072:goto680
- 730 j=j-1:x$=x$+n$(j):v=fnz(v-c(j)):if vv and v<48 then gosub 780
- 740 if v>=1 and v/vx>.05 then x$=x$+" plus ":goto700
- 750 if vv then gosub 780
- 760 if x$=""then x$=x$+"1 dash"
- 770 return
- 780 k=int(vv/192):ifk<2thenvv=0:return
- 790 x$=x$+" ("+mid$(str$(k),2):vv=vv-k*192:k=1
- 800 ifc(k)<=vvthenk=k+1:goto800
- 810 vv=0:ifk>8thenx$=x$+" "+n$(k-1)+"s)":return
- 820 x$=x$+" cups)":return
- 830 if vv=0 then return
- 840 x$=x$+" ("+mid$(str$(int(vv)),2)+" "
- 850 k=1:j=vv-int(vv):ifj=0thenx$=x$+"cups)":return
- 860 if (j-cc(k))>.05 then k=k+1:goto860
- 870 x$=x$+n$(k)+"s)":return
- 880 v1=int(v):v2=v-v1:j=1
- 890 if(cc(j)-v2)>.0625then920
- 900 j=j+1:ifj<11then890
- 910 x$=mid$(str$(v1+1),2):return
- 920 x$="":ifv1>0thenx$=mid$(str$(v1),2)+"[160]"
- 930 x$=x$+cc$(j):return
-