tell application "TextWrangler"
try
(* THIS DOESN'T WORK IN APPLESCRIPT OBJECTIVE-C Snow Leopard 10.6.6
The open always goes to the script and not the tell
set textDocument to open theFile
*)
set textDocument to first document whose name is DebugLogName
on error
-- document not in a window
try
set theAlias to theFile as alias
on error
-- file does not yet exist
set textDocument to make new document with properties {name:DebugLogName}
try
do shell script "touch " & quoted form of DebugLogPath
set theAlias to theFile as alias
save textDocument to theAlias
end try
end try
end try
tell text of textDocument -- won't work as one tell line
make new line with properties {contents:logLine & return}
end tell
-- scroll window to the bottom
tell window of textDocument to select insertion point after last character
end tell