[Info-vax] VAX BASIC global variables.
Jeffrey H. Coffield
jeffrey at digitalsynergyinc.com
Fri Oct 15 11:44:45 EDT 2021
On 10/15/2021 02:42 AM, E Thump wrote:
>
> Here's what I've done now:
>
> External 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
>
> compiles clean but throws this when linking :
>
> %LINK-W-NUDFSYMS, 2 undefined symbols:
> %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
> ......
>
>
The EXTERNAL statement says something else will define whatever you are
referencing. COMMON or MAP is what you want and it has to be in all
program/subprogram sections. The "MY_DATA" will be the name that is
shared so it can be whatever you want, it just has to be the same in all
sections that want to reference it.
Try this:
----------------------------------------
External SUB adder (integer,integer)
COMMON (MY_DATA) 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)
COMMON (MY_DATA) INTEGER a,b
a=400
b=1000
print "a+b in sub: ",a+b
print "c+d in sub: ",c+d
end sub
------------------------------------------
Jeff Coffield
www.digitalsynergyinc.com
More information about the Info-vax
mailing list