Applescripts in Yosemite no longer Working

Oh, I didn’t realize that was for this as well.
Sorry. My bad.
I’m not sure how to change the feature request into a bug report. Or how to delete it and create a new bug report.
I will create a new bug report then maybe someone can delete feature request 43029.

edit: <https://xojo.com/issue/43030>

You can already use Javascript with Christians plugins, the OSA kit stuff works for it. Only for 64bit though, for 32 bit the only language available is applescript. I’ve sort of half way implemented this in my main dayjob app XTension but it’s really horribly difficult to use. Normal verbs seem to work OK for the most part, but the song and dance necessary to use any Object model stuff ranges from horribly undocumented to actually impossible. Apple has a HUGE amount of work to do to get Javascript for automation up to par with AppleScript.

I’ve just spent an entire day trying to track down a “table overflow error” from applescript and still haven’t succeeded so I’m not exactly that fond of it right now, but even given all the time I’ve wasted over the years figuring out how it’s broken, javascript is broken more… Many of the normal accessors that you can use against an applescript to get and set properties of the script, or to get handler names or execute handlers directly with data seem to be totally broken for Javascript. Almost equally as likely I’ve got something messed up with the 64 bit conversion of the declares, though they all work fine for AppleScript the Javascript ID numbers tend to be very large numbers so I’m still thinking an overflow may be in there somewhere.

If you don’t have or want to use the plugins you can use javascript for automation with the really old school declares to Carbon. This is actually how I’ve ended up doing it because there are no Cocoa endpoints for any of it that aren’t just wrappers to the Carbon library and all my applescript support is already using them. Most of the basic code I’m using for them dates literally back to 2001 and I originally adapted it from some other examples while writing classic macos apps. It hasn’t significantly changed in all that time. The conversion of all the declares to 64bit was more than a little bit exciting. I’m currently trying to blame some number size overflow for my table error and considering if i should convert all the raw memory block AEDescriptors in the app to a class that I manage myself or to Christians NSAppleEventDescriptor classes in the MBS plugin. And then I read things like this thread and wonder if I shouldn’t just implement the PHP scripting plugin from the MBS plugins or invest in the Einhurger lua/python plugin. It’s very discouraging to hear such things.

Back to the original post, please be aware of a rather impressively huge applescript bug in Yosemite for 32 bit apps. There is a problem in the apple event ID table code for 32 bit apps that limits loaded scripts, results or other things that require a script ID in an app to 255! In previous versions it was 32k (or maybe larger) and in El Capitan they fixed it, but for Yosemite you should definitely use a 64 bit app if your app is using a dynamic number of user generated scripting. In XTension each script is loaded from the database at launch and as they run any result from the script is also kept around as a script ID so that you can retrieve it later, so for each script thats 2 ids and others are used as necessary while running so some overhead availability in the table is necessary. While loading my partners database into the app it would just crash on load because he had more scripts than that. That was a frantic couple of days as I sorted that out, there doesn’t seem to be any info about that problem anywhere on the internet except for a blog post on the late night software site where the author of script debugger warns about something similar. Compiling to 64bit solves the problem though.

Holy Crap did you guys get off topic!

Anyway I have resolved the issue. David Andrews was right on all accounts.
Couple of tricks:

  1. Image Capture in OS 10.9.5+ has slightly different structure than in OS 10.8.5 & under, I had modify the System Events call in all the AS calling the Image Capture app.
  2. And of course you need to recompile these and add them back into your Xojo app, deleting the old versions as you go.
  3. Recompile your XOJO app and delete then add the Newly Built app back into the Privacy settings.
  4. It actually helped that I renamed my app.

Thanks so much for all the input.

I do want to give MBS a try, I use some of their plugins already.

Steve