Scripting Rectangular Selections in BBEdit 7
Subject:   Select All fails on never-saved documents
Date:   2005-03-10 06:54:19
From:   joemaller
Hopefully this will save someone some time and frustration.

AppleScripts which attempt to find all will fail if applied to documents which have never been saved. BBEdit 7 throws an error, BBEdit 8 returns (*found:true, found matches:BBEdit*)

If the script does not specifically check for this behavior, it will fail when trying to work with the expected results. Checking the class of found results seems to work.

Here's a slight modification of the first if statement in John's script which will prevent errors:

if found of search_result is true and class of found matches of search_result is list then

A more informative solution would be to alert the user that the search doesn't work on documents which have never been saved.