Page 1 of 1
How to read a external txt file ?
Posted: Thu May 01, 2014 1:34 pm
by sirobchGA0cda
Hello,
I try to read a external "txt" file in IOS and put it in a field "read".
I can read the file path but not its contents.
In "Standalone application settings" I put the txt file (folder "documents") in the copy file menu :
And here is my script in a button :
Code: Select all
on mouseUp
set the defaultFolder to specialFolderPath("Documents")
put "file:" & SpecialFolderPath("engine") & french.txt into langFile
put url ("file:" & langFile) into field "read"
end mouseUp
It's possible to help me.
Thanks in advance.
Boris
Re: How to read a external txt file ?
Posted: Thu May 01, 2014 1:38 pm
by jmburnod
Salut Boris,
Try this
Code: Select all
on mouseUp
put SpecialFolderPath("engine") & "/" & "french.txt" into langFile
put url ("file:" & langFile) into field "read"
end mouseUp
All the best
Jean-Marc
Re: How to read a external txt file ?
Posted: Thu May 01, 2014 1:54 pm
by sirobchGA0cda
Salut Jean-Marc,
Thanks for your answer, but the content of the file txt is not put in the field.
Boris
Re: How to read a external txt file ?
Posted: Thu May 01, 2014 2:12 pm
by Klaus
Boris, it is not
MANDATORY that you put the content of the file into a field!
A variable will do, too!

Re: How to read a external txt file ?
Posted: Thu May 01, 2014 2:58 pm
by sirobchGA0cda
Thanks Klaus,
Your suggestion made me to try a different code :
Code: Select all
on mouseUp
set the defaultFolder to specialFolderPath("Documents")
open file specialFolderPath("engine") & "/French.txt" for read
read from file specialFolderPath("engine") & "/French.txt" until EOF
put it into Myvar
put item 1 of line 1 of myvar into field "read"
close file specialFolderPath("engine") & "/French.txt"
end mouseUp
and finally it's works.
Boris
Re: How to read a external txt file ?
Posted: Thu May 01, 2014 3:29 pm
by Klaus
Hi Boris,
if you are lazy like me, you can have it much shorter:
Code: Select all
on mouseUp
put specialFolderPath("engine") & "/French.txt" into tFile
put item 1 of line 1 of url("file:" & tFile) into field "read"
end mouseUp
Best
Klaus
Re: How to read a external txt file ?
Posted: Thu May 01, 2014 4:21 pm
by sirobchGA0cda
Hi Klaus,
Thank you very much.
I must learn to be lazy.
Best