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.

Author
Message
NickH
18
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 17th Oct 2011 15:48
Hi, Just a quick question.

I've been using an example from the following thread:

http://forum.thegamecreators.com/?m=forum_view&t=183061&b=1

This works fine except if I load it I have to dim the array to a certain size. As my files are variable in size, is there a way of determining the size of the array required to take all the data?

Thanks
Nick

www.illuminatedfx.com
For web design and custom GUI and 3D model design services.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 17th Oct 2011 17:12
If you're loading and saving arrays there's two ways of getting it right.

You can check for End Of File and then stop building your array from there. (that would mean using the "Array Insert At Bottom()" type of commands)

Or when saving your data, the header of your file can have the exact array count. Read that, set your Dim's, then read the data in. This is usually the way people go.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
WickedX
17
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 17th Oct 2011 18:18 Edited at: 17th Oct 2011 19:01
Hay NickH,

You can dimension the array with zero then use “array count (player(0))” the get the array index count.

Edit: Never mind, evidently it doesn’t work like that.
NickH
18
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 17th Oct 2011 19:10
Thanks WLGfx, I had thought about both of those options, though I'd considered a sort of header to be the best of the 2 for me. I thought, as I was going out for a bit, I'd see if there was a more elegant way of doing it. I've not done a lot with file handling within DBPro. I'll do that later, thanks

No problem WickedXGames

www.illuminatedfx.com
For web design and custom GUI and 3D model design services.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 17th Oct 2011 19:20
@WickedXGames - You can still use it similar to that:



DBP arrays are very useful when used like this and with a few experiments I've done in the past they are also very fast too.

@NickH - You may be better off using a header as I'm not actually sure if you can check for the end of file with the DBP file handling commands. Most of my work these days are in C/C++ so I proto type code in DBP nowadays...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
WickedX
17
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 17th Oct 2011 19:58 Edited at: 17th Oct 2011 20:01
Thanks WLGfx

Actually I have used these array functions before. This is a function I played with to build an object similar to a trianglefan function. Going by Nicks link I expected make array from memblock to add the index count.



Now back to this thread. If each type array index is fixed in size. You could try this.

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Oct 2011 20:48
@NickH,
You can use my Datafile IO plug-in, along with the LOAD ARRAY FROM DATAFILE and SAVE ARRAY TO DATAFILE.

Here's an example:


The only restriction is the the target array must be dim'd to the correct type before you load the new data into it. Any existing data in the target array will be safely returned to the system before the new data is loaded.

NickH
18
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 18th Oct 2011 02:14 Edited at: 18th Oct 2011 16:58
Thanks for the responses.

@IanM. I actually did try your plugin first, but I wanted to try another way before settling on how to go about this. I do own DarkData too, but this is only very simple saving and loading so that's a bit OTT. I'm a big user of certain plugins and yours is one of them. Thanks

Edit - I've gone back to Matrix1, but using a header and it works perfectly. My little app is just about complete now.

www.illuminatedfx.com
For web design and graphic design services

Login to post a reply

Server time is: 2026-07-11 14:37:12
Your offset time is: 2026-07-11 14:37:12