Author Topic: Clarification of 'INIOPEN' (iPod), please?  (Read 3428 times)

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
Hi,

I am using INIOPEN to save and load some simple files that hold persistent data. Although not documented as such, I noted in the examples and other code on the forums that using INIOPEN "" after you've done your last INIPUT writes that file to disk, seemingly by calling a 'null file' to open.

However, when I call the save function next, I get the following error in the debug console on opening my file:

fopen("/var/mobile/Applications/<etc>/Documents/file.dat", "rb") failed

and when I next call INIOPEN "" at the end of the function, I get:

request: fopen("", "rb") failed

To clarify, there are two seperate files I am saving to, and I have to assume that they may have made changes and saved to the preferences file before I am next able to call the save file, so I can't just 'leave it open', as such.

I know that I could use OPENFILE and then explicitly call CLOSEFILE, but it seems so, so much easier for my purposes to use INIOPEN because it does all the hard work of formatting it in a readable format. To further clarify, apart from these debug messages, what I'm trying to do works just fine!

1) are these considered 'just for info' messages? And I don't mean just by you guys!  :P  What I mean is, would Apple reject it as a bug?

2) Is there any way round it? Am I ordering something wrong? Is there a way to explicitly TEST if a particular file opened for writing with INIOPEN is *still* open and therefore not make the duplicate call?

Thanks in advance for any wisdom or advice you can impart  :)

Offline Ozden79

  • Mr. Polyvector
  • ***
  • Posts: 121
    • View Profile
Re: Clarification of 'INIOPEN' (iPod), please?
« Reply #1 on: 2010-Mar-18 »
I'm using INIOPEN "" in a game in appstore now, though not sure if I get such a warning in it...

MrTAToad

  • Guest
Re: Clarification of 'INIOPEN' (iPod), please?
« Reply #2 on: 2010-Mar-18 »
I wonder if "fclose" would be better (if its not used)...

Offline mykyl66

  • Mr. Polyvector
  • ***
  • Posts: 114
    • View Profile
Re: Clarification of 'INIOPEN' (iPod), please?
« Reply #3 on: 2010-Mar-18 »
Is there such a command as fclose now??? If so that's a big help as its not mentioned in the help files anywhere.

Cheers

Mike R

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
Re: Clarification of 'INIOPEN' (iPod), please?
« Reply #4 on: 2010-Mar-19 »
I wonder if "fclose" would be better (if its not used)...

As a thought, could I use INLINE to call fclose myself? I've never used INLINE. I don't even know how you would pass the file path you've declared in GLB to an inline statement. But assuming I could, would it make these errors go away? Any reason NOT to do this (iPod specifically speaking!)?

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10851
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Clarification of 'INIOPEN' (iPod), please?
« Reply #5 on: 2010-Mar-19 »
Using INIOPEN "" is the right way to close an ini file and save the changes if any. Ignore the output here. I should make that better.
I fixed that output in the next version.
Writing to several ini files is not really supported nicely, ATM, though.