GLBasic forum

Main forum => GLBasic - en => Topic started by: mykyl66 on 2009-Nov-11

Title: ini files on iphone/ipod touch.
Post by: mykyl66 on 2009-Nov-11
Hi,

After compiling my application on iPod Touch, I am getting an fOpen error on my ini files AFTER the first ini file has been successfully opened and read from.

It's not like I can explicitly close a file, because CLOSEFILE requires a handle defined by OPENFILE.

Besides which, as I understood it, INIOPEN handles closing of files when a new one is called. So can anyone tell me where I'm going wrong or any iPhone specific gotchas?

e.g

request: fopen("Media/lastsave.ini", "rb") failed
wrt-request: fopen("Media/lastsave.ini", "wb") failed

The paths are correct as are the filenames. Its just fails.

Mike R
Title: Re: ini files on iphone/ipod touch.
Post by: MrTAToad on 2009-Nov-11
Don't forget that the location you specified can only be read from and not
written to
Title: Re: ini files on iphone/ipod touch.
Post by: mykyl66 on 2009-Nov-11
Oh? Is there anywhere I can write to an ini file so that I can save game state etc?

Mike R
Title: Re: ini files on iphone/ipod touch.
Post by: codegit on 2009-Nov-11
Maybe this can help. This is how I do it. (obviously, I am writing to the file on quit, but you can write anywhere within your program using this method)

FILE_PATH$ = PLATFORMINFO$("DOCUMENTS")
.
.
.

ok = OPENFILE(1, FILE_PATH$+"/highscore.dat", 1)
IF (ok)
   READLONG 1, highscore%
ENDIF

.
.
.
SUB GLB_ON_QUIT:
   ok = OPENFILE(1, FILE_PATH$+"/highscore.dat", 0)
   IF (ok)
      WRITELONG 1,highscore%
      CLOSEFILE 1
   ENDIF

ENDSUB
Title: Re: ini files on iphone/ipod touch.
Post by: MrTAToad on 2009-Nov-11
It's always best to do something like that for all platforms
Title: Re: ini files on iphone/ipod touch.
Post by: mykyl66 on 2009-Nov-11
Thank you folks. will give it a try right now.

Cheers

Mike R
Title: Re: ini files on iphone/ipod touch.
Post by: matchy on 2009-Nov-12
Just to add, the function (with parameter) PLATFORMINFO$("DOCUMENTS") will return the user's writable app folder.