
In the previous program, the instruction plot 50*cos(a),50*sin(a)
was repeated 4 times. This
instruction can be typed in as a sub-routine; and called into action each time it is needed by using
the word gosub.
Type
in the following:
new
5 cls
1 0 for a=1 to 360
15 deg
20 origin 196,282
30 gosub 120
40 origin 442,282
50 gosub 120
6 0 o r i g i n 1 9 6 , 1 1 6
70 gosub 120
80 origin 442,116
90 gosub 120
100 next
110 end
1 2 0 p l o t 5 0 * c o s ( a ) , 5 0 * s i n ( a )
1 3 0 return
run
Note that the instruction end is used in line 110; otherwise the program would naturally continue
after instruction 100, and carry out instruction 120, which is only required when called by gosub.
To conclude this section, try the following program which incorporates a lot of the programming
commands and keywords that you should now understand. Type in:
new
1 0 m o d e 0 : b o r d e r 6 : p a p e r 0 : i n k 0 , 0
2 0 g o s u b 1 6 0 : f o r x = 1 t o 1 9 : l o c a t e x , 3
3 0 p e n 1 5 : p r i n t " " ; c h r $ ( 2 3 8 )
4 0 f o r t = 1 t o 5 0 : n e x t t : s o u n d 2 , ( x + 1 0 0 )
5 0 n e x t x : g o s u b 5 0 f o r b = 3 b = 3 t o 2 2
6 0 l o c a t e 2 0 , b : p e n 7 : p r i n t c h r $ ( 2 5 2 )
7 0 c l s : g o s u b 1 6 0 : n e x t b
8 0 s o u n d 2 , 0 , 1 0 0 , 1 5 , 0 , 0 , 1
9 0 g o s u b 1 6 0 : b o r d e r 1 6 0 : b o r d e r 1 6 , 2 4 : l o c a t e 2 0 , 2 5
1 0 0 p e n 1 4 : p r i n t c h r $ ( 2 5 3 ) ;
1 1 0 f o r t = 1 t o 1 0 0 0 : n e x t t
1 2 0 b o r d e r 6 : g o s u b 1 6 0 :for f=3 to 24
130 locate 10,(25-f):pen 2
1 4 0 p r i n t c h r $ ( l 4 4 ) : c l s : g o s u b 1 6 0
150 sound 7,(100-f),5:next f:goto 10
1 6 0 l o c a t e 1 0 , 2 5 : p e n 1 2
1 7 0 p r i n t c h r S ( 2 3 9 ) : r e t u r n
run
Содержание CPC464
Страница 1: ......
Страница 32: ...or you can type 3e1 1e1 ENTER 300 2 3000x1000 Type 3e3 1e3 ENTER 3000000 3 3000x0 001 Type 3e3 1e 3 ENTER 3 ...
Страница 102: ...PRINT 10 AND 12 Results in 8 PRINT 10 AND 1000 Results in 8 again ...
Страница 118: ...TO DO DRAW THIS PAGE ...
Страница 219: ...actual value may be made to vary during the execution of a program ...
Страница 240: ...Text and WINDOW planner Mode 2 80 Columns ...
Страница 241: ......
Страница 245: ...Sound envelope Music planner sheet ...