Page 1 of 1

Read/Write file

Posted: Sat Jan 15, 2011 6:50 pm
by jeanvouillon
Hi,
I have tried to read/write a txt file, following the tutorial (http://lessons.runrev.com/spaces/lesson ... he-iPhone-).
My stack works fine in the 4.2 iPad simulator, but when I deploy it on a real 4.2.1 iPad, it doesn't work anymore: when I try to get the information from the file, I just get its filename instead...
Did I missed something obvious? Any suggestions?
Thanks.

Re: Read/Write file

Posted: Sat Jan 15, 2011 7:31 pm
by Klaus
Hi Jean,

could you please post the relevant script(s)?

best

Klaus

Re: Read/Write file

Posted: Sat Jan 15, 2011 9:06 pm
by jeanvouillon
Hi Klaus,

I kept it simple:

A 'save' button:
on mouseUp
set the defaultFolder to specialFolderPath("documents/")
put URL ("file:notes.txt") into field "notes"
end mouseUp

A 'open' button:
on mouseUp
set the defaultFolder to specialFolderPath("documents/")
put field "notes" into URL ("file:notes.txt")
end mouseUp

In the simulator it's working fine, but on the iPad "notes.txt" is displayed in the field when the open button is clicked...

Re: Read/Write file

Posted: Sat Jan 15, 2011 9:49 pm
by Klaus
Hi Jean,
jeanvouillon wrote:...but on the iPad "notes.txt" is displayed in the field when the open button is clicked...
IS displayed or IS NOT displayed?
If its displayed, what is your problem? 8)

You could check the result after saving and loading of the file.
"the result" should be empty after successful writing/reading of the file.
...
put fld "notes" int URL...
answer the result
...

Same after loading.


Best

Klaus

Re: Read/Write file

Posted: Sat Jan 15, 2011 10:02 pm
by jeanvouillon
Hi Klaus,
Sorry for the confusion.
When I wrote that "notes.txt" was displayed, it's mean that the name of the file was displayed, instead of its content...

I'm going to check the result,
Thanks for the advice

Re: Read/Write file

Posted: Sat Jan 15, 2011 10:06 pm
by jeanvouillon
Hi again,
The result is "Can't open file" when I try to write or read the file...

Re: Read/Write file

Posted: Sat Jan 15, 2011 10:36 pm
by Klaus
Hi Jean,

ah, sounds like a permission problem.
Maybe the Defaultfolder did not get set?

Try this to avoiid setting the defaultfolder:
...
put URL ("file:" & specialFolderPath("documents") & "/notes.txt") into field "notes"
...
put field "notes" into URL("file:" & specialFolderPath("documents") & "/notes.txt")
...

Best

Klaus

Re: Read/Write file

Posted: Sat Jan 15, 2011 10:55 pm
by jeanvouillon
Great! :D
It's working!
Thanks Klaus for the solution and your fast answer!

Re: Read/Write file

Posted: Sun Jan 16, 2011 12:38 am
by Klaus
Bonsoir Jean,

we memorize:
Setting "the defaultfolder" does not work as exspected on iOS (yet) :D

Bon nuit, mon ami!


Best

Klaus