Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Internal and External Routines?

9 views
Skip to first unread message

Tom Lake

unread,
Oct 8, 2021, 9:13:10 PM10/8/21
to
ANSI/ISO BASIC allows for both internal and external subroutines and functions. Internal routines are those that come before the END statement. In this type, all variable are global to the program and routine itself. External routines are located after the END statement. No variables are shared and passing parameters is the only way to share data with the routine. Example:

10 a=10
20 CALL test
30 PRINT a
40 SUB test
50 a=5
60 END SUB
70 END

will print 5 but

5 DECLARE EXTERNAL SUB test
10 a=10
20 CALL test
30 PRINT a
40 END
50 EXTERNAL SUB test
60 a=5
70 END SUB

will print 10.

Are there any other versions of BASIC that do this?

Gordon Henderson

unread,
Oct 10, 2021, 8:07:14 AM10/10/21
to
In article <c9be2b60-483a-4666...@googlegroups.com>,
BASICs that have a concept of local variables in procedures/functions
ought to work like the latter example here - ones I know and have used
include BBC Basic and my own RTB Basic.

An example might look like:


>LIST
100 a = 10
110 PROCtest
120 PRINT a
140 END
150 DEF PROCtest
160 LOCAL a
170 a = 20
180 ENDPROC
>RUN
10

This is BBC Basic (6502) - there is no real distinction of where in the
program code the procedure can lie as long as it's not executed in the
normal program flow.

-Gordon
0 new messages