I am a little stuck on saving data from a game on the iPhone. I really only want to save 3 variable...score, high score, and level. All of them integers. I believe I understand openfile and I am aware of SUB GLB_ON_QUIT to save date on a sudden quit. My problem is I do not know how you create the file in the first place to write too. Is it as simple as creating a file in your working directory for your project, or does it have to be a certain name or place on the iPhone. Any help or code on how to create the file, write to the file, and later read from the file would be greatly appreciated.
Thanks in advance for any help.
Write it in the directory you get with PLATFORMINFO$("DOCUMENTS")
I use this:
SUB GLB_ON_QUIT:
Disco=OPENFILE(1, Fichero_Config$, FALSE)
IF (Disco)
WRITEBYTE 1,RELOJ_TIEMPO_JUEGO_HRS%
WRITEBYTE 1,RELOJ_TIEMPO_JUEGO_MIN%
WRITEBYTE 1,RELOJ_TIEMPO_JUEGO_SEC%
WRITEWORD 1,CONTADOR_EJECUCIONES%
WRITEBYTE 1,MUSICA_SISTEMA%
WRITEBYTE 1,SONIDO_FX_SISTEMA%
WRITEBYTE 1,PARTIDA_INICIADA%
CLOSEFILE 1
ENDIF
ENDSUB
And of course... when the app starts... first of all I use:
FUNCTION Carga_Config_Disco:
Disco=OPENFILE(1, Fichero_Config$, TRUE)
IF (Disco)
READBYTE 1,RELOJ_TIEMPO_JUEGO_HRS
READBYTE 1,RELOJ_TIEMPO_JUEGO_MIN
READBYTE 1,RELOJ_TIEMPO_JUEGO_SEC
READWORD 1,CONTADOR_EJECUCIONES
READBYTE 1,MUSICA_SISTEMA%
READBYTE 1,SONIDO_FX_SISTEMA%
READBYTE 1,PARTIDA_INICIADA%
CLOSEFILE 1
ENDIF
ENDFUNCTION
Don't forget to declare variable:
Fichero_Config$=PLATFORMINFO$("DOCUMENTS")+"/ProyectoLP_Config.dat"
ProyectoLP_Config.dat as the file.
:)
Thank you both very much. That should do it for me.