This is just a thank you to Shane Stanley for his tip ‘ignoring application responses’ regarding my freezing rtfd’s.
It worked, and for posterity, my code is below.
Unusually, the freeze only occurs when saving emails as rtfd’s from an ASObjC app, that seem to include certain ‘embedded in the text’ files. The same code pasted into a script editor script does not create an inaccessible file. Also, using File Buddy, the file shows as zero bytes, but if I add an administrator privilege, the file shows a size, e.g. 30 KB.
tell application "TextEdit"
close every document
ignoring application responses
try
open theDesktoprtfdFile as alias
on error errmsg number errnum
my transferMessage("* items to manually process")
try
tell application "Finder" to move file theDesktoprtfdFile to trash
end try
my setEMsgs(errnum, "mainMessagesView", "Error in fileAndMailHandlingSubRoutine1 whilst opening rtf document with TextEdit. Error number " & errnum & " Error " & errmsg as text, "Error Message Orange", true, "Cochin Bold", "14")
my mainLoopTwo()
end try
end ignoring
activate
tell application "System Events" to tell process "TextEdit"
try
if exists button "OK" of window 1 then click button "OK" of window 1
end try
end tell
if not (exists document 1) then
my transferMessage("* items to manually process")
try
tell application "Finder" to move file theDesktoprtfdFile to trash
end try
my mainLoopTwo()
end if
do shell script "sleep 0.2"
end tell