Read/Write file
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 21
- Joined: Sat Jan 15, 2011 6:40 pm
Read/Write file
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.
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
Hi Jean,
could you please post the relevant script(s)?
best
Klaus
could you please post the relevant script(s)?
best
Klaus
-
- Posts: 21
- Joined: Sat Jan 15, 2011 6:40 pm
Re: Read/Write file
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...
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
Hi Jean,
If its displayed, what is your problem?
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
IS displayed or IS NOT displayed?jeanvouillon wrote:...but on the iPad "notes.txt" is displayed in the field when the open button is clicked...
If its displayed, what is your problem?

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
-
- Posts: 21
- Joined: Sat Jan 15, 2011 6:40 pm
Re: Read/Write file
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
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
-
- Posts: 21
- Joined: Sat Jan 15, 2011 6:40 pm
Re: Read/Write file
Hi again,
The result is "Can't open file" when I try to write or read the file...
The result is "Can't open file" when I try to write or read the file...
Re: Read/Write file
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
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
-
- Posts: 21
- Joined: Sat Jan 15, 2011 6:40 pm
Re: Read/Write file
Great!
It's working!
Thanks Klaus for the solution and your fast answer!

It's working!
Thanks Klaus for the solution and your fast answer!
Re: Read/Write file
Bonsoir Jean,
we memorize:
Setting "the defaultfolder" does not work as exspected on iOS (yet)
Bon nuit, mon ami!
Best
Klaus
we memorize:
Setting "the defaultfolder" does not work as exspected on iOS (yet)

Bon nuit, mon ami!
Best
Klaus