home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / misc / replace.lbr / REPLACE.BZS / REPLACE.BAS
Encoding:
BASIC Source File  |  1993-10-25  |  14.1 KB  |  299 lines

  1. 10 '    *****************************************************
  2.  
  3.     *****       UTILITY  REPLACEMENT  PROGRAM    *****
  4. 11 '    *****                        *****
  5.  
  6.     *****        by Richard Altman        *****
  7.  
  8.     *****            2/15/90            *****
  9. 12 '    *****                        *****
  10.  
  11.     *****    Copyright (c) 1990 by Richard Altman    *****
  12.  
  13.     *****************************************************
  14. 13 '
  15. 14 '
  16. 15 '     USER SUPPORTED
  17. 16 '     ==== =========
  18. 17 '
  19. 18 '     This program is user-supported software.  It is copyrighted and cannot
  20. 19 ' be sold for profit (without the author's express written permission),  but
  21. 20 ' it may be copied and distributed for free.
  22. 21 '
  23. 22 '     The  SHAREWARE  concept is a  distribution method  that dispenses with
  24. 23 ' heavy  marketing/advertising costs and gives the user the  opportunity  to
  25. 24 ' try a software program before buying.   Its continued existence depends on
  26. 25 ' each user paying for what he does, in fact, use.
  27. 26 '
  28. 27 '     If you find this program [REPLACE.BAS] useful, please send the $20 (or
  29. 28 ' more) registration fee directly to the author:
  30. 29 '
  31. 30 '        Richard S. Altman -- P.O. Box 4388 -- Clearlake, CA 95422
  32. 31 '
  33. 32 '      Upon registration,  you will receive a floppy diskette containing the
  34. 33 ' latest version of this program, as well as a printed manual and a COMPILED
  35. 34 ' version.  You will also receive a FREE calendar printing program and other
  36. 35 ' programs by the same author.
  37. 36 '
  38. 37 '      WHEN ORDERING,  please be sure to indicate  single or double  density
  39. 38 ' disk drive,  and the name of the program  [REPLACE.BAS].  Comments on pro-
  40. 39 ' grams are also most welcome!
  41. 40 '
  42. 41 '     Due to  possible unforeseen circumstances,  the above offer is subject
  43. 42 ' to change without notice.
  44. 43 '
  45. 44 ' **************************************************************************
  46. 45 '    SET UP VARIABLES:
  47.  
  48.     String:    A$-F$      Integer:    G-Z
  49.  
  50.  
  51. 46 DEFINT G-Z:DEFSTR A-F:DIM F(24),E(500),D(8),C(8),A(12)
  52. 47 CLR=CHR$(24): CX=CHR$(23): E=CHR$(32): C=CHR$(34):CLS=CHR$(26)
  53. 48 ESC$=CHR$(27):FE=ESC$+"=":GOSUB 5020:F=STRING$(6,32):FR=STRING$(60,45)
  54. 49 FOR X=1 TO 24:F(X)=FE+CHR$(X+31)+E:NEXT:C7=CHR$(7):FS=STRING$(79,45)
  55. 50 DEF FNF(X,Y)=FE+CHR$(X+31)+CHR$(Y+31):LP=0:ON ERROR GOTO 6500
  56. 51 DEF FNTITLE$(X,M$)=FNF(X,1)+STRING$((80-LEN(M$))/2,12)+M$:WIDTH 255
  57. 52 U$=" UTILITY   REPLACEMENT  PROGRAM ":GOSUB 7000:GOSUB 80:GOTO 100
  58. 55 '
  59. 70 L$=A(X)+" to "+A(X+1):GOSUB 5050:PRINT",  ";:X=X+2:RETURN
  60. 75 PRINT CLS;FS:L$=FNF(2,23)+E+U$+E:GOSUB 5065:PRINT:PRINT FS:RETURN
  61. 80 PRINT F(5)CX:RETURN
  62. 85 '
  63. 100 '    Display Opening Screen
  64. 105 PRINT FNF(7,7)"This program will replace any portions of your program with"
  65. 110 PRINT F"anything you wish.   To use it, you must:"
  66. 115 PRINT FNF(10,10)"1.  Be sure each line of your program is less than ";
  67. 120 PRINT"245 bytes."FNF(11,10)"2.  Save your program in ";:L$="ASCII format"
  68. 125 GOSUB 5050:PRINT":  ("C"FILENAME"C",A)."
  69. 130 PRINT FNF(12,10)"3.  The Disk must have enough free space for a 2nd ";
  70. 135 PRINT"ASCII copy."FNF(13,10)"4.  Run this REPLACEMENT UTILITY."
  71. 140 L$=FNF(18,10)+"  Are you ready to run the REPLACEMENT Utility ?   (Y/N)  "
  72. 145 PRINT FNF(19,37)"~~~~~~~~~~~ ~~~~~~~"C7:GOSUB 5065:PRINT"   ";
  73. 150 GOSUB 6000:IF AK="Y" OR AK=CHR$(13) THEN 160
  74. 155 IF AK="N" THEN PRINT:PRINT:END:GOTO 150 ELSE 150
  75. 160 PRINT FNF(18,10)CX"What is the FILENAME of your program--- ";
  76. 165 INPUT FLNAME:IF FLNAME="" THEN 160
  77. 175 IF RIGHT$(FLNAME,4)<>".BAS" THEN FLNAME=FLNAME+".BAS"
  78. 180 '
  79. 200 '    Check for File's existance
  80. 210 L$=FNF(18,10)+"Checking to see if `"+FLNAME+"' exists...."
  81. 220 GOSUB 5050:PRINT"   "CX;:FOR T=1 TO 500:NEXT
  82. 230 NAME FLNAME AS FLNAME
  83. 240 L1=LEN(FLNAME):A1=FLNAME:FOR X=1 TO L1
  84. 250 IF ASC(MID$(A1,X,1))>90 THEN MID$(A1,X,1)=CHR$(ASC(MID$(A1,X,1))-32)
  85. 260 NEXT:FLNAME=A1:GOSUB 8500
  86. 270 '
  87. 300 '    Check for Long Lines
  88. 310 L$="Checking for over-long lines....":PRINT FNF(20,10)CX;:GOSUB 5050
  89. 320 PRINT"   ";:OPEN "I",1,FLNAME:L=0
  90. 330 IF EOF(1) THEN CLOSE:IF K=1 THEN 1500 ELSE PRINT C7:GOTO 400
  91. 340 L=L+1:LINE INPUT #1,A
  92. 350 IF K=1 THEN 360 ELSE IF LEN(A)>245 THEN PRINT FNF(6,7)L$;CX;F(8)
  93. 360 IF LEN(A)>245 THEN PRINT"Line "LEFT$(A,INSTR(A," "))"is"LEN(A)"bytes.":K=1
  94. 370 GOTO 330
  95. 380 '
  96. 400 '    Input NAME2
  97. 405 L$=FNF(20,10)+"The modified program will be saved under a different FILENAME.":GOSUB 5050
  98. 410 LL=L:PRINT FNF(21,10)"What will be the ";:L$="new":GOSUB 5050
  99. 415 PRINT" FILENAME--- "CLR;:INPUT FLNAME2
  100. 420 IF FLNAME2="" THEN 405
  101. 425 LX=1:LX=INSTR(FLNAME2,"."):IF LX>0 THEN 435
  102. 430 IF RIGHT$(FLNAME2,4)<>".BAS" THEN FLNAME2=FLNAME2+".BAS"
  103. 435 IF FLNAME<>FLNAME2 THEN 450
  104. 440 L$=FNF(21,10)+"  The FILENAMEs must be different.  "+C7+CX:GOSUB 5065
  105. 445 FOR T=1 TO 3000:NEXT:GOTO 405
  106. 450 L2=LEN(FLNAME2):A2=FLNAME2:FOR X=1 TO L2
  107. 455 IF ASC(MID$(A2,X,1))>90 THEN MID$(A2,X,1)=CHR$(ASC(MID$(A2,X,1))-32)
  108. 460 NEXT:FLNAME2=A2
  109. 465 '
  110. 500 '    Input Strings to Replace
  111. 505 PRINT FNF(7,7)CX"Filename:  "FLNAME"        Modified Filename:  ";
  112. 510 PRINT FLNAME2;FNF(2,66)D2$;
  113. 515 J=0:PRINT F(9)CX;C7
  114. 520 FOR M=1 TO 8:PRINT FNF(M+9,7)"Replace what?  ";
  115. 525 BX="":LINE INPUT BX:D(M)=BX:L(M)=LEN(BX)
  116. 530 IF BX="" THEN IF M=1 THEN 520 ELSE PRINT:GOTO 555
  117. 535 PRINT FNF(M+9,40)"With what?  ";:DX=""
  118. 540 LINE INPUT DX:C(M)=DX:M(M)=LEN(DX):IF M(M)>L(M) THEN J=1
  119. 545 NEXT M:PRINT FNF(20,7)"You have reached the maximum of eight changes."
  120. 550 PRINT FNF(22,7)"Press <ANY KEY> to continue.   ";:GOSUB 6000
  121. 555 PRINT FNF(19,7)CX;:L$=" Check the above CHANGES. ":GOSUB 5065
  122. 560 PRINT"    ";:L$=" Are they correct? ":GOSUB 5065
  123. 565 PRINT FNF(20,7)FR;FNF(19,57)"(Y/N)   "C7;
  124. 570 GOSUB 6000:IF AK="Y" OR AK=CHR$(13) THEN 600 ELSE IF AK<>"N" THEN 570
  125. 575 PRINT FNF(21,7)"Press <A> to ABORT `NO' answer and continue."CX
  126. 580 PRINT F"Press <RETURN> to retype above responses.   ";
  127. 585 GOSUB 6000:IF AK="A" THEN 600 ELSE IF AK=CHR$(13) THEN 515 ELSE 585
  128. 590 '
  129. 600 '    Check for NEW STRINGS longer than ORIGINAL
  130. 610 IF J=0 THEN 1000
  131. 620 L$=FNF(20,7)+"  <<< WARNING >>>  ":PRINT F(18)CX;FNF(19,7)FR"----"
  132. 630 PRINT F;:GOSUB 5065:PRINT"   Since you are replacing some parts of your"
  133. 640 PRINT F"program with ";:L$="larger parts":GOSUB 5050:L$="may"
  134. 650 PRINT",  the new lines ";:GOSUB 5050:PRINT" be longer than 245"
  135. 660 PRINT F"bytes.  If this happens, you will not be able to load the program"
  136. 670 PRINT F"back into the computer again.     (C)ontinue/ (A)bort   ";
  137. 680 GOSUB 6000:IF AK="C" THEN PRINT F(20)CX:GOTO 1000
  138. 690 IF AK="A" THEN 555 ELSE 680
  139. 700 '
  140. 1000 '    ====  REPLACE  ====
  141. 1010 OPEN "I",1,FLNAME:OPEN"O",2,FLNAME2:GOSUB 80:R=0
  142. 1020 PRINT FNF(7,7)L"line";:IF L<>1 THEN PRINT"s";
  143. 1030 PRINT" left to modify.  ":L$=FNF(7,40)+"New":GOSUB 5050
  144. 1040 PRINT" Filename:  "FLNAME2:GOSUB 5025
  145. 1050 IF EOF(1) THEN Z=12:GOTO 2000
  146. 1060 LINE INPUT #1,A:FOR Q=1 TO M-1:N=1
  147. 1070 N=INSTR(N,A,D(Q)):IF N>0 THEN LQ=1:A=LEFT$(A,N-1)+C(Q)+RIGHT$(A,LEN(A)-N-L(Q)+1):N=N+M(Q):GOTO 1070
  148. 1080 NEXT Q:IF LQ=1 THEN LX=INSTR(A," "):R=R+1:E(R)=LEFT$(A,LX):LQ=0
  149. 1090 PRINT #2,A:PRINT F(10);:LX=1:LX=INSTR(A,CHR$(10))
  150. 1110 IF LX>0 AND LX<71 THEN PRINT LEFT$(A,LX)CX:GOTO 1130
  151. 1120 PRINT LEFT$(A,70)CX
  152. 1130 L=L-1:GOTO 1020
  153. 1140 '
  154. 1500 '    Some lines need to be shortened
  155. 1510 PRINT:PRINT:PRINT F;
  156. 1520 L$="  Your program has NOT been modified.   The above lines need to  "
  157. 1530 GOSUB 5065:PRINT:PRINT F;C7;
  158. 1540 L$="  be shortened.  You will have to edit them before continuing.   "
  159. 1550 GOSUB 5065:END:GOTO 555 
  160. 1560 '
  161. 1750 GOSUB 80:Z=12
  162. 1770 '
  163. 2000 '    Search is Finished/ Display Options
  164. 2010 PRINT F(Z):L$=STRING$(79,32):GOSUB 5050:PRINT C7:L$="  OPTIONS:  "
  165. 2020 GOSUB 5065:PRINT"  [D]  Display List of Changed Lines"
  166. 2025 PRINT FNF(Z+2,52)" [Q]  Quit to SYSTEM":GOSUB 5020
  167. 2030 PRINT FNF(Z+3,14)" [P]  =Print= List of Changed Lines"
  168. 2035 PRINT FNF(Z+3,52)" [L]  Load `"FLNAME2"'   ";:CLOSE
  169. 2040 GOSUB 6000:IF AK="D" OR AK=CHR$(13) THEN 3000
  170. 2050 IF AK="P" THEN 3500
  171. 2055 IF AK="L" THEN 4000
  172. 2060 IF AK="Q" THEN 4500 ELSE 2040
  173. 2070 '
  174. 3000 '    Display List
  175. 3010 GOSUB 80:GOSUB 5025:K=1:KQ=160:KK=0:NG=8:IF R<109 THEN NG=12
  176. 3015 NL=5:NF=1:KK=KK+KQ:IF R<KK THEN KK=R
  177. 3020 FOR Y=K TO KK
  178. 3025 PRINT FNF(NL,NF)E(Y);:NL=NL+1
  179. 3029 IF NL=21 THEN NL=5:NF=NF+NG
  180. 3030 NEXT Y:IF R>KK THEN K=K+KQ:GOSUB 3050:GOTO 3015
  181. 3040 Z=20:GOTO 2000
  182. 3045 '
  183. 3050 '    End of Page Subroutine
  184. 3060 L$=FNTITLE$(23,"   Press <ANY KEY> to continue.   ")
  185. 3065 GOSUB 5020:GOSUB 3070:GOSUB 80:GOTO 5025
  186. 3070 AQ=INKEY$:AK=""
  187. 3100 GOSUB 5065:TX=0
  188. 3110 AK=INKEY$:IF AK<>"" THEN RETURN ELSE TX=TX+1:IF TX<150 THEN 3110
  189. 3120 PRINT L$;:TX=0
  190. 3130 AK=INKEY$:IF AK<>"" THEN RETURN ELSE TX=TX+1:IF TX<100 THEN 3130
  191. 3140 GOTO 3100
  192. 3150 '
  193. 3500 '    Print List on Printer
  194. 3505 LP=9:GOSUB 80:GOSUB 5020
  195. 3510 PRINT FNF(9,7)"SEARCH List is being output to Printer.   ";
  196. 3515 LPRINT ESC$"N"ESC$"!":WIDTH LPRINT 80:JK=R/6
  197. 3520 LPRINT FS:LPRINT"     "FLNAME2;TAB(25)U$;TAB(62)"Date: "D2$
  198. 3525 LN=22:LPRINT"     Replacements:  ";:FOR Y=1 TO 8
  199. 3530 LN=LN+LEN(C(Y))+2:IF C(Y)="" THEN LN=LN-2:GOTO 3545
  200. 3532 IF LN<80 THEN 3540
  201. 3535 LPRINT:LN=22:LPRINT STRING$(20,32);
  202. 3540 LPRINT C(Y)"//";
  203. 3545 NEXT Y:LPRINT FS:LPRINT ESC$"E";ESC$;CHR$(34):WIDTH LPRINT 96
  204. 3550 FOR Y=1 TO JK:IF E(Y)="" THEN 3560
  205. 3555 LPRINT F;E(Y);TAB(20)E(Y+JK);TAB(34)E(Y+JK*2);TAB(48)E(Y+JK*3);
  206. 3560 LPRINT TAB(62)E(Y+JK*4);TAB(76)E(Y+JK*5)
  207. 3565 NEXT Y:LPRINT CHR$(12):GOTO 1750
  208. 3570 '
  209. 4000 '    End Program   ***   Load MODIFIED Program
  210. 4010 GOSUB 4100:L$=FNF(8,7)+"  FINISHED MODIFYING  "+C7:GOSUB 5065
  211. 4020 PRINT FNF(10,7)">>>>>  The original program: `"FLNAME"' remains on the ";
  212. 4030 PRINT"disk in its":PRINT F"ASCII format.  It has NOT been changed."
  213. 4035 PRINT FNF(14,7)">>>>>  The modified program: `"FLNAME2"' is now being ";
  214. 4040 PRINT"loaded back in.":PRINT F"You should SAVE it on the disk ";
  215. 4050 PRINT"again using MBASIC:   ";:A=FLNAME2
  216. 4055 LX=INSTR(A,"."):L$=" SAVE "+C+LEFT$(A,LX-1)+C+" ":GOSUB 5065:PRINT
  217. 4060 PRINT F"so it will load faster than the ASCII version."
  218. 4070 GOSUB 5020:CLOSE:PRINT F(18):LOAD FLNAME2:END:RUN
  219. 4080 '
  220. 4100 '    Check for Hard Copy
  221. 4110 GOSUB 80:IF LP=9 THEN RETURN
  222. 4120 L$=FNF(9,7)+"You haven't PRINTED the List of Changed Lines"+C7:GOSUB 5050
  223. 4130 PRINT"."FNF(11,7)"Are you sure you're ready to LOAD:  `"FLNAME2"'  ??   ";
  224. 4140 GOSUB 6000:IF AK="Y" THEN LP=9:GOTO 4100
  225. 4150 IF AK="N" OR AK=CHR$(13) THEN 1750 ELSE 4140
  226. 4160 ' 
  227. 4500 '    Quit to SYSTEM
  228. 4510 GOSUB 80
  229. 4520 PRINT FNF(9,7)"Do you really want to QUIT to SYSTEM ??  (Y/N)   "C7;
  230. 4530 GOSUB 6000:IF AK="N" OR AK=CHR$(13) THEN 1750
  231. 4540 IF AK="Y" THEN PRINT F(7)"End of Program":SYSTEM
  232. 4550 '
  233. 5000 '    *****    Misc. Subroutines
  234.  
  235.  
  236. 5005 '
  237. 5010 PRINT ESC$"B0";:RETURN:'        Inverse Video ON/OFF
  238. 5015 PRINT ESC$"C0";:RETURN:
  239. 5020 PRINT ESC$"B4";:RETURN:'        Turn Cursor ON/OFF
  240. 5025 PRINT ESC$"C4";:RETURN:
  241. 5030 PRINT ESC$"B1";:RETURN:'        Reduced Intensity ON/OFF
  242. 5035 PRINT ESC$"C1";:RETURN:
  243. 5040 PRINT ESC$"B3";:RETURN:'        Underline ON/OFF
  244. 5045 PRINT ESC$"C3";:RETURN:
  245. 5050 GOSUB 5040:PRINT L$;:GOSUB 5045:RETURN:'    Underline L$
  246. 5055 '
  247. 5060 '
  248. 5065 GOSUB 5010:PRINT L$;:GOTO 5015:'                BRIGHT Video
  249. 5070 '
  250. 6000 '    INKEY$ Subroutines
  251. 6010 K$=INKEY$:AK=""
  252. 6020 AK=INKEY$:IF AK="" THEN 6020
  253. 6030 IF ASC(AK)>96 THEN AK=CHR$(ASC(AK)-32)
  254. 6040 RETURN
  255. 6050 GOSUB 6010:IF AK<>CHR$(13) THEN 6050 ELSE RETURN
  256. 6060 '
  257. 6500 '    ERROR LINE Subroutine
  258. 6510 IF ERR=53 THEN L$=FNF(19,10)+"  ERROR:  File not found.  "+C7:GOSUB 5065:FOR T=1 TO 4000:NEXT:RESUME 160
  259. 6520 IF ERR=58 THEN RESUME 240
  260. 6530 PRINT:PRINT C7"Error"ERR"in Line"ERL:END:RUN
  261. 6540 '
  262. 7000 '    Instructions ??
  263. 7010 GOSUB 75:PRINT FNF(14,20)"Do you want instructions  (Y or N) ?  "C7;
  264. 7020 GOSUB 6000:IF AK="Y" OR AK="N" OR AK=CHR$(13) THEN 7030 ELSE 7020
  265. 7030 IF AK="Y" THEN 8000 ELSE RETURN
  266. 7040 '
  267. 8000 '    Display Instructions
  268. 8010 GOSUB 80:B="    "
  269. 8020 PRINT FNF(5,5)"It will allow you to replace any part of your program ";
  270. 8030 PRINT"with anything":PRINT B"you wish, up to eight replacements per ";
  271. 8040 PRINT"session.   For example:"FNF(8,8)"1.  You have finished writing a ";
  272. 8050 PRINT"program only to find you have":PRINT B"misspelled the word ";
  273. 8060 L$=" CHOICE ":GOSUB 5065:PRINT" as ";:L$=" CHOISE ":GOSUB 5065
  274. 8070 PRINT".   Rather than find all":PRINT B"the errors by hand, let this ";
  275. 8080 PRINT"Utility work for you."FNF(12,8)"2.  Perhaps you wish to change a ";
  276. 8090 PRINT"Variable.  You can change all":PRINT B"references to ";
  277. 8100 L$=E+C+"N1"+C+E:GOSUB 5065:PRINT" into ";:L$=E+C+"X5"+C+E:GOSUB 5065
  278. 8110 PRINT" by running this Utility."F(15)FS:AA=F+B+" Replace what?  "
  279. 8120 AB=F+F+"With what?  ":PRINT AA"CHOISE"AB"CHOICE":PRINT AA"N1    "AB"X5"
  280. 8130 PRINT AA"2056  "AB"10":PRINT AA"<ENTER>"FNF(21,5)"If the above sample ";
  281. 8140 PRINT"was real, you would be asked if corrections were"FNF(22,5);
  282. 8150 PRINT"necessary.  Then the Utility would make the requested replacements."
  283. 8160 PRINT FNF(24,5)"Press <ENTER> to continue.   ";:GOSUB 6050:GOSUB 80
  284. 8170 L$=FNF(5,5)+" << CAUTION!! >> ":GOSUB 5065:PRINT"  This program changes ";
  285. 8180 PRINT"ALL references to the":PRINT B"string you choose.  Be aware of the";
  286. 8190 PRINT" possible problems."FNF(9,5)"For example--  If you want to change ";
  287. 8200 PRINT"a Variable "C"N"C" to "C"X"C", then":PRINT B"the line:  ";
  288. 8210 L$=ESC$+"B3"+" 10 IF R=0 AND N=0 THEN 20 "+ESC$+"C3":GOSUB 5065
  289. 8220 PRINT" will be changed ....":PRINT FNF(11,11)"to:  ";:X=1
  290. 8230 L$=" 10 IF J=0 AXD X=0 THEX 20 ":GOSUB 5065:PRINT FNF(12,28)"^  ^      ^"
  291. 8240 PRINT FNF(14,5)"SUGGESTION:  If you are careful, this can be avoided.  ";
  292. 8250 PRINT"Make several":PRINT B;F"smaller changes:    Change  ";
  293. 8260 A(1)="N=":A(2)="X=":A(3)="=N":A(4)="=X":A(5)="(N)":A(6)="(X)":A(7)="N("
  294. 8270 A(8)="X(":A(9)="N1(":A(10)="X5(":A(11)="<=N":A(12)="<=X":GOSUB 70:GOSUB 70
  295. 8280 GOSUB 70:PRINT:PRINT B;F;:GOSUB 70:GOSUB 70:GOSUB 70:PRINT CHR$(8)"etc."
  296. 8290 PRINT FNF(19,5)"NOTE:  The ORIGINAL program will ";:L$="not":GOSUB 5050
  297. 8300 PRINT" be changed!!"C7;FNF(22,5)"Press <ENTER> to begin.    ";:GOTO 6050
  298. 8310 '
  299. 8500 RESTORE 8600:'    Today's Date CALCULATION   (= D2$)
  300. 8510 FOR X=1 TO 6:READ ID(X):NEXT
  301. 8520 FOR Y=3 TO 6:ID=ID(Y):GOSUB 8550:CV%(Y)=CVAL%:NEXT
  302. 8530 M$=STR$(CV%(5)):D$=STR$(CV%(6)):Y$=STR$(CV%(3))
  303. 8540 D2$=RIGHT$(M$,2)+"/"+RIGHT$(D$,2)+"/"+RIGHT$(Y$,2):RETURN
  304. 8550 OUT 32,ID:BCD%=INP(36):SX=INT(BCD%/16):S1=BCD%-16*SX:CVAL%=10*SX+S1:RETURN
  305. 8600 DATA 0,0,9,0,7,6
  306. "+RIGHT$(Y$,2):RETURN
  307. 8550 OUT 32,ID:BCD%=INP(36):SX=INT(BCD%/16):S1=BCD%-16*SX:CVAL%=10*S