Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Yet another Module question...
#1
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.
Reply
#2
DIM SHARED in a bi file.
am an asshole. Get used to it.
Reply
#3
Didn't work... it's "5" in one module... "0" in the other...
Reply
#4
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.
Reply
#5
I did that, and now in the MAIN module, it's telling me "array already dimensioned"... GAAAAH!
Reply
#6
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.
Reply
#7
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...
Reply
#8
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.
Reply
#9
Did it, now I'm getting "Duplicate Definition"... *growl*
Reply
#10
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)