Qbasicnews.com
April 25, 2019, 01:00:55 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Yet another Module question...  (Read 2252 times)
Rokkuman
Na_th_an
*****
Posts: 1973



« on: September 07, 2003, 07:23:36 PM »

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.
Logged
Ninkazu
Been there, done that
*****
Posts: 1169



WWW
« Reply #1 on: September 07, 2003, 07:31:47 PM »

DIM SHARED in a bi file.
Logged

am an asshole. Get used to it.
Rokkuman
Na_th_an
*****
Posts: 1973



« Reply #2 on: September 07, 2003, 07:50:51 PM »

Didn't work... it's "5" in one module... "0" in the other...
Logged
Sterling Christensen
Na_th_an
*****
Posts: 1328


« Reply #3 on: September 07, 2003, 08:31:05 PM »

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.
Logged
Rokkuman
Na_th_an
*****
Posts: 1973



« Reply #4 on: September 07, 2003, 08:47:29 PM »

I did that, and now in the MAIN module, it's telling me "array already dimensioned"... GAAAAH!
Logged
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #5 on: September 07, 2003, 10:08:13 PM »

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)
Logged

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.
Sterling Christensen
Na_th_an
*****
Posts: 1328


« Reply #6 on: September 07, 2003, 10:31:35 PM »

Quote from: "Megaman"
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 from: "Agamemnus"
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...
Logged
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #7 on: September 07, 2003, 11:20:34 PM »

oh.......
Logged

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.
Rokkuman
Na_th_an
*****
Posts: 1973



« Reply #8 on: September 08, 2003, 01:36:58 AM »

Did it, now I'm getting "Duplicate Definition"... *growl*
Logged
ak00ma
Ancient Guru
****
Posts: 669



« Reply #9 on: September 08, 2003, 02:30:41 AM »

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.
Logged

B 4 EVER
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!