Qbasicnews.com

Full Version: Redim problem...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I made a map editor for my engine that you can cutomize the grid width and height of the map to make it versatile. In my game, I have a subroutine that loads the info from the map and allocates the map array according to the width and height of the map. But here's the problem, when I use redim in that subroutine, it won't let me allocate a map that's over (32, 29). When it redims a map with (32, 30), it crashes. Everything seems correct. At the begining I use:
'$dynamic
redim shared Map(1 to 1, 1 to 1) as integer

and in the MapInit subroutine, when it loads the info from the map file, I have:

redim Map(1 to GridXMax, 1 to GridYMax)

Everything seems correct. Like I said, it works if it isn't higher that (32,29) ???
I noticed that if I use Dim instead and don't make it dynamic it works fine for any map size, but the map always have to be the same size. Does anybody know anything about this? Thanks
i would do this:

Code:
Main:
DIM MAP(1,1)
LoadMapDimensions
SYSTEM 'end this demo

GetMapArray:
REDIM MAP(1 to dimensionX, 1 to dimensionY)
Return

SUB LoadMapDimensions
'load dimensions
gosub GetMapArray
'load mapdata
END SUB

and don't forget that the dimensions you're loading have to start with the coutning #'s, not 0

I didn't exactly change anything did I?
Yeah, that's sorta what I did. But the map array has to be dynamic. I want to be able to reload differant size maps into the same array when I switch levels.
qb.exe /ah
doesn't that just set arrays into xms? not sure how it works... how does it help?
Try Aga's way.

QB/L Rel/Ah

;*)
Quote:doesn't that just set arrays into xms? not sure how it works... how does it help?

No, it allows arrays to be >64K.
I tried all that, but to no avail. The array isn't bigger than that, much smaller. I think I located the problem. I unloaded some tiles that I had loaded, and it allowed me a larger map array. So that means it was because I was low on memory. But when I use dim as a static array, it let me use tons more subscripts for my array. Why would declaring a dynamic array reduce the amount of memory available by a lot?
then the program would only set aside the memory for the tiels as they are needed, rather than at the very beginning of the program.

if using 7.1, try /Ea also, without the /ah though