GLOBAL and SHARED variables
Posted: Fri Jan 10, 2025 2:22 pm
Hi everyone.
I am trying to write a routine to print large sprites using small tile pieces.
Anyway, I am having some problems with GLOBAL and SHARED variables.
I've reduced the code to a very basic example.
On the CPC target, this prints 8, which is the expected result.
However, this code:
Causes a compilation error:
undefined variable (OPTION EXPLICIT ON) (a)
If I set OPTION EXPLICIT OFF, the program compiles, and works as expected.
But that removes the desired benefits of using OPTION EXPLICIT.
Does GLOBAL only work when OPTION EXPLICIT is OFF?
I am trying to write a routine to print large sprites using small tile pieces.
Anyway, I am having some problems with GLOBAL and SHARED variables.
I've reduced the code to a very basic example.
Code: Select all
OPTION EXPLICIT ON
DIM a AS BYTE
PROCEDURE testProc
SHARED a
PRINT a
END PROCEDURE
a=8
CALL testProc
However, this code:
Code: Select all
OPTION EXPLICIT ON
GLOBAL a AS BYTE
PROCEDURE testProc
PRINT a
END PROCEDURE
a=8
CALL testProc
undefined variable (OPTION EXPLICIT ON) (a)
If I set OPTION EXPLICIT OFF, the program compiles, and works as expected.
But that removes the desired benefits of using OPTION EXPLICIT.
Does GLOBAL only work when OPTION EXPLICIT is OFF?