Main program and External Procedures☆
A BASIC program consists of the main program and some or no external procedures.
The main program is the part from the beginning to the END line.
External procedures are written succeeding the main program.
An external procedure is an external subprogram, an external function definition, or an external picture definition.
Example
On the following program, lines from 100 to 130 compose the main program, and lines from 200 to 260 compose an external function definition.
100 DECLARE EXTERNAL FUNCTION fact 110 INPUT n 120 PRINT fact(n) 130 END 200 EXTERNAL FUNCTION fact(n) 210 IF n=1 THEN 220 LET fact=1 230 ELSE 240 LET fact=n*fact(n-1) 250 END IF 260 END FUNCTION
Program Unit
The main program or an external procedure is called a program unit. A program unit is the scope of an identifier or a OPTION statement.
Program Units