How to debug writing or reading a file
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
How to debug writing or reading a file
Hi,
I am in the process of updating my iOS app and have hit a snag that has me baffled.
Me app writes an reads preference file.
This worked ine in my initial app.
However when building under the latest xcode and LC 10 my app shows no evidence of reading in the prefs.
So the code that previously worked does not seem to now.
My question: how can I check my read and write routines on my iPad to determine if they are at fault?
I am in the process of updating my iOS app and have hit a snag that has me baffled.
Me app writes an reads preference file.
This worked ine in my initial app.
However when building under the latest xcode and LC 10 my app shows no evidence of reading in the prefs.
So the code that previously worked does not seem to now.
My question: how can I check my read and write routines on my iPad to determine if they are at fault?
-
- Livecode Opensource Backer
- Posts: 10076
- Joined: Fri Feb 19, 2010 10:17 am
Re: How to debug writing or reading a file
I would just set up an extremely basic stack to read in a text file and write a text file.
Now if your stack (which you'll have to turn into an iOS executable) is set to write a file called "GUFF": then having supposedly exported the file you can search on your iPad for a file called "GUFF".
Now if your stack (which you'll have to turn into an iOS executable) is set to write a file called "GUFF": then having supposedly exported the file you can search on your iPad for a file called "GUFF".
Re: How to debug writing or reading a file
Hi James,
please post your script(s)!
Guessing is just too time consuming.
Best
Klaus
please post your script(s)!
Guessing is just too time consuming.

Best
Klaus
Re: How to debug writing or reading a file
I realised I can try the remote debugger.
I can set a breakpoint and put the result after each read and write.
and
I can set a breakpoint and put the result after each read and write.
Code: Select all
put specialFolderPath("documents") into thisfolder
put thisfolder &"/Heartease/Heartease.pref" into preffile
put the result
if there is a file preffile then --load prefs
put the result
Code: Select all
put specialFolderPath("documents") into thisfolder
put thisfolder &"/Heartease/Heartease.pref" into preffile
put prefs into URL("file:/" & preffile)
put the result
Re: How to debug writing or reading a file
And what does THE RESULT tell you/us?
Hint:
put prefs into URL("file:/" & preffile)
I think the SLASH is not neccessary:
put prefs into URL("file:" & preffile)
And of course the folder "Heartease" needs to be present to make this work.
Hint:
put prefs into URL("file:/" & preffile)
I think the SLASH is not neccessary:
put prefs into URL("file:" & preffile)
And of course the folder "Heartease" needs to be present to make this work.
Re: How to debug writing or reading a file
Well removed “/“, thanks @klaus.
Tested in IDE and the simulator and it worked fine.
Tested on my iPad and it fails.
The save file returns “can’t open file”
Tested in IDE and the simulator and it worked fine.
Tested on my iPad and it fails.
The save file returns “can’t open file”
Re: How to debug writing or reading a file
Just to be sure, the folder "Heartease" already exists on your iPad, right?
Re: How to debug writing or reading a file
When I open the app, the first thing it does is check for the presence of a pref file.
if it doesn't exist it creates one.
Well it creates the folder and then the file.
This works.
There is indeed a pref file.
if it doesn't exist it creates one.
Well it creates the folder and then the file.
This works.
There is indeed a pref file.
Re: How to debug writing or reading a file
So, the left hand doesn't know what the right hand has done.
In updating the app I decided to change the names of the pref file from what had had previously used.
Unfortunately I missed an occurrence.
Sorry
In updating the app I decided to change the names of the pref file from what had had previously used.
Unfortunately I missed an occurrence.
Sorry

Re: How to debug writing or reading a file
You are forgiven. I don't have to deal with such things, because I never make misteaks.
Craig
Craig