Qbasicnews.com
October 19, 2021, 10:06:19 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: memory overflow comiling larg program  (Read 3571 times)
A.Sadjadian
New Member

Posts: 18


« on: July 30, 2003, 10:50:33 AM »

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
Logged
Plasma
Na_th_an
*****
Posts: 1770


WWW
« Reply #1 on: July 30, 2003, 11:30:55 AM »

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/).
Logged
Antoni Gual
Na_th_an
*****
Posts: 1434



WWW
« Reply #2 on: July 30, 2003, 04:27:44 PM »

Check the FAQ
http://faq.qbasicnews.com/?blast=ModularizeIt
Logged

Antoni
A.Sadjadian
New Member

Posts: 18


« Reply #3 on: July 31, 2003, 06:00:09 AM »

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
Logged
Plasma
Na_th_an
*****
Posts: 1770


WWW
« Reply #4 on: July 31, 2003, 12:16:07 PM »

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
Logged
TheBigBasicQ
*/-\*
*****
Posts: 4550



WWW
« Reply #5 on: July 31, 2003, 03:13:44 PM »

http://faq.qbasicnews.com/?blast=PushingTheLimitsOfQb

Try this. I think it is the link Antoni provided you with leads to the samething  Cool
Logged
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!