home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1987 March & April / rerun-1987-03-04.d64 / recipe (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  3KB  |  85 lines

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