Hi James,
welcome to the Forum.
You are actually mixing two ways to read data into your field:
one where you first open the file, then read and close the file. After reading until EOF the data is in the variable it
Code: Select all
On Preopencard
local Intro -- initialization optional
put "/Tippen/Intro.rtf" into Intro
disable fld id 1024
Open file specialFolderPath("desktop") & Intro for read
read from file specialFolderPath("desktop") & Intro until EOF
set the rtftext of fld id 1024 to it
close file specialFolderPath("desktop") & Intro
end Preopencard
the other URL form is easier/shorter for reading a whole file, here you put it directly into the rtfText of the field
Code: Select all
On Preopencard
put "/Tippen/Intro.rtf" into Intro
disable fld id 1024
set the rtftext of fld id 1024 to url ("file:" & (specialFolderPath("desktop") & Intro))
end Preopencard
both scripts tested and they work.
with the url form it is important to put "url ("file:" & (specialFolderPath("desktop") & Intro))" into parenthesis. Otherwise
here wrong: url "file:" & (specialFolderPath("desktop") & Intro) it does not work.
You initialized a script local variable at the top of the script but only used one handler. The script local variable is persistent between calls and accessible to every handler that is below its initialization. Not needed here. If you want to initialize the variable you can do it as I indicated in the first script. Except if you turned on explicit variable in the preferences: then you have to declare the variables. But still in this case no need to declare the variable outside of the handler.
Kind regards
Bernd