[Info-vax] VAX BASIC global variables.
Dave Froble
davef at tsoft-inc.com
Fri Oct 15 15:05:51 EDT 2021
On 10/15/2021 1:27 PM, Arne Vajhøj wrote:
> On 10/15/2021 12:56 PM, Arne Vajhøj wrote:
>> On 10/15/2021 12:09 PM, E Thump wrote:
>>> On Friday, October 15, 2021 at 4:44:49 PM UTC+1, Jeffrey H. Coffield
>>> wrote:
>>>> COMMON (MY_DATA) INTEGER a,b
>>
>>>> sub adder (integer c,integer d)
>>
>>> Next question to do with arrays. Instead of doing DIM Z(10) it seems
>>> I should do COMMON (MY_DATA) INTEGER Z(10) and then use that exact
>>> same line within the sub. The 10 and everything has to match. Am I on
>>> the right lines there?
>>
>> Yes.
>>
>> Declarations *should* match.
>>
>> They are not strictly required to, but it becomes
>> pretty messy if they don't.
>>
>> 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
>
> So better include:
>
> $ type common.bas
> common (mydata) long a(2)
> $ type better.bas
> program better
> %include "common.bas"
> call s
> print a(0),a(1)
> end program
>
> sub s
> %include "common.bas"
> a(0) = 1
> a(1) = 2
> end sub
> $ bas better
> $ lin better
> $ run better
> 1 2
>
> Arne
>
Yes, it works. I tend to avoid COMMON unless I really need it.
Note that the address of a RECORD structure can be passed as a parameter.
Quite useful.
--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. E-Mail: davef at tsoft-inc.com
DFE Ultralights, Inc.
170 Grimplin Road
Vanderbilt, PA 15486
More information about the Info-vax
mailing list