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.

AppGameKit Studio Chat / How do I create a file for save system?

Author
Message
Krael
3
Years of Service
User Offline
Joined: 18th Jan 2021
Location:
Posted: 18th Jan 2021 21:20
I want to create a custom file for save systems. How do I do it? I cannot find a create file function anywhere.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 18th Jan 2021 22:38 Edited at: 18th Jan 2021 22:42
see the Read/Write File commands, Shared Variable Extra commands, and the Array/JSON commands.

without knowing how much data you want to save, how it's arranged, and which platforms are involved, it's difficult to suggest one over the other.
[My Itch.io Home] [Now Playing]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=AGK] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[Google Forum Search]
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 21st Jan 2021 19:25
AppGameKit has 2 Functions.,

OpenToWrite( FileID, FileName$ )
OpenToRead( FileID, FileName$ )

Now personally I'd prefer the Function to simply be "OpenFile"., because you're actually more limited when Writing than Reading.
For example., when you're Writing to a File you HAVE to specify where you want to Start Writing in the File (be it at the Start, or an Offset) ... the SetFilePos( ) and GetFilePos( ) Functions while not part of the "Read File" Section; are ONLY usable if the File is Opened to be Read.
The other frustration of this, is that in Order to Read/Write to a File; you HAVE to constantly Open and Close the File for the specific Operations.

A better alternative to this is using a Memory Block (Memblock) to Create / Manipulate the Data.
This can be done with the Memblock Functions:

CreateFileFromMemblock( FileName$, MemblockID )
CreateMemblockFromFile( MemblockID, FileName$ )

Data Manipulation is much easier and you can do R+W rather R/W Operations via Memblocks... but there are some downsides to this.
First is Performance.

Memblocks are MUCH Slower ... there is an irony here that in Dark BASIC Classic we used to have lengthy discussions about the very same drawbacks.
The other issue is that Memblocks use a Fixed Size., so if you want to expand what Data you have then you HAVE to create a Second Memblock that's Larger and Transfer across all the Data; or obviously switch to the File Commands, as those are only limited to 4GB; which should be more than enough outside of some select situations.

Now a way around this., and I used to use this method in Dark BASIC Classic is to create a "Save Block"... akin to how Console Memory Cards used to work.
In this regard you'd always know the size and at least one of the downsides of Memory Blocks was eliminated; as they'd always be the same generic size.

Login to post a reply

Server time is: 2024-04-19 13:54:38
Your offset time is: 2024-04-19 13:54:38