100 CLEAR:aika=DATE:p_wind
110 p_logo "PLOT a function","22.04.87"
120 CLS
130 PRINT\"TYPE: 250 y = function";"(x)"
140 PRINT"TYPE: RUN 220"
150 PRINT\"YOU MAY ALSO CHANGE THE DEFAULTS:"
160 PRINT"300 sk1=5:sk2=5   scaling"
170 PRINT"310 a1=82:a2=50   origin"
180 PRINT"320 x1=-15:x2=15  area"
190 PRINT"330 p=.5          point density"
200 p_valmis:STOP
210 :
220 aika=DATE:p_wind:PAPER#0,1:CLS#0
230 DEFine FuNction fny(x)
240  LOCal y
250  y=SIN(x)
260  RETurn y
270 END DEFine fny
280 :
290 REMark ** defaults **
300 sk1=5:sk2=5:REMark scaling
310 a1=82:a2=50:REMark origin
320 x1=-15:x2=15:REMark area
330 p=.5:REMark point density
340 :
350 REMark ** axes **
360 FOR i=a1 TO 165 STEP sk1:POINT i,a2
370 FOR i=a1 TO 0 STEP -sk1:POINT i,a2
380 FOR j=a2 TO 100 STEP sk2:POINT a1,j
390 FOR j=a2 TO 0 STEP -sk2:POINT a1,j
400 :
410 REMark ** drawing the function **
420 flag=0
430 FOR x=x1 TO x2 STEP p
440  w=a1+sk1*x
450  y=fny(x)
460  z=a2+sk2*y
470  IF flag THEN LINE w1,z1 TO w,z
480  w1=w:z1=z:flag=1
490 END FOR x
500 :
510 REMark ending it
520 AT#0,2,0:INK#0,4
530 PRINT#0,"p_reset restores the TV-state"
540 p_valmis
550 :
17000 DEFine PROCedure p_wind
17010  MODE 256
17020  WINDOW 512,256,0,0:PAPER 1:CLS
17030  WINDOW 448,200,32,16
17040  PAPER 0:INK 7:CLS:FILL 0
17050 END DEFine p_wind
17060 :
20000 DEFine PROCedure p_logo(ohj$,tpvm$)
20010  LOCal v$
20050  CSIZE 3,1:CURSOR 224-8*10,70
20060  PRINT "Timo Salmi"
20070  CURSOR 224-8*LEN(ohj$),110
20080  PRINT ohj$:CSIZE 2,0
20090  CURSOR 222-6*LEN(tpvm$),90
20100  PRINT tpvm$
20110  AT 19,0:INPUT "TO CONTINUE: PRESS ENTER?"!v$
20120 END DEFine p_logo
20130 :
30000 DEFine PROCedure p_valmis
30010  LOCal t,m,s:INK#0,4:AT#0,1,0
30020  PRINT#0,"READY, elapsed";
30030  s=DATE-aika
30040  t=INT(s/3600):s=s-t*3600
30050  m=INT(s/60):s=s-60*m
30060  IF t>0 THEN PRINT#0,!t!"h";
30070  IF m>0 THEN PRINT#0,!m!"min";
30080  PRINT#0,!s!"sec"
30090  PAPER#0,0:INK#0,7
30100 END DEFine p_valmis
30110 :
30120 STOP
31000 DEFine PROCedure p_reset
31010  MODE 8
31020  WINDOW 513,256,0,0
31030  PAPER 0:CLS
31040  WINDOW#0,448,40,32,216
31050  WINDOW#1,448,200,32,16
31060  WINDOW#2,448,200,32,16
31070  PAPER#0,0:INK#0,7
31080  PAPER#1,2:INK#1,7:CLS#1
31090  PAPER#2,1:INK#2,7
31100  SCALE 100,0,0:FILL 0
31110 END DEFine p_reset
