03-14-2023, 07:16 PM
I had a tutorial user contact me about using the SHARED statement. He was trying to share variables in a subroutine like this:
SHARED a, b, c AS INTEGER
According to the Wiki this is not an alternate method of using SHARED, however, the IDE accepts this form and there is no run-time error either.
Shouldn't method 4 above get flagged somehow as being incorrect?
SHARED a, b, c AS INTEGER
According to the Wiki this is not an alternate method of using SHARED, however, the IDE accepts this form and there is no run-time error either.
Code: (Select All)
DIM AS INTEGER a, b, c
a = 10
b = 20
c = 30
Mysub
SUB Mysub ()
'---------------
' ** Method 1 ** ------------> ** THIS WORKS **
'---------------
'SHARED AS INTEGER a, b, c ' all SHARED on a single line
'---------------
' ** Method 2 ** ------------> ** THIS WORKS **
'---------------
'SHARED a AS INTEGER ' all SHARED on a separate line
'SHARED b AS INTEGER
'SHARED c AS INTEGER
'---------------
' ** Method 3 ** ------------> ** THIS WORKS **
'---------------
'SHARED AS INTEGER a, b ' two different SHARED alternatives
'SHARED c AS INTEGER
'---------------
' ** Method 4 ** ------------> ** THIS DOES -NOT- WORK **
'---------------
'SHARED a, b, c AS INTEGER ' only the value of 'c' is passed, 'a' and 'b' are zero.
'-----------------------------------------------------------------------------------
' Method 4 is not a valid alternative to SHARED listed in the Wiki and should
' therefore not work. However, I would think an error would be generated in the IDE
' or at least at run-time when SHARED is attempted to be used in this manner?
'-----------------------------------------------------------------------------------
PRINT a, b, c
END SUB
Shouldn't method 4 above get flagged somehow as being incorrect?