Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 20.5 ('Xojo Workflows')
Instant purchase and download via GumRoad!

FEATURE

Calling XojoScript

Using XojoScripts in AppleScripts

Issue: 20.5 (September/October 2022)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 27,130
Starting Page Number: 49
Article Number: 20506
Resource File(s):

Download Icon project-20506.zip Updated: 2022-08-31 23:28:39

Related Link(s): None

Excerpt of article text...

I'll confess up front that I hate AppleScript. I love the concept and I really want to like the language, but AppleScript is funky and bizarre. Its syntax literally changes with each application you try to script!

AppleScript, if you're not aware, is a Mac technology that lets you script (automate) applications. It can be incredibly powerful, but in order to script an application, it has to support AppleScript and include a special dictionary of commands. While there are some standard commands, different applications often implement them with subtle changes, meaning you have to write your AppleScript differently depending on which app you're scripting. It can be exhausting trying to get an app or AppleScript itself to do what you want.

Usually when I need to write an AppleScript I end up searching the web for examples and manuals, copying and pasting online code, and using trial and error until I get something that works. It's frustrating to say the least, and for years I've longed to be able to write simple Xojo code that would easily do what I want to do rather than rely on weird AppleScript.

A while back Apple made it so you can write application scripting code in JavaScript instead of AppleScript. That might seem like an improvement, except I don't like JavaScript much, either. Worse, the JavaScript implementation is buggy and many things don't work, so then you're trying to figure out if your JavaScript is bad or if what you're trying to do won't work in that language. Ugh!

Recently while reading a blog post about AppleScript versus JavaScript, the author mentioned AppleScript's "do shell" command. This was not something I was aware of, but it's really cool. You can basically run a shell script inside your AppleScript, or even just call out to Unix terminal commands. The author, a fan of Python, used it to call Python via terminal to have his favorite language do his processing.

Suddenly a lightbulb when on in my head. If AppleScript can call out to Python or another scripting language, why couldn't it execute XojoScript commands?

...End of Excerpt. Please purchase the magazine to read the full article.