`prev Menu next`

Internal Picture Definition ☆
An internal picture definition is one of internal procedures, and is functionally the same as an internal subprogram.
An internal picture definition is written within a program unit.
An internal picture definition begins with a PICTURE line and ends with a END-PICTURE line.
Example 3. An internal picture

    100 OPTION ANGLE DEGREES
    110 SET WINDOW -4,4,-4,4
    120 DRAW polygon(6)
    130 DRAW polygon(7) WITH ROTATE(-90/7)*SCALE(1.5)*SHIFT(2,2)
    140 PICTURE polygon(n)
    150    FOR i=0 TO n
    160       PLOT LINES:COS(i*360/n),SIN(i*360/n);
    170    NEXT i
    180 END PICTURE
    190 END

Explanation
The main program consists of the whole lines.
Among these lines, lines 140 to 180 make up an internal picture.
A feature of internal picture definitions
All variables except parameters are shared with the program unit.
For example, on the following program, variable i in lines 120 to 140 and variable i in lines 170 to 190 are identical. Therefore, Because the variable i changes when the DRAW statement in 130-line is executed, the FOR～NEXT loop in lines 120 to 140 does not work correctly.
Example 4

    100 OPTION ANGLE DEGREES
    110 SET WINDOW -4,4,-4,4
    120 FOR i=-4 to 4
    130    DRAW polygon(7) WITH SHIFT(i,i)
    140 NEXT i
    150 PICTURE polygon(n)
    170     FOR i=0 TO n
    180        PLOT LINES:COS(i*360/n),SIN(i*360/n);
    190     NEXT i
    200 END PICTURE
    210 END