home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1989 December / 1989-12.d64 / kterm (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  5KB  |  204 lines

  1. 10 rem copyright 1989 compute! publications, inc. - all rights reserved
  2. 20 poke53280,14:poke53281,14:poke169,1
  3. 30 print"[147]";chr$(14);chr$(8);spc(10);
  4. 40 print"[147]":printtab(6)"[195]opyright 1989 [195][207][205][208][213][212][197]!"
  5. 50 printtab(8)"[208]ublications, [201]nc."
  6. 60 printtab(8)"[193]ll [210]ights [210]eserved":print
  7. 70 for jf=1to3000:next:print:print
  8. 130 print"[203]ermit [198]ile [212]ransfer":print
  9. 140 input"[206]umber of [196]ata [194]its ? 8[157][157][157]";b
  10. 150 if b<>7 then open 2,2,0,chr$(6)+chr$(0):b=0
  11. 160 if b=7 then open 2,2,0,chr$(38)+chr$(96):b=128
  12. 170 open 15,8,15:z$=chr$(0):print
  13. 180 gosub420:dim r(255),s(255),n$(143)
  14. 190 h(1)=32:h(2)=192:h(3)=64:print
  15. 200 for i=0 to 31:s(i)=i:next
  16. 210 r(8)=20:r(13)=13:s(20)=8:s=32
  17. 220 for j=1 to 3:g=h(j):for i=g to g+31
  18. 230 s(i)=s:r(s)=i:s=s+1:next:next
  19. 240 def fnc(i)=32+(i+(i and 192)/64 and 63)
  20. 250 def fnt(i)=(i or 64)-(i and 64)
  21. 260 b$=chr$(20):c$="[175]":print"[144]";c$;
  22. 270 get#2,g$:if g$="" then 290
  23. 280 g=asc(g$):gosub370:goto270
  24. 290 get g$:g=asc(g$+z$):if g=0 then 270
  25. 300 if g>132 and g<137 then 330
  26. 310 g=s(g):if h then gosub370
  27. 320 print#2,chr$(g);:goto270
  28. 330 printb$;"":n$="":t$="":e=0
  29. 340 on g-132 gosub390,450,760,420
  30. 350 print:goto260
  31. 360 rem ++ print byte ++
  32. 370 printb$;chr$(r(g));c$;:return
  33. 380 rem ++ f1, echo ++
  34. 390 print"[197]cho: ";mid$("[207]n [207]ff",h+1,3)
  35. 400 h=3-h:return
  36. 410 rem ++ f7, help ++
  37. 420 print"[198]1[146]=[197]cho  [198]3[146]=[210]eceive  [198]5[146]=[211]end  [198]7[146]=[200]elp"
  38. 430 return
  39. 440 rem ++ f3, receive ++
  40. 450 input"[210]eceive: [198]ile [212]ype ? s[157][157][157]";t$
  41. 460 if t$="" then return
  42. 470 gosub1890:gosub1670:p=4:gosub670
  43. 480 if e=0 then gosub1920
  44. 490 if e>1 then 630
  45. 500 e=0:gosub1320:p=0:p$=""
  46. 510 gosub670:if w$="b" then e=2
  47. 520 if e then 630
  48. 530 gosub2050:i$=i$+","+t$
  49. 540 open 8,8,8,i$+",w":gosub2020
  50. 550 if e then 620
  51. 560 gosub1320:gosub670
  52. 570 if w$="z" then e=1
  53. 580 if e then 620
  54. 590 print#8,i$;
  55. 600 if st then e=5:i$="write error"
  56. 610 goto550
  57. 620 close 8:gosub2020:goto490
  58. 630 if e>4 then u$="e"+i$
  59. 640 p=0:p$="":if e<>4 then gosub1320
  60. 650 goto1150
  61. 660 rem ++ receive packet ++
  62. 670 for j=1 to 5:x=p:gosub1490
  63. 680 printmid$("+o.o",y,1);
  64. 690 u$=mid$("yynn",y,1):u=k
  65. 700 on y goto730,710,720,720
  66. 710 u=k-1 and 63:u$=u$+a$:x=a
  67. 720 gosub1320:next:e=4:return
  68. 730 k=k+1 and 63:u$=u$+p$
  69. 740 a$=p$:a=p:return
  70. 750 rem ++ f5, send ++
  71. 760 input"[211]end: [215]hich [198]ile(s) ";n$
  72. 770 if n$="" then return
  73. 780 open 8,8,0,"$:"+n$
  74. 790 gosub2020:if e then 910
  75. 800 get#8,g$,g$:for n=0 to 143
  76. 810 get#8,g$,g$,g$,i$
  77. 820 if st then 910
  78. 830 n$=str$(asc(g$+z$)+asc(i$+z$)*256)
  79. 840 for i=1 to 40:get#8,g$,i$
  80. 850 n$=n$+g$+i$:if i$>"" then next
  81. 860 t$=mid$(n$,25,1)
  82. 870 if t$<>"p" and t$<"s" then 810
  83. 880 for i=7 to 23
  84. 890 if mid$(n$,i,1)<>chr$(34) then next
  85. 900 n$(n)=mid$(n$,7,i-7):next n
  86. 910 close 8:gosub2020:if e then 1150
  87. 920 print"[206]umber of [198]iles:";n
  88. 930 if n=0 then return
  89. 940 gosub1890:u$="s"+p$:x=4:gosub1250
  90. 950 x=0:if e then 1120
  91. 960 gosub1920:f=0
  92. 970 e=0:if f=n then e=2:goto1110
  93. 980 i$=n$(f):gosub2050
  94. 990 u$="f"+i$:gosub1200:if e then 1110
  95. 1000 open 8,8,8,n$(f):gosub2020
  96. 1010 if e then 1090
  97. 1020 u$="":v=0:for i=1 to 96
  98. 1030 get#8,g$:g=asc(g$+z$):u$=u$+chr$(g)
  99. 1040 if g and b then v=v+1:g=g-b
  100. 1050 if g<32 or g=35 or g=q or g=127 then v=v+1
  101. 1060 if st then e=1:goto1080
  102. 1070 if i+v<p(1) then next
  103. 1080 u$="d"+u$:gosub1250:goto1010
  104. 1090 if e<3 then u$="z":gosub1200:f=f+1
  105. 1100 close 8:gosub2020:if e<2 then 970
  106. 1110 if e<3 then u$="b":gosub1200
  107. 1120 if e<5 then 1150
  108. 1130 u$="e"+i$:gosub1200:i$=mid$(u$,2)
  109. 1140 rem ++ end message ++
  110. 1150 u$="[195]omplete[210]emote [157][212]imeout [204]ocal"
  111. 1160 print:printmid$(u$,e*8-15,8);
  112. 1170 if (e and 1)=0 then print:return
  113. 1180 gosub2050:print" ";i$:return
  114. 1190 rem ++ send string ++
  115. 1200 v=0:for i=1 to len(u$)
  116. 1210 g=asc(mid$(u$,i,1)+z$)
  117. 1220 if g<32 or g=35 or g=q then v=v+1
  118. 1230 next
  119. 1240 rem ++ send packet ++
  120. 1250 for j=1 to 5:u=k:gosub1320
  121. 1260 gosub1490
  122. 1270 if w$="n" and (y=1 or p) then y=4
  123. 1280 printmid$("++.o",y,1);
  124. 1290 if y<3 then k=k+1 and 63:return
  125. 1300 next:e=4:return
  126. 1310 rem ++ put packet ++
  127. 1320 i=1:c=66+len(u$)+v+u:gosub1670
  128. 1330 if i>p(3) then 1350
  129. 1340 print#2,chr$(p(4));:i=i+1:goto1330
  130. 1350 print#2,chr$(1);chr$(len(u$)+v+34);chr$(u+32);
  131. 1360 for i=1 to len(u$)
  132. 1370 g=asc(mid$(u$,i,1)):if x then 1410
  133. 1380 if g and b then s=q:gosub1470:g=g-b
  134. 1390 if g<32 or g=127 then gosub1450:g=fnt(g):goto1410
  135. 1400 if g=35 or g=q then gosub1450
  136. 1410 s=g:gosub1470:next
  137. 1420 print#2,chr$(fnc(c));chr$(p(5));
  138. 1430 return
  139. 1440 rem ++ put byte '#' ++
  140. 1450 s=35
  141. 1460 rem ++ put byte s ++
  142. 1470 c=c+s:print#2,chr$(s);:return
  143. 1480 rem ++ get packet ++
  144. 1490 i$="":y=2:w$="":t=ti+p(2)
  145. 1500 get#2,g$:if st and 247 then 1500
  146. 1510 if g$<>chr$(1) and ti<t then 1500
  147. 1520 c=0:if g$<>chr$(1) then 1650
  148. 1530 gosub1700:if y then 1650
  149. 1540 d=g-32:gosub1700:if y then 1650
  150. 1550 u=g-32:gosub1700:if y then 1650
  151. 1560 w$=g$:w=x+1:if d<4 then 1610
  152. 1570 for i=4 to d
  153. 1580 gosub1700:if y then 1650
  154. 1590 on w gosub1750,1800,1830,1860,1780
  155. 1600 next
  156. 1610 c=-fnc(c):gosub1700:if y then 1650
  157. 1620 if c then y=2:w$="":goto1650
  158. 1630 gosub1700:if y then 1650
  159. 1640 c=u<>k:if w$="e" then e=3
  160. 1650 y=y+1:if c then y=y+1
  161. 1660 rem ++ clear input buffer ++
  162. 1670 get#2,g$:if g$="" then return
  163. 1680 goto1670
  164. 1690 rem ++ get byte ++
  165. 1700 get#2,g$:y=st:if y then 1720
  166. 1710 g=asc(g$):c=c+g:return
  167. 1720 if y=8 and ti<t then 1700
  168. 1730 y=2:w$="":return
  169. 1740 rem ++ decode byte ++
  170. 1750 if g=p(6) then w=2:return
  171. 1760 if g=q then w=3:return
  172. 1770 rem ++ add byte ++
  173. 1780 i$=i$+chr$(g):return
  174. 1790 rem ++ control byte ++
  175. 1800 if g<>p(6) and g<>q then g=fnt(g)
  176. 1810 i$=i$+chr$(g):w=1:return
  177. 1820 rem ++ quoted byte ++
  178. 1830 if g=p(6) then w=4:return
  179. 1840 i$=i$+chr$(g or 128):w=1:return
  180. 1850 rem ++ quoted control byte ++
  181. 1860 if g<>p(6) and g<>q then g=fnt(g)
  182. 1870 i$=i$+chr$(g or 128):w=1:return
  183. 1880 rem ++ initialize parameters ++
  184. 1890 k=0:v=0:q=0:i$=""
  185. 1900 d$=chr$(112)+"% @-#n"
  186. 1910 rem ++ set parameters ++
  187. 1920 for i=1 to 7:g$=mid$(i$,i,1)
  188. 1930 if g$<"!" then g$=mid$(d$,i,1)
  189. 1940 p(i)=asc(g$):next:p(1)=p(1)-36
  190. 1950 p(2)=60*(p(2)-32):p(3)=p(3)-32
  191. 1960 p(4)=p(4)-32:p(5)=p(5)-32
  192. 1970 g=((p(7) and 63)+1 and 63)>32
  193. 1980 g$="y":if g then q=p(7):goto2000
  194. 1990 if b then g$="&":if p(7)=89 then q=38
  195. 2000 p$=chr$(126)+", @-#"+g$:return
  196. 2010 rem ++ check drive ++
  197. 2020 input#15,g,g$:if g then e=5:i$=g$
  198. 2030 return
  199. 2040 rem ++ convert i$ ++
  200. 2050 g$="":for i=1 to len(i$)
  201. 2060 g=asc(mid$(i$,i,1)+z$)
  202. 2070 if g>95 then g=g and 95
  203. 2080 g$=g$+chr$(g):next:i$=g$:return
  204.