Post by E ThumpPost by Stephen HoffmanAny VAX BASIC folk here?
Really VAX BASIC, and not BASIC on OpenVMS VAX with the
DEC/Compaq/HP/HPE/VSI BASIC compiler?
DEC/Compaq/HP/HPE/VSI BASIC replaced VAX BASIC a very long time ago
(back in VAX/VMS V3.x, IIRC)...
Assuming this is not the archaic VAX BASIC compiler, but rather the
DEC/Compaq/HP/HPE BASIC compiler...
https://vmssoftware.com/docs/VSI_BASIC_USER.pdf
https://vmssoftware.com/docs/VSI_BASIC_REF.pdf
The keyword you're looking for is EXTERNAL. See page 105 in the
reference manual, linked above.
COMMON (reference manual page 67) is not what you want.
--
Pure Personal Opinion | HoffmanLabs LLC
It identifies as "VAX BASIC V3.8-000" when I start it. Came with my
uVAX3100-80 running OpenVMS 6.2
V7.3 with whatever the latest BASIC for that era might be is the usual
recommendation.
I will assume the usual 'must experience all the associated bugs and
issues and limits of the oldest config' applies here.
I'm not going to wade through the old installer kits to figure out how
ancient that BASIC is. It's ancient.
I'd forgotten about the problems with the BASIC manuals. They're really
not very good. Ah, well.
Post by E ThumpExternal SUB adder (integer,integer)
External INTEGER a,b
a=100
b=200
print "a+b before sub: ",a+b
call adder (10,20)
print "a+b after sub: ",a+b
end program
sub adder (integer c,integer d)
a=400
b=1000
print "a+b in sub: ",a+b
print "c+d in sub: ",c+d
end sub
%LINK-I-UDFSYM, A
%LINK-I-UDFSYM, B
%LINK-W-USEUNDEF, undefined symbol A referenced
in psect $CODE offset %X00000021
in module TEST$MAIN file SYS$USERS:[ECKY]TEST.OBJ;24
%LINK-W-USEUNDEF, undefined symbol B referenced
in psect $CODE offset %X0000002C
in module TEST$MAIN file SYS$USERS:[ECKY]TEST.OBJ;24
%LINK-W-USEUNDEF, undefined symbol A referenced
in psect $CODE offset %X00000048
in module TEST$MAIN file SYS$USERS:[ECKY]TEST.OBJ;24
......
Assuming that's all one source code module (showing your commands helps
us figure out the details of your tests), you've told BASIC ADDER, A,
and B are all EXTERNAL, and they're all in one source module; there are
no EXTERNAL references, and (what the LINKER is telling you) no
declarations. If you're trying to break the BASIC-preferrred
modular-programming model within your app—I'd assumed that wasn't your
goal (as that approach turns gnarly), but looking at the source code
again, that does appear to be what you want to do—then using COMMON is
one way to do that. I'd still keep clear of COMMON storage, as that
usually ends badly as the apps increase in scale and complexity.
$ TYPE EXAMPLE.BAS
OPTION TYPE=EXPLICIT
DECLARE LONG A,B
a=100
b=200
print "a+b before sub: ",a+b
call adder (10,20)
print "a+b after sub: ",a+b
end program
sub adder (integer c,integer d)
a=400
b=1000
print "a+b in sub: ",a+b
print "c+d in sub: ",c+d
end sub
$ BASIC EXAMPLE
$ LINK EXAMPLE
$ RUN EXAMPLE
a+b before sub: 300
a+b in sub: 1400
c+d in sub: 33984
a+b after sub: 300
$
$
$ TYPE COMMON.BAS
OPTION TYPE=EXPLICIT
COMMON (HACK) LONG A, B
A=100
B=200
print "a+b before sub: ",a+b
call adder (10,20)
print "a+b after sub: ",a+b
end program
sub adder (integer c,integer d)
COMMON (HACK) LONG A, B
a=400
b=1000
print "a+b in sub: ",a+b
print "c+d in sub: ",c+d
end sub
$ BASIC COMMON
$ LINK COMMON
$ RUN COMMON
a+b before sub: 300
a+b in sub: 1400
c+d in sub: 33984
a+b after sub: 1400
$
--
Pure Personal Opinion | HoffmanLabs LLC