home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1985 Spring / rerun-1985-spring.d64 / calcaid64 (.txt) next >
Commodore BASIC  |  2022-09-20  |  12KB  |  487 lines

  1. 1 dimda$(25,29),fc$(25,29),cu$(2),da(25,29)
  2. 5 cu$(1)=chr$(18)+" "+chr$(146)+chr$(157):cu$(2)=" "+chr$(157)
  3. 6 pa=1:z=0:p=100
  4. 20 gosub10000
  5. 30 printchr$(19);
  6. 40 fort=1to10:getg$:next
  7. 50 in$=""
  8. 52 de=0
  9. 54 printcu$(pa);
  10. 56 de=de+1
  11. 60 getg$
  12. 61 ifg$=chr$(34)then60
  13. 62 ifg$<>""then70
  14. 65 ifde<24then54
  15. 68 pa=3-pa
  16. 70 ifg$=chr$(29)thenifc<27thenc=c+1:gosub10000:goto30
  17. 71 ifg$=chr$(145)thenifrd>0thenrd=rd-1:gosub10000:goto30
  18. 72 ifg$=chr$(19)thenc=0:rd=0:goto9900
  19. 73 ifg$="_"then22000
  20. 74 ifg$=chr$(147)then350
  21. 75 ifg$=chr$(17)thenifrd<6thenrd=rd+1:gosub10000:goto30
  22. 76 ifg$=chr$(29)org$=chr$(145)org$=chr$(17)then60
  23. 77 ifg$=chr$(136)and(peek(53281)and15)<15thenpoke53281,(peek(53281)+1):goto60
  24. 78 ifg$=chr$(136)and(peek(53281)and15)=15thenpoke53281,0:goto60
  25. 79 ifg$=chr$(137)then400
  26. 80 ifg$=chr$(157)thenifc>0thenc=c-1:gosub10000:goto30
  27. 81 ifg$=chr$(133)thenprintchr$(18);"f";chr$(146);:goto140
  28. 82 ifg$=chr$(139)then13000
  29. 83 ifg$=chr$(140)and(peek(53280)and15)=15thenpoke53280,0:goto60
  30. 84 ifg$=chr$(140)and(peek(53280)and15)<15thenpoke53280,peek(53280)+1:goto60
  31. 85 ifg$=chr$(134)then24000
  32. 86 ifg$=chr$(138)then25000
  33. 87 ifg$=chr$(135)then13400
  34. 90 ifg$=chr$(13)then300
  35. 100 ifg$=chr$(20)then200
  36. 125 iflen(in$)>30then52
  37. 130 printg$;
  38. 140 in$=in$+g$
  39. 199 goto52
  40. 200 iflen(in$)=0then60
  41. 210 iflen(in$)=1thenprintchr$(20);:goto50
  42. 220 in$=left$(in$,len(in$)-1):printchr$(20);
  43. 230 goto60
  44. 300 ifleft$(in$,1)<"a"orleft$(in$,1)>"z"then20000
  45. 305 ifmid$(in$,2,1)<"0"ormid$(in$,2,1)>"9"then20000
  46. 306 ifmid$(in$,3,1)<"0"ormid$(in$,3,1)>":"then20000
  47. 310 ifval(mid$(in$,2,2))<0orval(mid$(in$,2,2))>29then20000
  48. 320 ifmid$(in$,3,1)<>":"andmid$(in$,4,1)<>":"then20000
  49. 330 goto500
  50. 350 gosub12500:ifg$="n"then9900
  51. 355 gosub12550
  52. 360 forr=0to25:forcd=0to29
  53. 370 da$(r,cd)="":fc$(r,cd)="":da(r,cd)=0
  54. 380 next:next:z=0
  55. 390 goto9900
  56. 400 printchr$(19);:print
  57. 410 printchr$(18);" maximum precision (0 to 6) press key "
  58. 420 getg$:ifg$<"0"org$>"6"then420
  59. 430 p=10^val(g$)
  60. 440 goto9900
  61. 500 gosub12000
  62. 520 ifmid$(in$,3,1)=":"thens=4:goto540
  63. 530 ifmid$(in$,4,1)=":"thens=5
  64. 540 ifmid$(in$,s,1)=chr$(133)then2000
  65. 550 ifmid$(in$,s,1)=""thenda$(r,cd)="":da(r,cd)=0:goto9900
  66. 1450 iffc$(r,cd)<>""thengoto11000
  67. 1500 t$=mid$(in$,s,1)
  68. 1510 ift$<"0"ort$>"9"thenift$<>"+"andt$<>"-"then1560
  69. 1512 da(r,cd)=val(mid$(in$,s,19))
  70. 1513 da$(r,cd)=mid$(in$,s,19)
  71. 1515 iflen(da$(r,cd))=9then1590
  72. 1518 iflen(da$(r,cd))>9then1580
  73. 1520 forx=1to9-len(da$(r,cd))
  74. 1530 da$(r,cd)=" "+da$(r,cd)
  75. 1540 next
  76. 1545 goto9900
  77. 1560 da$(r,cd)=mid$(in$,s,9):goto9900
  78. 1580 da$(r,cd)="*********"
  79. 1590 goto9900
  80. 2000 ifmid$(in$,s+1,1)="t"andlen(in$)=s+1then2010
  81. 2005 goto2020
  82. 2010 ifcd<>0andr<>0then20000
  83. 2015 z=1:ct=cd:rt=0:goto9900
  84. 2020 ifmid$(in$,s+1,1)="o"andlen(in$)=s+1then2030
  85. 2025 goto2040
  86. 2030 z=0:goto9900
  87. 2040 ifmid$(in$,s+1,3)="sum"thengosub14000:goto9900
  88. 2050 ifmid$(in$,s+1,3)="min"thengosub14000:goto9900
  89. 2060 ifmid$(in$,s+1,3)="max"thengosub14000:goto9900
  90. 2070 ifmid$(in$,s+1,3)="avg"thengosub14000:goto9900
  91. 2080 ifmid$(in$,s+1,3)="cop"thengosub14000:gosub26010:goto2085
  92. 2081 goto2110
  93. 2085 ifr1=r2then2100
  94. 2088 forx=r1tor2
  95. 2090 da(x,c1)=da(r,cd):da$(x,c1)=da$(r,cd)
  96. 2095 next:goto9900
  97. 2100 forx=c1toc2
  98. 2103 da(r1,x)=da(r,cd):da$(r1,x)=da$(r,cd)
  99. 2106 next:goto9900
  100. 2110 ifmid$(in$,s+1,1)="c"andlen(in$)=s+1then2120
  101. 2115 goto2130
  102. 2120 gosub12500
  103. 2125 ifg$="n"thengoto9900
  104. 2128 da(r,cd)=0:da$(r,cd)="":fc$(r,cd)="":goto9900
  105. 2130 ifmid$(in$,s+1,1)="v"andlen(in$)=s+1then2140
  106. 2135 goto2150
  107. 2140 gosub12600:goto9900
  108. 2145 goto9900
  109. 2150 ifmid$(in$,s+1,1)="j"andlen(in$)=s+1then2160
  110. 2155 goto2500
  111. 2160 c=val(mid$(in$,2,2)):ifc>27thenc=27
  112. 2162 ifasc(left$(in$,1))>84thenrd=6
  113. 2163 ifasc(left$(in$,1))<=84thenrd=0
  114. 2165 goto9900
  115. 2500 ifmid$(in$,s+1,1)<"a"ormid$(in$,s+1,1)>"z"then20000
  116. 2505 ifmid$(in$,s+2,1)<"0"ormid$(in$,s+2,1)>"9"then20000
  117. 2510 ifval(mid$(in$,s+2,2))<0orval(mid$(in$,s+2,2))>29then20000
  118. 2580 t$=mid$(in$,s+3,1)
  119. 2590 ift$="+"ort$="-"ort$="*"ort$="/"ort$="^"then2650
  120. 2600 t$=mid$(in$,s+4,1)
  121. 2610 ift$="+"ort$="-"ort$="*"ort$="/"ort$="^"then2670
  122. 2620 goto20000
  123. 2650 s1=s+4:goto2680
  124. 2670 s1=s+5
  125. 2680 ifmid$(in$,s1,1)<"a"ormid$(in$,s1,1)>"z"then3000
  126. 2690 ifmid$(in$,s1+1,1)<"0"ormid$(in$,s1+1,1)>"9"then20000
  127. 2700 ifval(mid$(in$,s1+1,2))<0orval(mid$(in$,s1+1,2))>29then20000
  128. 2710 goto3100
  129. 3000 ift$="/"andval(mid$(in$,s1,19))=0then20000
  130. 3100 fc$(r,cd)=mid$(in$,s,19)
  131. 9900 gosub10000
  132. 9910 printchr$(19);
  133. 9999 goto50
  134. 10000 printchr$(147)
  135. 10010 printchr$(18);"                                        "
  136. 10015 ifz=1thenprinttab(5);ct;tab(16);c+1;tab(27);c+2:goto10021
  137. 10020 printtab(5);c;tab(16);c+1;tab(27);c+2
  138. 10021 ifz=1then10026
  139. 10022 printchr$(65+rd);:printtab(2);da$(rd,c);
  140. 10023 printtab(13);da$(rd,c+1);
  141. 10024 printtab(24);da$(rd,c+2)
  142. 10025 goto10030
  143. 10026 printchr$(65+rt);:printtab(2);da$(rt,ct);
  144. 10027 printtab(13);da$(rt,c+1);
  145. 10028 printtab(24);da$(rt,c+2)
  146. 10030 forr=rd+1tord+19
  147. 10040 printchr$(65+r);
  148. 10045 ifz=1thenprinttab(2);da$(r,ct);:goto10060
  149. 10050 printtab(2);da$(r,c);
  150. 10060 printtab(13);da$(r,c+1);
  151. 10070 printtab(24);da$(r,c+2)
  152. 10080 next
  153. 10090 return
  154. 11000 printchr$(19);:print
  155. 11005 printchr$(18);"protected formula  ";fc$(r,cd)
  156. 11010 getg$:ifg$=""then11010
  157. 11020 goto20
  158. 12000 r=asc(left$(in$,1))-65
  159. 12010 cd=val(mid$(in$,2,2))
  160. 12020 return
  161. 12500 printchr$(19);:print
  162. 12505 printchr$(18);" are you sure press 'y' or 'n' "
  163. 12510 getg$:ifg$<>"y"andg$<>"n"then12510
  164. 12520 return
  165. 12550 printchr$(19);:print
  166. 12555 printchr$(18);" working    please wait...        "
  167. 12560 return
  168. 12600 printchr$(19);:print
  169. 12605 printchr$(18);
  170. 12606 iffc$(r,cd)<>""thenprint"form. ";fc$(r,cd);" - ";
  171. 12607 print"val.";da(r,cd)
  172. 12610 getg$:ifg$=""then12610
  173. 12620 return
  174. 13000 printchr$(19);:print
  175. 13005 printchr$(18);"press 'space' to print-'return' to exit"
  176. 13010 getg$:ifg$<>chr$(32)andg$<>chr$(13)then13010
  177. 13020 ifg$=chr$(13)then9900
  178. 13030 open4,4
  179. 13040 r=0:cd=0
  180. 13050 iffc$(r,cd)<>""then13080
  181. 13060 cd=cd+1:ifcd=30thencd=0:r=r+1:ifr=26then13300
  182. 13070 goto13050
  183. 13080 print#4,chr$(r+65);cd;
  184. 13090 print#4,chr$(16)"06";fc$(r,cd);
  185. 13100 cd=cd+1:ifcd=30thencd=0:r=r+1:ifr=26then13300
  186. 13110 iffc$(r,cd)<>""then13140
  187. 13120 cd=cd+1:ifcd=30thencd=0:r=r+1:ifr=26then13300
  188. 13130 goto13110
  189. 13140 print#4,chr$(16)"20";chr$(r+65);cd;
  190. 13150 print#4,chr$(16)"26";fc$(r,cd);
  191. 13160 cd=cd+1:ifcd=30thencd=0:r=r+1:ifr=26then13300
  192. 13170 iffc$(r,cd)<>""then13200
  193. 13180 cd=cd+1:ifcd=30thencd=0:r=r+1:ifr=26then13300
  194. 13190 goto13170
  195. 13200 print#4,chr$(16)"40";chr$(r+65);cd;
  196. 13210 print#4,chr$(16)"46";fc$(r,cd);
  197. 13220 cd=cd+1:ifcd=30thencd=0:r=r+1:ifr=26then13300
  198. 13230 iffc$(r,cd)<>""then13260
  199. 13240 cd=cd+1:ifcd=30thencd=0:r=r+1:ifr=26then13300
  200. 13250 goto13230
  201. 13260 print#4,chr$(16)"60";chr$(r+65);cd;
  202. 13270 print#4,chr$(16)"46";fc$(r,cd)
  203. 13280 goto13060
  204. 13300 print#4,chr$(10)
  205. 13310 print#4
  206. 13320 close4:goto9900
  207. 13400 printchr$(147):print"          print spreadsheet"
  208. 13410 print:print
  209. 13420 print"     enter the top left cell
  210. 13430 [153]"         to be printed or
  211. 13440 print"      press 'return' to exit"
  212. 13450 print:g$=""
  213. 13460 input"              ";g$:ifg$=""then9900
  214. 13465 ifg$<"a0"org$>"z9"then13400
  215. 13467 r1=asc(left$(g$,1))-65:tc=val(mid$(g$,2)):iftc>29then13400
  216. 13470 printchr$(147):print"          print spreadsheet"
  217. 13472 print:print
  218. 13474 print"    enter the bottom right cell
  219. 13476 [153]"         to be printed or
  220. 13478 print"      press 'return' to exit"
  221. 13480 print:t$=""
  222. 13482 input"              ";t$:ift$=""then9900
  223. 13484 ift$<"a0"ort$>"z9"then13470
  224. 13486 r2=asc(left$(t$,1))-65:t=val(mid$(t$,2)):ift<tcthen13470
  225. 13487 ifr2<r1then13470
  226. 13488 gosub13700
  227. 13490 t$=chr$(16)
  228. 13500 open4,4
  229. 13505 print#4,chr$(10)
  230. 13525 forr=r1tor2
  231. 13535 iftc>tthen13700
  232. 13540 print#4,t$;"03";da$(r,tc);
  233. 13545 iftc+1>tthen13600
  234. 13550 print#4,t$;"14";da$(r,tc+1);
  235. 13555 iftc+2>tthen13600
  236. 13560 print#4,t$;"25";da$(r,tc+2);
  237. 13565 iftc+3>tthen13600
  238. 13570 print#4,t$;"36";da$(r,tc+3);
  239. 13575 iftc+4>tthen13600
  240. 13577 print#4,t$;"47";da$(r,tc+4);
  241. 13580 iftc+5>tthen13600
  242. 13585 print#4,t$;"58";da$(r,tc+5);
  243. 13590 iftc+6>tthen13600
  244. 13595 print#4,t$;"69";da$(r,tc+6);
  245. 13600 print#4,chr$(13);:next
  246. 13610 tc=tc+7:iftc>tthenprint#4:close4:goto9900
  247. 13620 printchr$(147):print:print
  248. 13630 print"      ...... more to come ......"
  249. 13635 print
  250. 13640 print"      please align printer paper"
  251. 13650 print"