Adding AppleScriptObjC to Existing Scripts

Originally published at:

AppleScriptObjC opens up lots of doors for AppleScript, but it’s not without its quirks. One of them is that it can change the way file references are resolved. Here is a script that shows the problem: use AppleScript version “2.4” – Yosemite (10.10) or later – use framework “Foundation” use scripting additions set filePath to…



Putting a “use statement” in a handler is an interesting approach. For some reason I had been thinking the “use statement” would not work in a handler. Overall I think that is a pretty good way to reduce to interaction with AppleScript things and ASObj-C things. With your way the scripter doesn’t get as distracted by problems with interactions between AppleScript stuff and ACObj-C stuff.

One of things I have been trying to look for is ways like this that make ASObj-C easier to use. I think determining good standard practices would help make ASObj-C a lot easier to use. I’ve seen a lot of haphazard ASObj-C that is hard to figure out, really hard to use as a template, and very hard to modify because a small change in the code can cause the entire script to stop working and return incomprehensible errors.

No one has ever come up with any kind of of “best practices” that has spread across very many scripters. I think ASObj-C could be used used by scripters with far less trouble if the documentation is improved. After I update the ASObj-C database I’m planning on working on creating exports from the database that can create some kind of documentation. This is something Jim suggested a lot in the past and I have come to think he is probable right.

If there is both a database and a book form that dumps the information in the database to a book more people could benefit. Also people could use use database dumps to create wikis as Jim has also suggested.

I have really been thinking about this stuff lately and your post fitted nicely into what I’ve been thinking about.

Your book Everyday ASObj-C has good practices in it but it’s mixed in with other stuff. I have thought about pulling the best practices out of you book and making it a basis to creating a new best practices that is more complete. Something that people on the discourse group could participate in.

Thanks Shane :slight_smile: