Posts: 18
Threads: 7
Joined: Feb 2003
Dear Qbasicers
Salaam
Back in Feb.2003 I asked for help to tackel too long qbasic programs and received some advice that made compiling possible.
Howver I now find that when I break a long program into 2 parts the second part does not recieve the arrays even though all dim statements are copied at its top. Could anybody help.
I use qbasic 7.1 on vintage 486 computers to build control systems for the industry.(up to 384 I/O lines so far)
Best Regards
A.Sadjadian
Posts: 1,752
Threads: 21
Joined: Jun 2002
Main module:
Code:
COMMON SomeArray()
COMMON AnotherOne()
DIM SHARED SomeArray(whatever)
DIM SHARED AnotherOne(whatever)
Other modules:
Code:
COMMON SomeArray()
COMMON AnotherOne()
Make sure that you keep the COMMON statements in the same order in all the modules. Or you can use blocks (/something/).
Posts: 1,407
Threads: 117
Joined: Dec 2002
Posts: 18
Threads: 7
Joined: Feb 2003
Dear Plasma 357
Thank you for the help. However the code you posted does not work as I get the message subscript out of range for the first array member used in a sub in the second (not main) module. There seems that DIM shared statements have to be in all moduls but that is not enough as then I do not get the above error but the array members can not be manipulate in moduls other than the main.
I will be trying the solutions in ModularizeIt next. and will report the results.
Thanks again
A.Sadjadian
Posts: 1,752
Threads: 21
Joined: Jun 2002
I had it backwards...should be COMMON SHARED and then DIM , not COMMON and DIM SHARED. (SHARED is not needed with DIM in this case, but if you use it nothing changes)
Code:
DECLARE SUB test1 ()
DECLARE SUB test2 ()
COMMON SHARED a()
COMMON SHARED b()
DIM a(100)
DIM b(500)
CLS
test1
test2
SUB test1
a(0) = 1
a(100) = 2
b(0) = 3
b(500) = 4
END SUB
Code:
DECLARE SUB test2 ()
COMMON SHARED a()
COMMON SHARED b()
SUB test2
PRINT a(0), a(100), b(0), b(500)
END SUB
Posts: 4,307
Threads: 63
Joined: May 2003
http://faq.qbasicnews.com/?blast=PushingTheLimitsOfQb
Try this. I think it is the link Antoni provided you with leads to the samething 8)