Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
save and load function
#1
how can i make an easy way to make an save and load stuff for my games with the open commnad
Reply
#2
Easy way? I don't quite understand you, but I'll try to guess.

The easiest way to save game data is opening a text file with OPEN "file" FOR OUTPUT AS #filenumber, and then putting important variables in it using PRINT #filenumber, variable. Don't forget to CLOSE #filenumber when you're done.

To load, just OPEN "file" FOR INPUT AS #filenumber, and get those variables from the file using INPUT #filenumber, variable. Don't forget to CLOSE #filenumber.

For more info, check QB help and try to be more specific in your next post, just to point me in the direction where I should help you Smile
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
ok... that just wat i wontd to know
Reply
#4
The easiest way is to use get and put, but that advice only applies if you know exactly what you'll be saving and loading. INPUT/OUTPUT is a lot easier to manipulate if you decide to add something later or change the format..
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#5
Why dont u create a type containing all the variables and just PUT it in a binary file and then when u require to retrieve it just GET it from the file in the same variable like this:

Type typgame
score as integer
...
...
...
End Type

DIM gm AS typgame

gm.score = 1000
gm.... = ...

'To put
OPEN "game.bin" FOR BINARY AS #1
PUT #1, gm
CLOSE #1

'To get
OPEN "game.bin" FOR BINARY AS #1
GET #1, gm
CLOSE #1

P.S: I am sleepy right now so just take this code as a guide line 8)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)