MacOS Error code: -2707 Displayed at End of Some Scripts in BBEdit

I have an annoying problem that I don’t know how to debug. I suspect it’s a BBEdit issue, but it only affects my Applescripting. At the end of certain Applescript routines performed within BBEdit, usually just before the results are inserted back into an open document, I get a dialog box which displays “This operation couldn’t be completed, because an error occurred. (MacOS Error code: -2707)”

The results of the script are always contained in the clipboard, so I usually just dismiss the dialog box and paste the results.

This always happens only at the very end of the script. If I add more statements in the script before the end, they’ll execute properly but at termination the dialog box shows up.

The insertion into the open document isn’t the problem. Interim steps in the script which call for the same type of insertion in BBEdit work without error.

And some of these scripts are legacy scripts which worked fine in previous versions of BBEdit. At some upgrade point in the past, these started showing up.

Seen this before? Any ideas?

Thanks very much!


I quick look at MacErrors.h shows me the error

errOSAInternalTableOverflow = -2707, /* Signaled when a runtime internal data structure overflows*/

my feeling is that you may be trying to put to much into the clipboard but I don’t know this may very well be a problem with bbedit but I have no real way to see whats happening could you maybe post on of your scripts so that we can take a closer look ?


Thanks, Mcgrailm,

It would be difficult to post a script because it uses a set of routines in a different file – which may be part of the problem. I couldn’t find the error, so it’s helpful to know that it’s a data structure overflow problem. I’ll need to poke around a bit more.


Sorry I could be more helpful… I hope it works out for you.


Thanks. It was very helpful to find out what the error code meant. I always figured it was some kind of memory error. I don’t think it’s too much in the clipboard because it happens on rather small text snippets. It only seems to bite me on the scripts which call other scripts – perhaps it’s some kind of recursion.

But I do appreciate your research on the error code. I looked up the source you referenced, which looked like a header file – part of Carbon? A C file? Perl? Where do I get my hands on macerrors.h?


It came with xcode if you have xcode then you have the errors.h file. its a header file I think its objective C I don’t know for sure I use that file only to find out what errors are. and I am novice when it comes to xcode.


Ah, never installed XCode. I’ll have to give it a look. Thanks!

Here’s where it is on my machine…

Did you guys ever find a resolution for this error, I am getting the same thing using Photoshop with AppleScript.

"Could not save changes to this script because of a scripting system (OSA) error. -2707

Save changes? I’m not saving any changes in my AppleScript??

Also if I run the script within Script Editor I do not get the error. However, if I run the script as an app being called from a shell command then I get the -2707 error at the end of the script.