having a bit of trouble refering to a text file on my computer harddrive and opening it…
this is what i have so far…
-- open about database file
set aFile to ("sinik:Users:sinik:Desktop:users.txt")
open for access aFile
set txt to (read aFile)
close access aFile
return aFile
Your ‘aFile’ is a string. Some processes still distinguish between path strings and file specifiers and I’d guess that’s what you’re seeing here. Also, you don’t need to open the file for access if you’re only going to read it once in the script.
-- open about database file
set aFilePath to (path to desktop as Unicode text) & "users.txt"
set txt to (read file aFilePath)
return txt
thanks guys… this works if the file is on the desktop but i seem to have a problem reading the other files which are in sub folders from off the desktop
-- open about database file
set aFilePath to (path to desktop as Unicode text) & "users:profile_template.txt"
set txt to (read file aFilePath)
return txt
depending on the file i choose it either tells me there is an end of file error or the original cant make profile_template into type file…
Well. It’s likely that the end of file errors are caused by the files concerned still being open for access after your previous errors stopped the script before it could close them again. Since the files have already been read right through, the rewritten script is trying to read the files from the end instead of from the beginning. If you save the script and quit Script Editor, that should close any files that have been left open and should hopefully solve that problem. I don’t know why you’re getting the other error “ unless the files you’ve specified don’t exist, of course.