I need some help with this read/write code used for a script debugger 3 libary. Could anyone help me with it.
-- writes/reads from/to list of strings
-- don't think it works yet
property filepath : ""
property fileID : 0
on writeListToFile(theStringList, filepath, overWrite)
try
set fileID to open for access alias filepath with write permission
on error number errorNum
error number 0 -- reset error
return errorNum
end try
if overWrite then
set eof of fileID to 0
end if
repeat with theString in theStringList
try
write theString & return as text to fileID
end try
end repeat
end writeListToFile
on readFileToList(filepath)
local theString, theStringList
copy {} to theStringList
try
set fileID to open for access filepath
on error number errorNum
error number 0 -- reset error
return errorNum
end try
repeat
try
set theString to read fileID as text until return
set end of theStringList to {theString}
on error
exit repeat
end try
end repeat
try
close access fileID -- added this in the forum editor, not script editor. :)
end try
return theStringList
end readFileToList
It’s been a while since I’ve worked with AppleScript but it’s coming back to me. Any help would be much appreciated. I hope the script code is self explanitory.