Reading from an external file
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Reading from an external file
Hi Team,
I am struggling with a silly thing here, and I am sure it is easy!!
I hope you can help me.
I am writing to a text file in Documents...
open file specialFolderPath("documents") & "/myFood" & ".txt" for write
replace tab with ", " in field "email body" of card "email"
put field "email body" of card "email" into Food
write Food to file specialFolderPath("documents") & "/myFood" & ".txt"
close file specialFolderPath("documents") & "/myFood" & ".txt"
I want to write it into the App when it is opened.
I have tried many ways of wording it!!!
I appreciate your help as always,
All the best,
Jessamy
I am struggling with a silly thing here, and I am sure it is easy!!
I hope you can help me.
I am writing to a text file in Documents...
open file specialFolderPath("documents") & "/myFood" & ".txt" for write
replace tab with ", " in field "email body" of card "email"
put field "email body" of card "email" into Food
write Food to file specialFolderPath("documents") & "/myFood" & ".txt"
close file specialFolderPath("documents") & "/myFood" & ".txt"
I want to write it into the App when it is opened.
I have tried many ways of wording it!!!
I appreciate your help as always,
All the best,
Jessamy
Re: Reading from an external file
Hi Jessamy,
you HAVE TO USE PARENTHESIS when concatenating file- and/or object names!
And maybe I can interest you in the shorter URL syntax? That is a ONE-liner!
With your syntax you need to do like this:
You decide what to use.
Best
Klaus
you HAVE TO USE PARENTHESIS when concatenating file- and/or object names!
And maybe I can interest you in the shorter URL syntax? That is a ONE-liner!
Code: Select all
...
replace tab with ", " in field "email body" of card "email"
## No parens neccessary when you put the file- or objectname into a variable first!
## Which also saves a lot ot typing! 8-)
put specialFolderPath("documents") & "/myFood.txt" into tFile
put field "email body" of card "email" into url("file:" & tFile)
...
Code: Select all
...
open file (specialFolderPath("documents") & "/myFood.txt") for write
replace tab with ", " in field "email body" of card "email"
put field "email body" of card "email" into Food
write Food to file (specialFolderPath("documents") & "/myFood.txt")
close file (specialFolderPath("documents") & "/myFood.txt")
...
Best
Klaus
Re: Reading from an external file
Thankyou Klaus!
Yes, your method looks much neater!
But how do I read the file back into the app?
It is probably my fault for not being clear.
I want to copy the contents of the file into a field.
Best wishes,
Jessamy
Yes, your method looks much neater!
But how do I read the file back into the app?
It is probably my fault for not being clear.
I want to copy the contents of the file into a field.
Best wishes,
Jessamy
Re: Reading from an external file
Well, the other way round!
OK, better put it into an IF THEN clause:
Code: Select all
...
put specialFolderPath("documents") & "/myFood.txt" into tFile
put url("file:" & tFile) into field "email body" of card "email"
...
Code: Select all
...
put specialFolderPath("documents") & "/myFood.txt" into tFile
if there is a file tFile then
put url("file:" & tFile) into field "email body" of card "email"
end if
...
Re: Reading from an external file
Speaking about the 'Clause'...
... you could make that a one liner -
Code: Select all
...
put specialFolderPath("documents") & "/myFood.txt" into tFile
if there is a file tFile then put url("file:" & tFile) into field "email body" of card "email"
...
Re: Reading from an external file
Noone likes a wise guy, Starsk.. erm bogs!
Re: Reading from an external file
Thankyou both very much!!
I will have a go.
Have a wonderful Christmas!!
All the best,
Jessamy
I will have a go.
Have a wonderful Christmas!!
All the best,
Jessamy
Re: Reading from an external file
It worked!!
Thankyou both - you are angels!!
Much appreciated.
Jessamy
Thankyou both - you are angels!!
Much appreciated.
Jessamy