Function definition: Difference between revisions

→‎{{header|BASIC}}: Added ANSI BASIC.
m (Dialects of BASIC moved to the BASIC section. QuickBASIC moved to its alphabetical position.)
(→‎{{header|BASIC}}: Added ANSI BASIC.)
Line 662:
 
=={{header|BASIC}}==
==={{header|ANSI BASIC}}===
In ANSI BASIC, functions can be defined as either formulas or multi-line external or internal subroutines. External functions are independent program units that can be called from within the program. Internal functions are considered part of the program unit they are contained in and can only be called from within that unit. External functions do not share any information with other program units and exchange information through parameters and returned values. Internal functions share everything with their surrounding program unit except for their parameters. Internal functions do not have local variables.
{{works with|Decimal BASIC}}
<syntaxhighlight lang="basic">
100 DEF Multiply(A, B) = A * B
110 DECLARE FUNCTION MultiplyI
120 DECLARE EXTERNAL FUNCTION MultiplyE
130 PRINT Multiply(3, 1.23456)
140 PRINT MultiplyI(3, 1.23456)
150 PRINT MultiplyE(3, 1.23456)
160 FUNCTION MultiplyI(X, Y)
170 LET MultiplyI = X * Y
180 END FUNCTION
190 END
200 EXTERNAL FUNCTION MultiplyE(A, B)
210 LET MultiplyE = A * B
220 END FUNCTION
</syntaxhighlight>
{{out}}
<pre>
3.70368
3.70368
3.70368
</pre>
 
==={{header|Applesoft BASIC}}===
511

edits