150 DRAW 600,500
160 PLOT 85,200,800
170 ENDPROC
180 DEFPROCright_wing
190 GCOL 0,1
200 MOVE 1080,200
210 DRAW 600,500
220 PLOT 85,1080,800
230 ENDPROC
The main program is really only lines 10 to 50:
10MODE 2
20PROCbody
30 PROCleft_wing
40 PROCright_wing
50 END
Lines 20 to 40 are known as procedure calls. Each PROC tells the computer
not to obey the next line number. Instead it must search the program for a
DEFinition of the PROCedure (DEFPROC) with the correct procedure name,
and obey the instructions in that procedure.
For example, after line 20 the computer moves to line 60 and then executes
lines 70 to 100 which draw the butterfly's body. Line 110 is the END of the
PROCedure (ENDPROC).
After carrying out the procedure, the computer returns to the line after the
procedure call to carry on with the program. Here the line following line 20 is
another procedure call. PROCleft _wing draws the butterfly's left wing, and
the computer then executes PROCright _wing, which draws the right wing.
The END in line 50 tells the computer that the program is finished. END is
optional in some programs, such as the Teddy program. It must be used here as
otherwise the computer will carry on and execute line 60 (and attempt to draw
the butterfly body again!
The order in which procedures appear does not matter and you can place
procedures wherever you want within a program, except at the very beginning.
Procedure names follow much the same rules as for variable names, although a
procedure name can begin with a number.
A procedure can be called more than once in a program, saving you the trouble
of repeating program lines:
10 MODE 130
20PROCvariables
30 PROCengine
C 31