Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
memory overflow comiling larg program
#1
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
Reply
#2
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/).
Reply
#3
Check the FAQ
http://faq.qbasicnews.com/?blast=ModularizeIt
Antoni
Reply
#4
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
Reply
#5
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
Reply
#6
http://faq.qbasicnews.com/?blast=PushingTheLimitsOfQb

Try this. I think it is the link Antoni provided you with leads to the samething 8)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)