Author Topic: ini files on iphone/ipod touch.  (Read 1813 times)

Offline mykyl66

  • Mr. Polyvector
  • ***
  • Posts: 114
    • View Profile
ini files on iphone/ipod touch.
« 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
« Last Edit: 2009-Nov-11 by mykyl66 »

MrTAToad

  • Guest
Re: ini files on iphone/ipod touch.
« Reply #1 on: 2009-Nov-11 »
Don't forget that the location you specified can only be read from and not
written to

Offline mykyl66

  • Mr. Polyvector
  • ***
  • Posts: 114
    • View Profile
Re: ini files on iphone/ipod touch.
« Reply #2 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

Offline codegit

  • Dr. Type
  • ****
  • Posts: 270
    • View Profile
Re: ini files on iphone/ipod touch.
« Reply #3 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
« Last Edit: 2009-Nov-11 by codegit »
------------------------------------------
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

  • Guest
Re: ini files on iphone/ipod touch.
« Reply #4 on: 2009-Nov-11 »
It's always best to do something like that for all platforms

Offline mykyl66

  • Mr. Polyvector
  • ***
  • Posts: 114
    • View Profile
Re: ini files on iphone/ipod touch.
« Reply #5 on: 2009-Nov-11 »
Thank you folks. will give it a try right now.

Cheers

Mike R

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1544
    • View Profile
Re: ini files on iphone/ipod touch.
« Reply #6 on: 2009-Nov-12 »
Just to add, the function (with parameter) PLATFORMINFO$("DOCUMENTS") will return the user's writable app folder.