[comp.sys.tandy] Model 100 graphing utility

rmb384@leah.UUCP (10/03/87)

	Enclosed is a nifty graphing utility A freind of mine and i wrote 
to help me get through Calc last year. It will draw a graph of a function
which it prompts you for. It then asks for the range. Kinda fun. You can 
type the  funtion in like so:

	Computer: y=	
	you type: sin(x^(cos(x)))
	Computer: From A=
	you:	0
	Computer: To B=?
	you:	4

	And it scales and draws the graph. Have Fun and enjoy....


---------------------------- Cut Here ---------------------------

1 ' (c) + 1987 R.M. Bownes & L.B. Fulton
2 ' This program may be copied,modified,
3 ' and distributed so long as this 
4 ' notice is kept intact. Please inform
5 ' the authors of any nift changes.
6 N=64:DIM DP(66),DS(66)
20 GOSUB 1000
30 GOSUB 2000
40 GOSUB 3000
50 GOSUB 4000
60 A$=INKEY$:IF A$="" THEN 60
70 IF A$="Q" OR A$="q" THEN MENU
80 RUN
1000 'input section
1010 CLS:PRINT "  Model 100 Whiz-bang Graphing Program";
1020 PRINT @80,"Please input function of the form"
1030 PRINT "    y=F(x)"
1040 LINE INPUT "y=";FX$
1050 PRINT @200,"From A=";:INPUT A
1060 PRINT @220,"To B=";:INPUT B
1070 PRINT "          Please Wait";
1080 RETURN
2000 'Calculation routine
2010 HIGH=-10000:LOW=10000
2015 IN=(B-A)/N
2020 F$="DP(INT((X-A)/IN))="+FX$+CHR$(0)
2500 A0=VARPTR(F$)
2510 A1=PEEK(A0+1)+256*PEEK(A0+2)
2520 CALL 1606,0,A1
2530 '
2540 FOR X=A TO B STEP IN
2550  CALL 2499,0,63105
2560 NEXT X
2570 FOR I=0 TO N
2580  IF DP(I)>HIGH THEN HIGH=DP(I)
2590  IF DP(I)<LOW THEN LOW=DP(I)
2600 NEXT I
2610 RETURN
3000 ' Scaling function
3010 SS=(HIGH-LOW)/55:'STEP SIZE
3020 FOR I=0 TO N
3030 DS(I)=INT(63-(DP(I)-LOW)/SS)
3040 NEXT I
3050 RETURN
4000 'Plotting routine
4010 CLS:PRINT USING "-###.##{";HIGH;
4020 PRINT @280,"";:PRINT USING"-###.##~";LOW;
4025 T=INT(195/N)
4030 FOR I=0 TO N-1
4040  LINE(44+I*T,DS(I))-(44+(I+1)*T,DS(I+1))
4050 NEXT I
4060 RETURN