[Info-vax] VAX BASIC global variables.

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


On 10/14/2021 9:24 PM, Arne Vajhøj wrote:
> On 10/14/2021 9:18 PM, E Thump wrote:
>> 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.

External SUB adder (integer,integer)

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)
common (myarea) integer a,b
a=400
b=1000
print "a+b in sub: ",a+b
print "c+d in sub: ",c+d
end sub

Arne




More information about the Info-vax mailing list