1 GOSUB 32000
2 MODE 4:VDU28,0,27,39,5:CLG
4 VDU24,0;130;1279;860;:CLS
6 VDU15
7 ON ERROR GOTO 30400
10 CLS:INPUT"ENTER F(X) "F1$
13 F2$="X*0":G2=0
14 PRINT"F2(X)=0 Y/N":A$=GET$
18 IF A$="N" THEN G2=1:INPUT"ENTER F2
(X) "F2$
19 IF G2 THEN GOTO 2000
20 PRINT"IS THE DIFFERENTIAL REQUIRED
Y/N":A$=GET$
22 IF A$="N" THEN GOTO 2000
24
26 CLS:PRINT"FIRST REMOVE BRACKETS"
28 F2$=F1$:G2=3
30
34 FOR R=1 TO LEN(F2$)
36 C$=MID$(F2$,R,2)
38 IF C$=")(" THEN F2$=MID$(F2$,1,R)+
"*"+MID$(F2$,R+1)
40 NEXT
41
42 GNU$="":TYPE%=0
44 PRINT F2$
45 F2$="("+F2$+")"
46 CLOS%=1
47
48 REM find end of first bracket
50 A%=0:R%=0
51 REPEAT
52 CLOS%=CLOS%+1
54 C$=MID$(F2$,CLOS%,1)
56 A%=A%-(C$="(")+(C$=")")
58 IF A%=0 AND C$=")" THEN R%=1
60 IF CLOS%=LEN(F2$) THEN R%=1
62 UNTIL R%=1
64 IF MID$(F2$,CLOS%+1,1)="^" THEN GO
TO 50
66 A%=0:R%=0:CNT%=CLOS%+1
67
68 REM find start of first bracket
70 REPEAT
72 CNT%=CNT%-1
74 C$=MID$(F2$,CNT%,1)
76 A%=A%-(C$=")")+(C$="(")
78 IF A%=0 AND C$="(" THEN R%=1
80 IF CNT%=1 THEN R%=1
82 UNTIL R%=1
84 IF CNT%=1 AND CLOS%=LEN(F2$) THEN
GOTO 500
86 C$=MID$(F2$,CNT%-1,1)
88 IF C$="^" THEN GOTO 50
90 IF C$<>"+" AND C$<>"-" AND C$<>"*"
AND C$<>"/" AND C$<>"(" THEN GOTO 50
92 IF C$<>"*" AND MID$(F2$,CLOS%+1,1)
<>"*" THEN GOTO 50
94 AC%=CNT%:OC%=CLOS%:A%=0
96 IF MID$(F2$,CLOS%+2,1)<>"(" THEN G
OTO 220
98 IF MID$(F2$,CLOS%+1,1)<>"*" THEN G
OTO 220
100 E%=CLOS%+1:R%=0
101
102 REM find end of second bracket
104 REPEAT
106 E%=E%+1
108 C$=MID$(F2$,E%,1)
110 A%=A%-(C$="(")+(C$=")")
112 IF A%=0 AND C$=")" THEN R%=1
114 IF E%=LEN(F2$)-1 THEN R%=1
116 UNTIL R%=1
118 IF MID$(F2$,E%+1,1)="^" THEN GOTO
220
120 REM start of type 0 ( )*( )
121 ******************************
122 REM check first term in second bra
cket for numery minus
123
124 C$=MID$(F2$,CLOS%+3,1)
126 IF C$="-" THEN CLOS%=CLOS%+1
128 CLOS%=CLOS%+2:OC%=CLOS%
129
130 REM check first term in first brac
ket for numery minus
132 C$=MID$(F2$,CNT%+1,1)
134 IF C$="-" THEN CNT%=CNT%+1
136 W%=CNT%:PRINT"$";
137
138 REM start of LOOP
140 REPEAT
144 A%=0:C%=0:R%=0
146 REM store sign of first term
147
148 C$=MID$(F2$,CNT%,1)
150 IF C$="-" THEN S1$="-" ELSE S1$="+
"
152 SP%=LEN(GNU$)
153
154 REM collect first term
156 REPEAT
158 CNT%=CNT%+1
160 C$=MID$(F2$,CNT%,1)
162 GNU$=GNU$+C$
164 A%=A%-(C$="(")+(C$=")")
166 IF A%=0 AND MID$(F2$,CNT%+1,1)=")"
THEN C%=1:R%=1
168 IF A%=0 THEN IF C$="+" OR C$="-" T
HEN GNU$=MID$(GNU$,1,LEN(GNU$)-1):R%=1
170 UNTIL R%=1
172 R%=0:S%=0
174 GNU$=GNU$+"*"
176 A%=0:PRINT"*";
177
178 REM store sign of second term
180 C$=MID$(F2$,CLOS%,1)
182 IF C$="-" THEN S2$="-" ELSE S2$="+
"
184 REM collect second term
186 REPEAT
188 CLOS%=CLOS%+1
190 C$=MID$(F2$,CLOS%,1)
192 GNU$=GNU$+C$
194 A%=A%-(C$="(")+(C$=")")
196 IF CLOS%=E%-1 THEN S%=1:R%=1
198 IF A%=0 THEN IF C$="+" OR C$="-" T
HEN GNU$=MID$(GNU$,1,LEN(GNU$)-1):R%=1
200 UNTIL R%=1
201
202 REM compare signs and store result
in GNU$
204 IF S1$=S2$ THEN S$="+" ELSE S$="-"
206 GNU$=MID$(GNU$,1,SP%)+S$+MID$(GNU$
,SP%+1)
208 IF S%=1 THEN W%=CNT%:CLOS%=OC%:PRI
NT"$";
210 S%=0:CNT%=W%
212 UNTIL C%=1 AND CLOS%=OC%
214 AC%=AC%-1:E%=E%+1
218 PRINT"END":GOTO 358
220 PRINT"NO SECOND BRACKET"
222 E%=CLOS%:A%=0:R%=0:L%=0:PRINT"$";
224 IF MID$(F2$,E%+1,1)<>"*" THEN GOTO
270
226 IF MID$(F2$,CNT%+1,1)="-" THEN CNT
%=CNT%+1
227
228 REM LOOP for type 1 ( )*N
229 **********************************
230 REPEAT
232 E%=CLOS%
233
234 REM store sign of N
236 IF MID$(F2$,E%+2,1)="-" THEN S1$="
-":E%=E%+1 ELSE S1$="+"
238 SP%=LEN(GNU$)
240 E%=E%+1:R%=0:TYPE%=1
241
242 REM collect N
244 REPEAT
246 E%=E%+1
248 C$=MID$(F2$,E%,1)
250 GNU$=GNU$+C$
252 A%=A%-(C$="(")+(C$=")")
254 IF E%=LEN(F2$) THEN R%=1
256 IF A%=0 AND C$="^" THEN E%=CLOS%:G
NU$="":R%=1
258 IF A%=0 THEN IF C$="+" OR C$="-" O
R C$="*" OR C$="/" THEN R%=1
260 UNTIL R%=1
262 IF E%=CLOS% THEN GOTO 270
264 GNU$=MID$(GNU$,1,LEN(GNU$)-1)
266 GNU$=GNU$+"*"
268 GOTO 320
270 IF MID$(F2$,CNT%-1,1)<>"*" THEN GO
TO 500
272 REM type 2 N*( )
273 **********************************
274 TYPE%=2:E%=CLOS%+1:W%=CNT%:R%=0
275
276 REM find start of N
278 REPEAT
280 AC%=AC%-1
282 C$=MID$(F2$,AC%,1)
284 A%=A%-(C$="(")+(C$=")")
286 IF AC%=1 THEN R%=1
288 IF A%=0 THEN IF C$="+" OR C$="-" O
R C$="^" THEN R%=1
290 IF A%=0 AND AC%<CNT%-1 THEN IF C$=
"*" OR C$="/" THEN R%=1
292 UNTIL R%=1
294 IF C$="^" THEN GOTO 500
296 AC%=AC%+1
297
298 REM store sign of N
300 IF C$="-" THEN S1$="-" ELSE S1$="+
"
302 IF MID$(F2$,CNT%+1,1)="-" THEN CNT
%=CNT%+1
303
304 REM LOOP for type 2
305
306 REPEAT
308 SP%=LEN(GNU$):L%=0
309
310 REM collect N
312 FOR R%=AC% TO W%-1
314 C$=MID$(F2$,R%,1)
316 GNU$=GNU$+C$
318 NEXT
320 A%=0:R%=0:PRINT"*";
321
322 REM store sign of term
324 IF MID$(F2$,CNT%,1)="-" THEN S2$="
-" ELSE S2$="+"
325
326 REM collect term from bracket
328 REPEAT
330 CNT%=CNT%+1
332 C$=MID$(F2$,CNT%,1)
334 GNU$=GNU$+C$
336 A%=A%-(C$="(")+(C$=")")
338 IF A%=0 THEN IF C$="+" OR C$="-" T
HEN R%=1
340 IF CNT%=CLOS% THEN R%=1:L%=1
342 UNTIL R%=1
344 GNU$=MID$(GNU$,1,LEN(GNU$)-1)
345
346 REM compare signs and store result
in GNU$
348 IF S1$=S2$ THEN S$="+" ELSE S$="-"
350 GNU$=MID$(GNU$,1,SP%)+S$+MID$(GNU$
,SP%+1)
352 UNTIL L%=1
354 AC%=AC%-1:PRINT"END"
355
358 PROCtest
360
364 REM reassemble string
366 B$=MID$(F2$,AC%-1,1):C$=MID$(F2$,A
C%,1):D$=MID$(F2$,E%,1)
368 IF C$="*" OR D$="*" THEN S%=1 ELSE
S%=0
370 IF C$="/" OR D$="/" THEN S%=1
372 IF TYPE%=2 AND C$="-" THEN IF B$="
*" OR B$="/" THEN AC%=AC%-1:GOTO 366
374 IF S%<>1 THEN GOTO 386
375
376 REM brackets not removed
378 IF TYPE%=2 THEN F2$=MID$(F2$,1,AC%
)+"("+MID$(F2$,AC%+1)
380 IF TYPE%=1 THEN F2$=MID$(F2$,1,E%-
1)+")"+MID$(F2$,E%)
381 IF TYPE%=0 THEN E%=E%-1
382 AC%=AC%+1:GOTO 410
383
384 REM brackets removed
386 S$="":I%=0:REM alter signs as requ
ired
388 REPEAT
390 IF S$="+" THEN S2$="-" ELSE S2$="+
"
392 IF (S$="+" OR S$="-") AND I%=1 THE
N GNU$=S2$+MID$(GNU$,2)
394 IF (S$="+" OR S$="-") AND I%>1 THE
N GNU$=MID$(GNU$,1,I%-1)+S2$+MID$(GNU$,I
%+1)
396 I%=I%+1
398 S$=MID$(GNU$,I%,1)
400 UNTIL C$<>"-" OR (TYPE%=2 AND S%=0
) OR I%=LEN(GNU$)
402 IF S%=1 THEN GOTO 378
404 D$=MID$(GNU$,1,1)
406 IF D$="-" AND C$<>"(" THEN AC%=AC%
-1
408 IF TYPE%<>0 AND D$="+" AND C$<>"("
AND AC%=2 THEN AC%=AC%-1
409 IF TYPE%<>0 AND D$="+" AND C$<>"("
AND AC%>2 THEN F2$=MID$(F2$,1,AC%-1)+"+
"+MID$(F2$,AC%+1)
410 IF MID$(GNU$,1,1)="+" THEN GNU$=MI
D$(GNU$,2)
412 F2$=MID$(F2$,1,AC%)+GNU$+MID$(F2$,
E%)
414 F2$=MID$(F2$,2,LEN(F2$)-2)
416 GOTO 42
500 PRINT"DIFF"
1998
1999 REM*****GRAPH******
2000
2010 PRINT"IS GRAPH REQUIRED Y/N":A$=GE
T$
2012 IF A$="N" THEN GOTO 2208
2015 VX=2*PI:VY=3
2016
2017 REM ****PLOT GRAPH****
2019 REPEAT
2020 CLG:X=-VX
2021 VDU23,1,0;0;0;0;
2024 PRINTTAB(10,1)VY
2026 PRINTTAB(30,11)INT(VX*1000+.5)/100
0
2028 MOVE 130,512:PLOT5,1175,512
2029 MOVE 652,180:PLOT5,652,845
2030 REPEAT
2032 Y=EVAL(F1$):PROCplot
2034 Y=EVAL(F2$):PROCplot
2036 X=X+(VX/522)*5
2038 UNTIL X>VX
2040 VDU23,1,1;0;0;0;:VDU30
2042 PRINT"ALTER X OR Y AXIS ? "
2044 X%=0:Y%=0:A$=GET$
2046 IF A$="X" THEN X%=-1:PROCalter
2048 IF A$="Y" THEN Y%=-1:PROCalter
2052 UNTIL A$<>"<" AND A$<>">"
2054
2099 VDU30
2100 PRINT"ARE THE CALCULATIONS REQUIRE
D Y/N ? "
2104 A$=GET$:IF A$="N" THEN GOTO 2208
2108 VDU30:PRINT"
":VDU30
2110 N=1
2116 REM LOOP
2120 X=-VX:XI=.1:Z=0.000001
2124 IF N=1 OR N=2 THEN PRINT"Y";N;"=0
WHEN X= "
2128 IF N=3 THEN PRINT "INTERSECTS AT "
2132 REPEAT
2136 REPEAT
2140 XO=X
2144 PROCcalcs
2148 UNTIL XO=X
2152 YO=Y
2156 REPEAT
2160 X=X+XI:IF ABS(X)<Z THEN X=0
2164 XO=X
2168 PROCcalcs
2172 IF SGN(YO)<>SGN(Y) THEN X=X-XI:XI=
XI/10
2176 UNTIL XO=X OR SGN(YO)<>SGN(Y)
2177 UNTIL X>=VX
2178 X=0:E=0
2179 ONERROR PROCe1
2180 REPEAT
2182 IF N<>3 AND E=0 THEN PROCvals
2185 IF N<>3 AND E=0 THEN PRINT"WHEN X=
0 Y";N;"=";INT(Y*1000+.5)/1000
2186 E=0
2187 UNTIL E=0
2188 REM REMOVE WHEN DIFF IS COMPLETED
2192 IF G2=3 AND N=2 THEN N=3
2196IF G2=0 THEN N=3
2198 ONERROR OFF
2199 PRINT
2200 N=N+1:IF N<>4 THEN GOTO 2116
2204
2208 PRINT"ANOTHER ONE Y/N ? "
2212 A$=GET$:IF A$="N" THEN PRINT"THAT'
S ALL FOLK'S ":END
2216 GOTO 10
2220
2229 DEFPROCe1
2230 PRINT"Y DOES NOT EXIST AT X=0"
2231 X=X+XI
2232 E=1
2235 ENDPROC
2240
2700 DEFPROCcalcs
2704 P=0:PROCvals
2712 IF ABS(Y)>1000 THEN X=X+.1:XI=.1:Y
O=Y
2714 IF ABS(Y)<Z THEN P=1:XP=X:X=X+.05:
XI=.1:YO=Y
2716 IF N=1 OR N=2 THEN IF P=1 THEN PRI
NT INT(XP*1000+.5)/1000
2718 IF N=3 AND P=1 THEN PRINT "(";INT(
XP*1000+.5)/1000;" , ";INT(Y1*1000+.5)/1
000;")"
2790 ENDPROC
2799
2800 DEFPROCvals
2804 IF N=1 THEN Y1=EVAL(F1$):Y=Y1
2808 IF N=2 THEN Y2=EVAL(F2$):Y=Y2
2810 IF N=3 THEN Y1=EVAL(F1$):Y2=EVAL(F
2$):Y=Y1-Y2
2812 ENDPROC
2899
2900 DEFPROCalter
2905 VDU30
2910 PRINT"ENTER < SMALLER > LARGER "
2912 A$=GET$
2914 IF X% AND A$="<" THEN VX=VX*2
2916 IF X% AND A$=">" THEN VX=VX/2
2918 IF Y% AND A$="<" THEN VY=VY*2
2920 IF Y% AND A$=">" THEN VY=VY/2
2922 ENDPROC
2949
3000 DEFPROCplot
3010 NY=332+(Y*332/VY)+180
3012 IF NY>1024 OR NY<0 THEN ENDPROC
3014 PLOT69,(X*522/VX)+522+130,NY
3016 ENDPROC
4999
5000 DEFPROCtest
5004 C%=1:TYPE$="=":Q$=MID$(GNU$,1,1)
5014 REPEAT
5016 C%=C%+1
5018 C$=MID$(GNU$,C%,1)
5020 IF C$="+" OR C$="-" THEN IF C$<>Q$
THEN TYPE$="<>"
5022 UNTIL TYPE$="<>" OR C%=LEN(GNU$)
5024 IF TYPE$="=" THEN ENDPROC
5026
5030 CNT%=1:C%=0
5032 REPEAT
5034 CLOS%=CNT%:F%=0:Z$=""
5036 REPEAT
5038 CLOS%=CLOS%+1
5040 C$=MID$(GNU$,CLOS%,1)
5042 IF C$="+" OR C$="-" THEN F%=1
5043 IF CLOS%=LEN(GNU$) THEN CLOS%=CLOS
%+1
5044 UNTIL CLOS%=LEN(GNU$)+1 OR F%=1
5045
5046 Z$=MID$(GNU$,CNT%+1,CLOS%-1-CNT%)
5047
5048 PROCsort
5049
5050 IF C%=1 THEN GOTO 5060
5052 S1T=CNT%+1:E1T=CLOS%-1:FIRF=F%:S1$
=Z$
5054 IF FIRF=0 THEN ENDPROC
5056 C%=1:CNT%=CLOS%:UNTIL FALSE
5060 S2T=CNT%+1:E2T=CLOS%-1:SECF=F%:S2$
=Z$
5062 IF S1$<>S2$ THEN GOTO 5100
5064 P1$=MID$(GNU$,S1T-1,1)
5066 P2$=MID$(GNU$,S2T-1,1)
5068 IF P1$=P2$ THEN GOTO 5100
5069
5070 REM *** REMOVE TERMS ***
5071
5072 GNU$=MID$(GNU$,1,S1T-2)+MID$(GNU$,
E1T+1,S2T-2-E1T)+MID$(GNU$,E2T+1)
5073
5074 IF LEN(GNU$)<S1T THEN ENDPROC
5076 C%=0:CNT%=S1T-1:UNTIL FALSE
5078
5100 IF SECF=1 THEN CNT%=E2T+1 ELSE C%=
0:CNT%=E1T+1
5102 UNTIL FALSE
5104 ENDPROC
5106
5110 DEFPROCsort
5112 FOR Q=1 TO LEN(Z$)-1
5114 X$=MID$(Z$,Q,1):Y$=MID$(Z$,Q+1,1)
5116 IF X$>Y$ THEN Z$=MID$(Z$,1,Q-1)+Y$
+X$+MID$(Z$,Q+2):Q=1
5118 NEXT
5120 ENDPROC
5999
29999 END
30000
30100 MESSAGE$="TXT-MC"
30101 MODE 4
30102 VDU28,0,27,39,5,:CLS
30105 VDU19,0,4,0,0,0
30110 *FX4,1
30115 S%=&5000:BYTE%=32
30120 PROCcheck:*FX4,0:END
30125
30200 MESSAGE$="DBUG-MC"
30205 S%=&4E20:BYTE%=76
30210 PROCcheck:END
30215
30300 REM **CALL &4CCE FOR 1/50 SEC
30305 REM **CALL &4CF8 FOR 1/100 SEC
30310 REM MESSAGE$="TRAC-MC"
30320 REM S%=&4BA2:BYTE%=32
30330 REM PROCcheck:END
30340
30400 REM SEE VARIABLES
30402 VDU14
30410 PROC`LVAR
30412 VDU15
30420 END
30430
30500 MESSAGE$="RE#-MC"
30505 S%=&53FC:BYTE%=186
30510 !&8D=S%:PROCcheck:END
30515
30950 DEFPROCcheck
30952 X%=&C00
30955 IF ?S%<>BYTE% THEN PROCoscli("L."+
MESSAGE$)
30960 CALL S%:ENDPROC
30965
32000 REM FKEYS
32002 *KEY0"GOTO 32500 |M"
32005 *KEY1"GOTO 30100 |M"
32010 *KEY2"GOTO 30200 |M"
32012 *KEY3"GOTO 30300 |M"
32014 *KEY4"GOTO 30400 |M"
32015 *KEY5"GOTO 30500 |M"
32020 *KEY10"MODE6 |M VDU19,1,3,0,0,0 |M
OLD |M CLS |M "
32025 RETURN
32026 END
32027
32030 DEFPROC`LVAR
32040 LOCAL a%,z%,s%,l%,p%,t%,f$
32050 a%=&482:z%=&4F4:s%=&4B8
32060 ON ERROR OFF
32070 *FX229,0
32080 *FX4,0
32090 *FX12,0
32100 VDU 7,3,6,14,12
32110 PRINT"Last errror was "
32120 REPORT:PRINT; " at line "ERL
32130 PRINT
32140 FOR l%=a% TO z% STEP 2
32150 IF l%=s%-2 l%=&4BC:GOTO 32200
32160 p%=?l%+256*l%?1
32170 IF p%=0 THEN 32200
32180 f$=CHR$((l%-a%)/2+65)
32190 PROClvar(p%,f$)
32200 NEXT
32202 PRINT'"RESIDENT INTEGER VARIABLES"
'
32210 FOR l%=1 TO 26:f$=CHR$(64+l%)+"%"
32220 p%=EVAL(f$)
32222 PRINT,f$"=";p%," &";÷p%
32224 NEXT:PRINT
32230 ENDPROC
32240
32250 DEFPROClvar(o%,a$)
32260 LOCAL d%,f$
32270 f$=a$
32280 d%=2
32290 REPEAT
32300 a$=a$+CHR$(o%?d%)
32310 d%=d%+1
32320 UNTIL o%?(d%-1)=0
32330 a$=LEFT$(a$,d%-2)
32340 IF INSTR("a%a$d%f$l%o%p%s%t%z%",a$
)<>0 THEN t%=0 ELSE t%=-1
32350 IF RIGHT$(a$,1)="(" THEN a$=LEFT$(
a$,LEN(a$)-1)+" = array":GOTO 32380
32360 IF RIGHT$(a$,1)="$" THEN a$=a$+" =
"+EVAL(a$):GOTO 32380
32370 a$=a$+" = "+STR$(EVAL(a$))+" &"+
STR$÷(EVAL(a$))
32380 IF t% PRINT TAB(15-INSTR(a$,"="))a
$
32390 IF o%?1<>0 THEN PROClvar(?o%+256*o
%?1,f$)
32400 ENDPROC
32490
32500 REM CONVERT H-D D-H
32502 PROCin:END
32504 DEFPROCin
32506 LOCAL a$,l%
32508 VDU11
32510 INPUT"ENTER NUMBER "a$
32512 VDU11,11
32514 l%=LEN(a$)
32516 PRINT'TAB(10-l%)a$" = ";
32520 IF MID$(a$,1,1)<>"&" THEN PRINT"&"
;÷VAL(a$); ELSE a$=STR$(EVAL(a$)):PRINTa
$;
32525 PRINTVAL(a$)DIV256;",";VAL(a$)MOD2
56
32530 PRINT
32532 ENDPROC
32599
32600 DEFPROCoscli ($X%):Y%=X%DIV256:CAL
L&FFF7:ENDPROC