I'm trying to write a script which doublespaces the lines of the source text, but I'm having a problem with setting the altered source text back. -Any of you guys who knows the right incantation?
set AppleScript's text item delimiters to ""
set frontAppBid to bid's frontmostBundleId()
haltIfAppIsNotSupported(frontAppBid)
-- return
try
tell application id frontAppBid
tell its script window 1
activate
if frontAppBid is "com.apple.ScriptEditor2" then
set theText to every paragraph of text of its document 1
else if frontAppBid is "com.latenightsw.ScriptDebugger" then
set theText to script source of its document
end if
set {tids, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
set theText to text items of theText
-- display dialog "here"
repeat with aPar in theText
set contents of aPar to "" & aPar & return
end repeat
-- set AppleScript's text item delimiters to tids
set theText to theText as text
tell its document
set script source of it to a reference to theText
-- the last thing I tested for
end tell -- of script window 1 to theText
end tell
set AppleScript's text item delimiters to tids
end tell
on error e number n
tell me
activate
display dialog e & ":" & n
end tell
end try