reading a file

This is my first applescript in a long time, and I am having the worst time trying to get a simple text file to load into my script. I found many examples on the net but they neither work or do what I want. I want the file name and path hardcoded into the script (not chosen with dialog box). For testing purposes I been trying display the contents of the file in a text box of the interface. I am sure this is extremely simple but I cannot find any working example of this.

This is what I got so far that just returns an error
“nsreceiverevaluationscripterror: 4(1)”

on clicked theObject

set theFile to (read alias "homedirectory:server.txt")

set theFile to open for access ("server.txt" as POSIX file)

set theData to theFile as string

close access theFile

set contents of text view "log" of scroll view "log" of window of theObject to theData

end clicked

Thanks

This should work:

set contents of text view "log" of scroll view "log" of window of theObject to (read alias "homedirectory:server.txt")

To read a file, you don’t need open it for access (you will do it to write to it).

Thanks for the tip, I shortened the script to that 1 line you gave me, however it gives me the exact same error. I am guessing I am referring to the scroll text field wrong, I labeled the text field as “log” its contained within the same window that the button you press to activate script is on. Dont know why this not working. =/
Any ideas?

Perhaps you labeled “log” only the scroll view. Try, then, text view 1 of scroll view “log” of…

Ahh you figured it out jj, thanks!