When run, the intermediate code works through OS X to fire off AppleEvents (AEvents) to trigger the target applications to perform the actions. When you are ready to test your script, it compiles into intermediate code, and the editor automatically checks, formats and colours your source code, reporting any errors that it finds. Unlike the great majority of programming languages, punctuation marks are used sparsely in AppleScript, making it considerably easier to write code that works, rather than tripping over a missing semicolon. It first asks OS X whether it knows that Mail is running, and depending on the answer it executes the code that you insert where the comments (prefaced by ‘-‘ characters) are placed. You might use that code to set up a script that interacts with the Mail application. Set mailIsRunning to application process "Mail" exists This complexity arises because AppleScript is in fact an object-orientated language as sophisticated as Objective C, used by pro Mac developers do not be deceived by its apparently relaxed and informal style, with examples such as There are also events, notifications that something has occurred, such as a DVD being inserted, or a file being added to a folder. View a dictionary and you will see what at first appears very complex: long listings of data types (classes, which are instantiated into objects when they are used), such as application, window, file, and text, and methods (commands) that are applied to the objects of each class. Rather than having to locate additional documentation sets specific to each application, all a scripter needs do is open the dictionary. Those, and the suites of additional commands that bring joy to the scripter, are documented in standard formats within each application’s dictionary, which can be browsed by Script Editor and other tools. At their most complex, they can automate intricate and repetitive tasks that are messy in a GUI.Īs a minimum, every application supports a small core of commands to play clean with the Finder and OS X. At their simplest, these can open a document and print it, for instance. The concept behind AppleScript is simple: scripts that compile to a series of instructions for despatch by OS X to their destination application, which in turn is controlled by those commands to perform a co-ordinated sequence of functions. AppleScript is designed to give users and developers direct control over the applications on their Macs, and was quickly supported by professional products such as QuarkXPress, as well as Apple’s own rich software portfolio. The release of Apple’s System 7 Pro, version 7.1.1, in October 1993 brought a new programming language, based on the ‘natural’ English-like syntax of HyperTalk, HyperCard’s scripting language. Old, often neglected, and only available on Macs, AppleScript should have been overwhelmed by numerous other scripting languages – if it were not for its unique abilities.
0 Comments
Leave a Reply. |