Posts: 1,556
Threads: 298
Joined: Dec 2002
Alright, I can share non-arrayed variables (X,Y, and Z) just fine. I have an include file with the "Common Shared" statements, and it works perfectly.
But how do I get arrays like "Sprite(36,43)" shared throughout all of the modules? I hope I explained that right... thanks.
Posts: 1,166
Threads: 62
Joined: Apr 2003
DIM SHARED in a bi file.
am an asshole. Get used to it.
Posts: 1,556
Threads: 298
Joined: Dec 2002
Didn't work... it's "5" in one module... "0" in the other...
Posts: 1,272
Threads: 36
Joined: Feb 2003
blah.bi:
Code:
COMMON SHARED myArray() AS DOUBLE
...
blah.bas (main module):
Code:
'$INCLUDE:'blah.bi'
DIM SHARED myArray(234 TO 3453, 43 TO 456) AS DOUBLE
...
blah2.bas (secondary module):
Code:
'$INCLUDE:'blah.bi'
' No need for a DIM SHARED
PRINT "asdf" ' this line of source code will never be executed
... (SUBs, FUNCTIONs)
You could put a DIM SHARED in blah2.bas if you really wanted to, but it wouldn't do anything... just like the PRINT statement in blah2.bas. Module-level (outside of any SUB/FUNCTION) executable statements (like PRINT or DIM, not like DEFINT or COMMON) are ignored unless they're in the main module.
Posts: 1,556
Threads: 298
Joined: Dec 2002
I did that, and now in the MAIN module, it's telling me "array already dimensioned"... GAAAAH!
Posts: 3,368
Threads: 195
Joined: Jan 2003
hey megaman, what you can do is just make yourself a program that copies together two programs (gets rid of the DECLAREs and puts them all at the front, too).... or use plasma's routines... (dunno where they actually are)
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 1,272
Threads: 36
Joined: Feb 2003
Quote:I did that, and now in the MAIN module, it's telling me "array already dimensioned"... GAAAAH!
Make absolutely sure there is only one (1) DIM for that array in the entire project. It's only the COMMON SHAREDs that should be in all the bas files, or just in the bi.
Quote:hey megaman, what you can do is just make yourself a program that copies together two programs (gets rid of the DECLAREs and puts them all at the front, too)....
Open QB, Click File->Merge...
Posts: 3,368
Threads: 195
Joined: Jan 2003
oh.......
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 1,556
Threads: 298
Joined: Dec 2002
Did it, now I'm getting "Duplicate Definition"... *growl*
Posts: 594
Threads: 11
Joined: Oct 2002
Do it like this...
blah.bi:
Code:
COMMON SHARED map() AS STRING * 1
REDIM SHARED map(50, 50, 2) AS STRING * 1
blah.bas:
Code:
REM $INCLUDE: 'blah.bi'
You have to 'REDIM' the 'COMMON SHARED' array in every module. So you can just put the REDIM into the bi file and you get it.
B 4 EVER