External Picture Definition ☆
An external picture definition is one of external procedures, and is functionally the same as an external subprogram.
An external picture definition begins with EXTERNAL-PICTURE-line and ends with END-PICTURE-line.
A DECLARE EXTERNAL PICTURE statement that specifies the name of an external picture is written in any program unit that uses it.
Example 1. An external picture that draws a regular n-gon.
10 DECLARE EXTERNAL PICTURE polygon 20 OPTION ANGLE DEGREES 30 SET WINDOW -4,4,-4,4 40 DRAW polygon(6) 50 DRAW polygon(7) WITH ROTATE(-90/7)*SCALE(1.5)*SHIFT(2,2) 60 END 100 EXTERNAL PICTURE polygon(n) 110 OPTION ANGLE DEGREES 120 FOR i=0 TO n 130 PLOT LINES:COS(i*360/n),SIN(i*360/n); 140 NEXT i 150 END PICTURE
Explanation
The part consisting of lines 10 to 60 is the main program,
and the part from lines 100 to 150 is an external picture definition.
As an external picture is a program unit, OPTION ANGLE statements are needed by both the main program and the external picture definition.
A feature of external picture definitions
All variables written within an external picture definition are independent of the variables within the main program .
For example, on the following program, variables i on the main program and on the external picture polygon are different.
Example 2.
10 DECLARE EXTERNAL PICTURE polygon 20 OPTION ANGLE DEGREES 30 SET WINDOW -4,4,-4,4 40 FOR i=-4 to 4 50 DRAW polygon(7) WITH SHIFT(i,i) 60 NEXT i 70 END 100 EXTERNAL PICTURE polygon(n) 110 OPTION ANGLE DEGREES 120 FOR i=0 TO n 130 PLOT LINES:COS(i*360/n),SIN(i*360/n); 140 NEXT i 150 END PICTURE