Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Array was not resized correctly?

Author
Message
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 21st Aug 2010 13:15
Ok here's the thing. I have managed to make a savegame file that saves your location, screen resolution and inventory, all is good with it, YAY! BUT i have stumbled upon a small problem... If i have put something into my inventory array and save it so there is only 1 object in the inventory, that's fine, BUT if i then "Use" that item and it is removed from the array and then SAVE the game, when i try to reload it at a later time i get the error message "Runtime error : Array was not resized correctly at line xxx"

What does it mean and how could i fix it?

I can see from your smile, you're not here for the sunset

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD
Nights Bane
14
Years of Service
User Offline
Joined: 15th Dec 2009
Location:
Posted: 21st Aug 2010 18:35
I think when it says 'Array was not resized correctly' as an error msg, what it is telling you is your program tried to put information into it, and it either did not have enough dimensions i.e) array(0,0,0) <-- this is a three dimensional array- it is however more likely that your array does not have enough memory allocated to it.

so if i added to an array using 'ARRAY INSERT AT BOTTOM' and then reloaded an array which had less 'slots', for lack of a better word, this would certainly cause problems.

I'm pretty new to DB myself, and have found arrays dominating most of my time of late. so I will be keeing an eye on this thread myself! Hope i've been a little helpful.. also, maybe could you post a bit of code to look at?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st Aug 2010 19:34
Quote: "Array was not resized correctly"

That sounds like one of mine.

I can reproduce the problem, so I'll get it fixed ready for the next release. Until then, you'll need to work around the problem - you should write an extra value to the datafile, eg write a 0 byte if the array is empty and don't write the array, or write a 1 otherwise and do write the array. Then when loading, if the value read is 0, just use the EMPTY ARRAY command on the array. Otherwise, load the array as you do now.

Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 23rd Aug 2010 15:11
ok so it doesn't seem to be limited to what i said before now

if i save the game with an empty inventory, reload and then save the game with an item in the inventory and then reload the game, it does the same.

if i load a game with 1 item in the inventory then add another, save and then reload it again does the same.

I can see from your smile, you're not here for the sunset

Windows 7 64 bit, AMD Phenom II x4 Black edition, 4 GB Ram, Radeon HD 4650, 540 GB HDD
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 23rd Aug 2010 17:35
Are you wiping out the old array before you reload? Try using EMPTY ARRAY right before loading.

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 24th Aug 2010 01:40
I had the same problem recently in an editor I was working on. I tried to save one part of an array by putting that particular slot into a temporary array and saving it that way, like so (PEFE_T is a user defined type):


and load it like this:


That didn't work. But when I changed all of the PEFETEMP(0)'s to PEFETEMP(1) it worked. So maybe it has something to do with the size of your array.

Are you using the ARRAY INSERT AT BOTTOM command? Maybe it's trying to load an array of one size into an array of another. You could write a byte or integer with the array's count before saving it. Then, when you load it up again, you could read that integer, DIM the array properly, and then load it.

By DIM properly, I mean something like this:


I have no idea if this will work, but it might be worth a try :S


Guns, cinematics, stealth, items and more!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Aug 2010 15:30 Edited at: 24th Aug 2010 15:35
The problem can occur any time you shrink or grow the array to a different size than it was declared as - that can only happen using the list/queue array resizing commands.

If you include a 'DIM array( get array count( array() )' before you save the array then that might fix the problem.

Login to post a reply

Server time is: 2024-09-28 20:35:59
Your offset time is: 2024-09-28 20:35:59