Hey all!
I have an issue with reading a text file in Applescript. This is for an Adium script, and the file is in the same folder as the script itself.
Here's a snippet of what I'm trying to do:
The log is just to allow me to see what variable has what, and to tell me what part of the code I am in. It seems that the script knows the file is there, but when running I get this:
So the log "(On Error Block)Data:" means no data is being presented! I want it to come out as a list, but I just want data to show up first. Any suggestions on fixing this issue?
Thanks for any help!
PS: I created the text file in TextEdit and did modifications using VIM.
I have an issue with reading a text file in Applescript. This is for an Adium script, and the file is in the same folder as the script itself.
Here's a snippet of what I'm trying to do:
Code:
on ReadFile()
log "Reading file..."
tell application "Finder"
try
set fileName to "macgames.txt" as Unicode text
log "Filename: " & fileName
set fileID to open for access fileName
log "File ID: " & fileID
set dataFromFile to read fileID
log "(Try Block)Data: " & dataFromFile
on error
log "(On Error Block)Data: " & dataFromFile
--close access fileID
end try
close access fileID
end tell
end ReadFile
The log is just to allow me to see what variable has what, and to tell me what part of the code I am in. It seems that the script knows the file is there, but when running I get this:
Code:
open for access "macgames.txt"
2816
(*File ID: 2816*)
read 2816
(*(On Error Block)Data: *)
close access 2816
(*Start compare loop...*)
(*End of compare loop...*)
(*Return application name: Script Editor*)
So the log "(On Error Block)Data:" means no data is being presented! I want it to come out as a list, but I just want data to show up first. Any suggestions on fixing this issue?
Thanks for any help!
PS: I created the text file in TextEdit and did modifications using VIM.