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.

DarkBASIC Professional Discussion / Saving a type array

Author
Message
Divided
FPSC Reloaded TGC Backer
10
Years of Service
User Offline
Joined: 31st Oct 2013
Location:
Posted: 17th Nov 2016 11:32
Hey guys, don't know how active the DarkBasic community is these days but I find that DB is literally the best language ever to make a text based game which AppGameKit doesn't provide or at least is VERY limited due to not having console input etc...

on the question:

I've found myself in need of saving an array of types which i've named objects.
the follow is the type code:


next up is the AddObject function which simply adds a text item into an array:


and lastly, is the PrintObjects function which will simply display the name of each item within an array.


when I run the code, my error is:
Quote: " Runtime Error 54 - Array type is invalid at line 234 "

I know that doesn't mean or help much but maybe i'm wrong.
Cheers!

( apologies if anyone notices this as a re-post, I accidentally posted the same question in the DB thread and not the DBP thread. )

Real programmers don't comment their code, because if it was hard to write it must be hard to read!

- PixHil Entertainment
Download Pixel Smasher on the App Store today!
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 17th Nov 2016 13:45
You cannot save a TYPE array. See here:

https://forum.thegamecreators.com/thread/16810



So many games to code.....so little time.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 17th Nov 2016 16:35
I would say write the data out in csv format, each index is a line, each type is a comma separated field.

Load it back in by reading each line and splitting on the commas


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
revenant chaos
Valued Member
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 17th Nov 2016 18:08
The Matrix1Util plugins contain commands for loading and saving arrays which are compatible with UDTs; SAVE ARRAY TO DATAFILE and LOAD ARRAY FROM DATAFILE.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 17th Nov 2016 21:28
When in doubt, matrix1 usually has a good solution


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Divided
FPSC Reloaded TGC Backer
10
Years of Service
User Offline
Joined: 31st Oct 2013
Location:
Posted: 17th Nov 2016 23:19
Cheers guys! this has been most helpful!

Real programmers don't comment their code, because if it was hard to write it must be hard to read!

- PixHil Entertainment
Download Pixel Smasher on the App Store today!

Login to post a reply

Server time is: 2024-04-16 12:41:52
Your offset time is: 2024-04-16 12:41:52