[Info-vax] VAX BASIC global variables.
Arne Vajhøj
arne at vajhoej.dk
Fri Oct 15 20:18:58 EDT 2021
On 10/15/2021 4:37 PM, Dave Froble wrote:
> On 10/15/2021 3:13 PM, Arne Vajhøj wrote:
>> On 10/15/2021 3:03 PM, Dave Froble wrote:
>>> On 10/15/2021 12:56 PM, Arne Vajhøj wrote:
>>>> This does not look good:
>>>>
>>>> program hack
>>>> common (mydata) long a(2)
>>>> call s
>>>> print a(0),a(1)
>>>> end program
>>>>
>>>> sub s
>>>> common (mydata) word a(4)
>>>> a(0) = 1
>>>> a(1) = 1
>>>> a(2) = 2
>>>> a(3) = 2
>>>> end sub
>>>
>>> In Arne's example, the linker will allocate space for the 4 element
>>> array,
>>> but the main program will not be able to address a(3).
>>
>> It runs fine.
>>
>> And outputs exactly what I expected.
>>
>> $ bas hack
>> $ lin hack
>> $ run hack
>> 65537 131074
>>
>> (which is 00010001 and 00020002 in hex)
>>
>> But definitely not nice.
>
> I see my reading skills are deteriorating, like the rest of me. I
> missed the
> LONG vs WORD. I thought you were defining different size common blocks.
N. I was doing different types.
> And a(4) is a 5 element array, not 4 as I stated elsewhere.
Ah. So it should have been a(1) and a(3). Not totally like Fortran.
Arne
More information about the Info-vax
mailing list