EasyManua.ls Logo

AMSTRAD CPC464 - Gosub Return; Origin

AMSTRAD CPC464
249 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
ORIGIN
In the previous program we used the plot command to plot the centre of a circle, then added the x,y
co-ordinates to this centre position. Instead of adding these centre co-ordinates to the point plotted,
we can use the origin command. This will position the centre of the circle, then position the x,y co-
ordinates of all the points on the circumference (in 1 degree steps) from the origin. To see this type
in:
new
5 cls
10 for a = 1 to 360
15 deg
20 origin 320,200
30 plot 190*cos(a),190*sin(a)
40 next
run
Again, you can alter lines 15 or 30 to remove deg or draw the solid circle from the centre.
To plot four smaller circles on the screen, type in the following program:
new
5 cls
10 for a=1 to 360
15 deg
20 origin 196,282
30 plot 50*cos(a),50*sin(a)
40 origin 442,282
50 plot 50*cos(a),50*sin(a)
60 origin 196,116
70 plot 50*cos(a),50*sin(a)
80 origin 442,116
90 plot 50*cos(a),50*sin(a)
100 next
run
Once again, you can remove line 15 and modify lines 30,50,70 and 90 to use the DRAW command.
GOSUB RETURN
If there are a set of instructions within a program which are to be carried out a number of times,
these instructions can be typed as a sub-routine, and can be called into action by the command gosub
followed by the line number.
The end of a gosub routine is marked by typing in the instruction return.
At this point, the computer will return to the line that followed the gosub command which it had just
obeyed.

Table of Contents

Other manuals for AMSTRAD CPC464

Related product manuals