ini files on iphone/ipod touch.

Previous topic - Next topic

mykyl66

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

MrTAToad

Don't forget that the location you specified can only be read from and not
written to

mykyl66

Oh? Is there anywhere I can write to an ini file so that I can save game state etc?

Mike R

codegit

#3
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
------------------------------------------
1 X Acer TravelMate 4270, laptop, XP PRO
1 X Dell Studio 17 laptop, Windows 7
1 X MacBook Pro 2,2 GHz Core 2 Duo, 2 GB RAM, 160 GB HDD, 9400M
2 X iTouch
1 X HTC Desire (Android 2.1)
iPad soon to be added

MrTAToad

It's always best to do something like that for all platforms

mykyl66

Thank you folks. will give it a try right now.

Cheers

Mike R

matchy

Just to add, the function (with parameter) PLATFORMINFO$("DOCUMENTS") will return the user's writable app folder.