REALBasic GUI’s for AppleScript – chapter 1

In this blog category RealBASIC & XOJO (AppleScript UI, AppleEvents & Python) I’m eventually getting around to revisiting the work I did to automate the design studio artwork production for Superdrug Stores, Co-op Pharmacy, Threshers and Wine Rack many years ago. Mainly this blog section is a record of a relatively small and successful area of my work but also an exposition of my philosophy which is an holistic world view. My website is not really here to tout for business or advertise cleverness, sell stuff, or evangelise for someone else for an under-the-table payment, but rather is a functionally and simply designed respository as well as a personal record of my ‘digital’ life, mainly for my own reflection but also to give away any secrets and skills I have picked up along the way.

The key ingredients in this series are:

1) Script Debugger by Late Night Software.I use v 4.5.7
2) Library (available on this site for free)
3) REALBasic (now known as XOJO).
3) InDesign CS4 or later and Adobe Acrobat 9 Pro or later are also required for scripting
4) TextWrangler (free), the light version of BBEdit (paid) from Bare Bones. Can use either.

The OS I’m using is El Capitan (10.11.6), the version of Script Debugger is 4.5.7. and REALBasic is 2007r5 and also XOJO 2118.

To start at the beginning….

Below is a simple REALBasic project called ‘RB Applescript’ that I started out with when first beginning to write commercial publishing automation solutions.

Background to AppleScript

Why do you need AppleScript in the first place anyway? Why can’t you use Python, or Ruby. For print publishing and professional creative design apps, nearly all of them are AppleScriptable along with the Mac oerating system itself. You’ve got the usual suspects: PhotoShop, Illustrator, InDesign and Acrobat (Adobe Creative Cloud/Suite) and QuarkXpress, the Mac Finder as already mentioned, as well as admin integration tools such as Microsoft Excel, Word, Mail, BBEdit and OmniFocus. Only AppleScript can drive them all ( like Tolkien’s “one ring”) and by doing so can make them all talk to each other and pass data and then get organised and bossed about by the Mac itself. Pure Genius. There simply is nothing else that comes close or is as all encompassing, powerful and elegant. Even on the Macintosh nothing else is as ‘insanely great’ as AppleScript.

The RealBasic / XOJO USP

I was looking for a simple way to give a proper and powerful control interface to AppleScript. RealBasic gives a frontend GUI that amongst many other features can handle the drag and drop of text and CSV files which can then be processed by the underlying scripts. When automating or scripting the Finder, or QuarkXpress, Photshop, Acrobat, or BBEdit or all of them at the same time in a workflow it makes sense to do the whole thing in AppleScript and then collate all the scripts into a single App, a REALBasic wrapper. Scripts can then be broken down into smaller functional sub units reducing the memory overhead, simplyfying script complexity, making debugging and testing easier, enabling processes to be saved to log files, creating user preference files and also adding additional goodies, help documentation and branding into the ‘App’s’ menu system. The point is that its not that you can’t do this with Xcode and Swift or Objective-C or some other solution but that you can do all this, rather quickly and singlehandedly with simple and straight forward code in a very short space using REALBasic

RB AppleScript

RB Applescript consists of a Window Interface (Window 1) containing a text entry box (named EditFeld1) a push button (named PushButton1) and an AppleScript called ‘SaySomeString.scpt’

You can create a simple interface around your AppleScript in just two minutes so that you can control it with the usual Mac interface elements like buttons and textfields and progress bars supplied by the REALBasic ‘wrapper’. AppleScript in itself gives you very limited dialog boxes that pop up and disappear in a sequential manner, whereas with RB you can create an app with a presence that stays visible on screen throughout the ‘running’ and integrates the scripts with the user. You can attach a whole bunch of applescripts in one app, have many different windows and elements and link them all together in logic with a minimal amount of basic code.

RB Applescript Project with Window 1 interface tab consisting of a Window with an EditField called EditField1 and a BevelButton called pushbutton1

In Script Editor save the following as a script

on run {x}
	tell application "Finder"
		say x
	end tell
end run

drag the file icon of the script from desktop into your REALBasic ‘RB Applescript’ Project tab.

in Window1’s code tab add the code for pushbutton1‘s Action under the Controls list. Note the name of the applescript is added as a function here

In the Project tab click on the App icon and then in properties pane set the Mac name of the app to RB Applescript.

Check the Build Settings in the Project menu are set to Intel Mac and then click build