``

prev Menu next

External Subprogram ☆
An external subprogram is a subprogram that is written as a program unit, begins with EXTERNAL-SUB-line and ends with END-SUB-line.
Use a CALL statement to execute an external subprogram.
Write a DECLARE EXTERNAL SUB statement in the program unit that has a CALL statement that invokes the subprogram as in the 10-line of the following program.
Example.

    10  DECLARE EXTERNAL SUB circle
    20  SET WINDOW -4,4,-4,4
    30  CALL circle(1,-1,2)
    40  END
    100 EXTERNAL SUB circle(a,b,r)
    110 OPTION ANGLE DEGREES
    120 FOR t=0 TO 360
    130     PLOT LINES: a+r*COS(t),b+r*SIN(t);
    140 NEXT t
    150 PLOT LINES
    160 END SUB

Note.
While the current version of Decimal BASIC allows DECLARE EXTERNAL SUB statements to be omitted, it is recommended that DECLARE EXTERNAL SUB statements should be written for compatibility with Full BASIC.