Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with OUT OF MEMORY 1

Status
Not open for further replies.

Corbinealious

Technical User
Aug 24, 2007
13
for those of you who want to jump straight into the question, basically...

i'm looking for a programming environment thats essentially just like qbasic but can compile using more memory.

for the longer explanation... ive been writing a game in Qbasic (4.5) and ive reached a point where i cant add anything without getting a "OUT OF MEMORY" error when i compile. so what next?

as for what ive done so far, i tried downloading some other compilers. i was hoping visual basic was similar, but its not... i tried a compiler called rapidQ, but i didnt understand it at all (although i cant say i spent much time there...) and i tried freebasic, which claims to be just like Qbasic, but i couldnt even get to the command prompt for it. after installing it and running the shortcut it puts on my desktop it only opens a dos command prompt, and i tried running every .exe in the folder and they all seem to do nothing.

basically i just want to be able to finish this little project of mine without having to learn a whole new programming language. i dont understand much about compilers im finding, but i just want something that can run my code. which id love to link for you if you're interested! but there doesnt seem to be an attachment option...

anyway any help would be appreciated! thanks in advance!
 
just kidding for that last part about using 2 dimensional common arrays! apparently you need to dim the array before the common statement. even for 1 dimensional arrays... fracturing my program now! fracturing?... is that a good word?...
 
ok so this is odd, i seem to be getting less memory the more pieces i put it in. so far ive only added one bas file with 2 subs (and the program functions, ive shared all the proper variables), and if i dim bob(2000) i run out of memory. while in my all together version i can dim bob(2000) just fine. any ideas?
 
Would you post some of your beginning code where you are declaring variables, using the COMMON statement(s), DIM SHARED etc. Basically (pardon the pun) the Initialization code you are using?
 
'the program starts with sub declarations such as...

DECLARE SUB drawbots ()
DECLARE SUB wallcheck (playerdircheck, playerwallcheck)
DECLARE SUB drawmap ()

'then goes straight to...

DIM movx(8), movy(8), botalive(8), botdir(8), movebackqueue(8), movequeue(8)
COMMON SHARED movx(), movy(), botalive(), botdir(), movequeue(), movebackqueue()
COMMON SHARED movebackyes, j, players, wallyes, saycollideyes, press$

'then to non common variables like...

DIM SHARED x, y, map, map(12, 12, 2), movcheckx(8), movchecky(8)
DIM SHARED beltB2R(257), beltL2B(257), beltT2L(257), beltR2T(257), beltB2L(257)

'then to the main thing. that what you're looking for?
 
Dynamic arrays in COMMON must be DIMensioned AFTER the COMMON statement in just the main module and should not be DIMensioned in any support modules.

A simple dynamic two-dimensional array example.

TEST1.BAS
Code:
DECLARE SUB PrintArray ()

COMMON TwoDimensional() AS INTEGER

REM $DYNAMIC
DIM TwoDimensional(5, 5) AS INTEGER

FOR x = 1 TO 5: FOR y = 1 TO 5
  TwoDimensional(x, y) = x * 10 + y
NEXT y, x

PrintArray

TEST2.BAS
Code:
COMMON SHARED TwoDimensional() AS INTEGER

SUB PrintArray

CLS

FOR x = 1 TO 5: FOR y = 1 TO 5
  PRINT TwoDimensional(x, y);
NEXT y: PRINT : NEXT x

END SUB


 
Regarding the DEFINT A-Z, I tried a new program where the first line of code is DEFINT A-Z. Then I added a SUB with the Edit, New Sub... function and lo and behold DEFINT A-Z was automatically added as the first line of the SUB procedure, prior to the SUB definition line. This explains why you were getting a parameter type mismatch on your SUBs that received parameters. All SUBs and FUNCTIONs must be preceeded with a matching DEFINT statement...and of course they aren't automatically added if you don't initially start with a DEFINT statement.
 
Your code but designed for dynamic arrays:

Main module
Code:
'the program starts with sub declarations such as...

DECLARE SUB drawbots ()
DECLARE SUB wallcheck (playerdircheck, playerwallcheck)
DECLARE SUB drawmap ()

'then goes straight to...

COMMON SHARED movx(), movy(), botalive(), botdir(), movequeue(), movebackqueue()
COMMON SHARED movebackyes, j, players, wallyes, saycollideyes, press$

REM $DYNAMIC
DIM movx(8), movy(8), botalive(8), botdir(8), movebackqueue(8), movequeue(8)

'then to non common variables like...

DIM SHARED x, y, map, map(12, 12, 2), movcheckx(8), movchecky(8)
DIM SHARED beltB2R(257), beltL2B(257), beltT2L(257), beltR2T(257), beltB2L(257)
Other Modules
Code:
COMMON SHARED movx(), movy(), botalive(), botdir(), movequeue(), movebackqueue()
COMMON SHARED movebackyes, j, players, wallyes, saycollideyes, press$

 
As far as the bob() array, instead of DEFINT A-Z, you could try changing the DIM bob() statement and all references to bob() to bob%() which forces the array to be INTEGERS, using half the space as the default single-pricesion array would.
 
Just my 2 cents.
On each saving BASIC writes DECLARE (at least QBasic does that).
so it puts parameter types in DECLARE, like
DECLARE SUB wallcheck (playerdircheck!, playerwallcheck!)
(see "!")?
after adding DEFINT parameter type is changed, hence error
"parameter type mismatch"

You can just delete that DECLARE lines.
Then you save, Basic will re-create this line now with integer parameters.
 
I found an ancient program, Monopoly, which was 101,060 characters long. I added a lot of functionality, such as a "boss-is-coming" feature yet nevertheless reduced it to 67,180 chars.

See history at

The point: you probably don't need more memory. You need to improve your coding techniques.

If you like, post your program at for an evaluation.

Mac
 
Well, you never posted, so I guess your problem was solved.

Glad for you!

Mac
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top