[Info-vax] VAX BASIC global variables.

Arne Vajhøj arne at vajhoej.dk
Thu Oct 14 21:24:50 EDT 2021


On 10/14/2021 9:18 PM, E Thump wrote:
> On Friday, October 15, 2021 at 1:36:11 AM UTC+1, Arne Vajhøj wrote:
>> This program print 3:
>>
>> program comdemo
>> common (myarea) integer v
> 
> Alright, thanks so I was on the right track with COMMON... what's the significance of myarea then?

That is the name of the memory area.

And it is really what matters!

Which becomes clear by the fact that this also print 3:

program comdemo2
common (myarea) integer v
v = 1
call s1
end program

sub s1
common (myarea) integer w
w = w + 1
call s2
end sub

sub s2
common (myarea) integer u
u = u + 1
print u
end sub

> I changed my program to this but it doesn't work as I want:
> =====
> External SUB adder (integer,integer)
> 
> common (myarea) integer a
> common (myarea) integer b

I would make that:

common (myarea) 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

You do not have a common (myarea) in adder, so it does
not use anything global.

Arne




More information about the Info-vax mailing list