GLBasic forum

Main forum => GLBasic - en => Topic started by: fjsantosb on 2009-Sep-03

Title: New PlatformInfo Parameter
Post by: fjsantosb on 2009-Sep-03
Hi all.

I was waiting impaciently for the new command Parameter of PlatformInfo 'Document', which have the ability to save files on iPhone (I need mainly to save some settings).
Its seems to work pretty well (Althought i haven't tested on real device yet, it works wells on glbasic).
But i discover while i was playing around that files creates using openfile command (and write command), beggins always with '0', ie. i have created a data file name settings.dat and glbasic creates 0settings.dat file.
I don't care so much about it, but i am a little worry if that behaviour will be change in a future (creating settings.dat without extra character), because the applications done before the change can be crash (well i can code to find new file, but player will lose his game, settings, progress etc).

Best Regards, fjsantos.
Title: Re: New PlatformInfo Parameter
Post by: codegit on 2009-Sep-03
Hi

I have tested on PC and iTouch and I dont seem to be having any problem. Here is what I did to save a high score file:

Code (glbasic) Select


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: New PlatformInfo Parameter
Post by: fjsantosb on 2009-Sep-03
Yep its seems to work pretty well, the problem is the name of the file, anyfile i can save always is saved with character '0' ie. i save 'settings.dat', and in my hd is saved '0settings.dat'.

Best regards, fjsantos.
Title: Re: New PlatformInfo Parameter
Post by: Hemlos on 2009-Sep-04
Hi,

Sounds like a bug with openfile..

Does this fix it the name?

Code (glbasic) Select
COPYFILE a$, "newname.bak"
Title: Re: New PlatformInfo Parameter
Post by: fjsantosb on 2009-Sep-04
Mmmm, I tried your solution Hemlos, but doesn't work cause the problems seems to be the value of variable path.
if you write


GLOBAL path = PLATFORMINFO$("DOCUMENTS");
PRINT path, 0, 0;


You get 0, as value of variable path.

Strange...
Title: Re: New PlatformInfo Parameter
Post by: Hemlos on 2009-Sep-04
Well to use info$ = PLATFORMINFO$(what$) you need to have this format as a string.

Second, platform info is simply a variable reader for your devices.

The openfile command is used for making/ saving files....if it isnt doing exactly what you want with the name...then its likely a bug...if you want i can move this thread into the bug report section.


Title: Re: New PlatformInfo Parameter
Post by: fjsantosb on 2009-Sep-04
You are right Hemlos, my problem was that i haven't format variable as string (i am used to use string before variable name on c#).
So is not a bug, its my mistake!

All is working perfect!

So sorry!  :-[
Title: Re: New PlatformInfo Parameter
Post by: Hemlos on 2009-Sep-04
NP, glad i could help!  :)