[Info-vax] VAX BASIC global variables.

Arne Vajhøj arne at vajhoej.dk
Thu Oct 14 20:36:07 EDT 2021


On 10/14/2021 8:23 PM, E Thump wrote:
> I come from BBC Basic where all variables are global unless
> explicitly defined as local to a sub/proc.
> 
> VAX BASIC seems to operate the opposite way; IE variables by default
> are local. QB64 also seems to operate this way however in QB64, I am
> able to DIM SHARED [var_name] which makes a variable accessible
> globally.
> 
> How do I accomplish the same in VAX BASIC? I want a variable declared
> at the top to be common throughout all the code, SUBs and all. At
> this time, I'm working with a single source file.
> 
> I'm looking at the COMMON keyword but I can't see how that works for
> what I want, if at all it does!

This program print 3:

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

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

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

Arne




More information about the Info-vax mailing list