With all the excitement over Mavericks’ fancy new apps, memory compression and Finder enhancements, perhaps one of the most revolutionary changes to go largely unnoticed is to the venerable (yes, it’s 20 years old, this year!) programming language AppleScript.
Apple have quietly introduced a new command to the AppleScript language called ‘use’. In effect, ‘use’ replicates the preprocessor ‘import’ directive familiar to Objective C users or the ‘include’ directive known to C programmers. This is likely to have a radical effect on how people learn and write AppleScripts.
Although ‘use’ seems primarily intended as a means to turbo-boost AppleScript by making available Objective C methods to scripters, it can also be used to import the scripting language of any app on your system. With that power, the whole concept (and limitations) of the ‘tell’ block are done away with. To see how this works in practice, take a look at this short script for toggling Bluetooth depending on your power source that I wrote pre-Mavericks, using tell statements and blocks:
Compare that with how we will do it now in 10.9 with the ‘use’ statement*:
Not a ‘tell’ in sight! Note the three ‘use’ declarations at the beginning of the script. The first one tells the script editor to include terms from System Events scripting dictionary. The second one does something similar with terms from System Preferences, but you’ll notice the syntax is slightly different. In the second declaration, I’ve taken advantage of the optional means to define a global text substitution for the expression “application System Preferences”. If you’re familiar with the #define directive in Objective C, or with using global properties in AppleScript of old, you’ll understand how this works. If you’re not, the short version is that we’ve declared a global variable of the sort which allows us to use the expression
SysPrefs wherever we would normally have used the string
application "System Preferences".
Don’t overlook the third ‘use’ statement in my example script above. Using ‘use’ effectively disables scripting additions (that includes all your familiar ‘display dialog’, ‘clipboard’, ‘path to’ and other essential expressions). In short, if you include any ‘use’ statements, be sure to also add the ‘use scripting additions’ statement, too.
There’s a lot more to using ‘use’ (you can read the full documentation here), but overall I think this is a positive change. However, if you’re fond of ‘tell’ don’t despair. At least for now, there’s no sign that ‘tell’ is being deprecated and you can carry on using it just as before.
*Note that there are other changes in the Mavericks version of the Bluetooth toggle script (in the ‘if…else’ blocks) due to the fact that Mavericks has changed the Bluetooth system prefs pane.
Got a new Mac and feeling like you’re on a whole different planet? Providing user manuals with computers isn’t really very Apple somehow 😉 …after all, the OS is supposed to be so intuitive and easy to use we shouldn’t need one…
However, clearly more than a few have been having problems getting used to their new Lion installation as Apple are now prominently displaying two beginners help guides on the ASC support forum.
Have a look at Mac 101 if you’re new to computers in general or haven’t really used one for a while.
If you’re pretty computer savvy but have just switched over from a lifetime of Windows to your first Mac, then Switch 101 will clue you into both some of the major differences and how to accomplish familiar Windows tasks in your new Mac OS X environment.
To keep up to date, troubleshoot, or find answers to specific questions not covered in the above materials, be sure to visit http://www.apple.com/support/lion/. You can also find this page from the menu at the top left of your screen. Click
> About This Mac and then ‘More Info…’:
Over on the right of the next panel, click the ‘Support’ button:
You can access both the online Lion manual (indicated in blue), and also a pdf manual (indicated in purple) for your computer from here.
Enjoy exploring! 🙂
Struggling with the basics? Don’t be shy, let us know in the Comments below! 🙂
featured picture The Close Light by *qaz2008
iPads are so easy to use, why bother with the manual? 😉 The chances are though, that at some point you’re either going to find that an app freezes on your screen or your whole tablet becomes unresponsive. Don’t panic, the answer’s simple:
First, be sure that it’s connected to a power source. The most common reason for iPads not working is people don’t realise they’re out of battery! Otherwise try these:
If it’s just a particular App that’s frozen on your screen:
— Hold down the ‘sleep/wake’ button (top right, back edge) for about 5 seconds until the slider appears. Release the ‘sleep/wake’ button. Now hold down the ‘Home’ button (bottom front, centre) until you see your Home screen.
If your whole machine is unresponsive, then do a restart:
— Hold down the ‘sleep/wake’ button for about 5 seconds until the slider appears. Slide it to ‘Off’. Then hold it down again until the Apple logo appears showing that the iPad is restarting.
If that doesn’t work, do a hard reset:
— Hold down the ‘sleep/wake’ button AND the ‘Home’ button simultaneously for about 10 seconds or until the Apple logo appears.
*For more serious problems with your iPad, such as continual restarting or no home screen, have a look here.
featured picture: ice crystals by Typen