AppleScript - the Definitive Guide 140
AppleScript - the Definitive Guide | |
author | Matt Neuburg |
pages | 476 |
publisher | O'Reilly and Associates |
rating | 8 - Well written, good topic coverage, some flaws |
reviewer | Tony Williams |
ISBN | 0596005571 |
summary | Excellent guide |
AppleScript as a language and development environment has some terrible problems, and I applaud Neuburg for not trying to hide them away. Personally I love the power the language can provide, while loathing it for it's "English-like" syntax and the problems inherent in having most of the language defined in differing ways in different applications.
One of Applescript's problems is that it is difficult to teach, as you almost have to understand everything before you can know anything. Unfortunately that problem is reflected in this book. Neuburg constantly finds himself having to resort to the "believe me for now, I'll explain later" strategy throughout the book.
The book is broken up into four sections: "AppleScript Overview," "The AppleScript Language," "AppleScript In Action," and several appendices.
"AppleScript Overview" is a well written look at what AppleScript is, what it is good for and how to use it. Chapter 3, "The AppleScript Experience" is an impressive warts-and-all walk-through of the author developing an AppleScript to solve the problem of renaming files to conform to a particular standard using FrameMaker and the Finder. It is here that the reader will first see the problems inherent with AppleScript as Neuburg battles with incomprehensible dictionaries, unknown object models and uncommunicative error messages to build his script.
Part II, "The Applescript Language," is the 200-page core of this book. Neuburg provides a detailed and comprehensive look at every detail of AppleScript's syntax and semantics. The first chapter of this section, "Introducing AppleScript" contains a marvelous section entitled 'The "English-likeness" Monster' that is a short, sharp (and entirely justified) attack on the problem of AppleScript's attempt to be English-like in syntax.
In the rest of this section Neuburg provides an exceptional survey of the language. I personally appreciated his examination of the intricacies of type coercion and the exotic scoping rules. He has also taken the time to write and elaborate a large number of small pieces of code to demonstrate gotchas and tricks throughout the language.
It is this section that truly separates this book from every other AppleScript book I have previously read -- it is a masterful guide to the language.
Part III is a concrete path towards writing your own scripts. Neuburg starts by examining application dictionaries in depth. The real power of AppleScript lies not in the language itself but in the ability to use language extensions built in to other applications. This also becomes a huge flaw when the only documentation you get is in the application dictionary. As Neuburg puts it "One purpose of the dictionary is to show the human user how to speak AppleScript to a scriptable application in order to drive that application. But a dictionary, by its very nature, is not completely adequate to this task." He then goes on to explain the flaws.
The first appendix is a dump of the AppleScript Suite from AppleScript's 'aeut' resource. This is the core of the language usable everywhere. The second Appendix is a good, useful guide to tools and resources for the AppleScript programmer.
Taken as whole, this is a great book for the AppleScript programmer, both beginner and expert. It has a good writing style, has been well edited and well constructed. Neuburg may be putting in too many forward references, though. Other reviewers, particularly those newer to AppleScript, have called the book frustrating and confusing. I think this may be due to both the high information density in this book and Neuburg's fast introduction to topics that are better explained later in the book. If you are a newcomer to programming and AppleScript then this may be daunting.
If you are new, however, this is still an excellent volume but you may have to force yourself to finish it and then go over at least Part I and II again to truly understand the language. It would probably be a good idea to start trying to build your own scripts after the first read through. I must say, that after taking a good hard look at the way the book has been constructed and ordered I couldn't really come up with a better way that wouldn't have doubled the size of the book.
Visit the O'Reilly web page for the book if you would like to see the Table of Contents or grab an example chapter.
Neuburg has said "My approach is not to rely on documentation, ... but to bang away at the language itself, testing and experimenting, trying to deduce the underlying rules" and this approach has certainly borne fruit in this volume. For all it's minor flaws you cannot say, as may be true of many other tech books, that it is a rewrite of the documentation. He has approached the problem from a different direction and given us a book that offers an excellent guide to the language.
I would recommend it to all Macintosh owners as the perfect way to unleash another powerful aspect of your system. For people who have no AppleScript or programming experience who want to be totally spoon fed this book is probably only a 5, for people with a little AppleScript experience, a fair amount of programming experience and a willingness to stick through to the end this book is probably a 9. It is certainly the best book on AppleScript I have seen.
You can purchase AppleScript - the Definitive Guide from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
AppleScript could rock, if only... (Score:5, Insightful)
An AppleScript-recordable application lets you record your interaction with an application and play it back later. But it's more than just keystrokes and mouse-clicks. The events that make up your interaction are recorded at the semantic level, which makes them a whole lot more useful.
It also would address what everybody keeps saying is the chief shortcoming of AppleScript: it's terrible syntax. I agree it's pretty unwieldy in places, but the thing of it is, you shouldn't be writing scripts, you should be recording them! And once you've recorded a script, it's a pretty easy task to go in there and make simple changes if you need to.
The problem is compounded by people releasing software that claims to be recordable but really isn't. BBEdit is an example... they claim to be recordable, but they're not. All they let you do is screw around with window positions and basic UI crap like that. But do they let you actually record your interactions with the text within the document? No. And so people go buy BBEdit, see that the box says it's recordable, try it out and come away thinking that AppleScript sucks. It doesn't. It's BBEdit that sucks.
What's especially frustrating is that the purchase of Next should have helped remedy this situation. One of the reasons so few really good recordable applications are out there is because it's really hard to write a really good recordable application. You have to factor your code with AppleScript foremost in mind, so what was once a single function becomes four or five. And the API is a little convoluted. And you have to create and maintain an object hierarchy that may or may not correspond to the hierarchy of classes used in your code.
Cocoa/Objective-C could've gone a long way towards solving these problems. I detest Objective-C on other grounds, but I do appreciate that it would be a great boon in the creation of AppleScript-recordable applications. Alas, the guys from NeXT who seem to be running the show over there these days have taken a "not invented here" attitude to the language.
That's really too bad. Because you may all think the syntax is absurdly verbose and superficially English-like today, but just wait until we start talking to our computers as a matter of course. AppleScript would rule your desktop.
If I were running Apple, I'd make Python a first-class language, give it access to everything Cocoa and Carbon have access to, and put together a truly awesome AppleScript module that would let developers create AppleScript-recordable applications just as easily as you would, well, write a program in Python.
Sigh. If only.
Re:AppleScript could rock, if only... (Score:5, Informative)
Re:AppleScript could rock, if only... (Score:2)
Re:AppleScript could rock, if only... (Score:3, Interesting)
Damn good point; I was working for a couple weeks on an iTunes appleScript that would have been so much easier to figure out if the script recording could have generated some code for me to modify. Ahh well.
Re:AppleScript could rock, if only... (Score:1)
Re:AppleScript could rock, if only... (Score:2)
I hear such good things about it, and didn't myst get its start in that direction?
I always lament the way consumer PCs no longer come bundled with any easy to use programming language ala BASIC...kids who grew up in the 80s were truly privelged, before that computers were too expensive, afterwards they're closer and closer to being black boxes, programming wise... (on the other hand, we didn't have the web or easy Net access, but still)
Re:AppleScript could rock, if only... (Score:4, Informative)
Supercard [supercard.us]
It looks quite native for OSX and has a trial version you can download. If you miss Hypercard you may like it.
Re:AppleScript could rock, if only... (Score:1)
consumer PCs no longer come bundled with any easy to use programming language...
errr.... Windows comes bundeled with VisualBasic (well, at least Office and a load of other apps include a VB Runtime), and Linux comes "bundeled" with Perl, Python, whatever-you-like.
Sure, the VB-support in Windows is not up-in-your-face, and VB sucks, but it's there... It's just carefully hidden from the user. Now, if that is good or bad is quite arguable, i guess.
Re:AppleScript could rock, if only... (Score:2)
A. I don't see any way of making a form in my PC w/ Office
B. Office only sometimes comes bundled...old school BASIC was much closer to universal
Re:AppleScript could rock, if only... (Score:1)
I don't think you can blame the tools, though. Windows comes with built-in Javascript and VBScript support
Re:AppleScript could rock, if only... (Score:2)
I disagree. I watched newbies have a much harder time learning C at my school than pick up VB3 in the class I designed and taught.
Now here's what I think is closer to the truth: it's because programming for MODERN GAMES is fundamentally harder. (And it a bit more esoteric) I think making little games is what drove a lot of kids to mess around, combined with languages you didn't have to download...in fa
Re:AppleScript could rock, if only... (Score:2, Informative)
Assuming you have a current version of Windows, the C# compiler would be in c:\windows\microsoft.net\framework\[version]\csc. e xe or the analogous directory.
And my statement about C# wasn't intended as a dig on Java -- okay, maybe a little one -- it was to point out that any the user has serious power available if
Re:AppleScript could rock, if only... (Score:2)
Re:AppleScript could rock, if only... (Score:1)
Re:AppleScript could rock, if only... (Score:2)
The problem is that to be truly useful, you want *every* application to support whatever scripting language you end up using, since so much of the power comes from being able devise useful solutions by connecting different applications together.
And there is a good deal of support for AppleScript already. So much pain, misery and wailing went into providing even the limited functionality we see today... I don't think developers are going to embrace throwing all that work away.
Re:AppleScript could rock, if only... (Score:1)
Re:AppleScript could rock, if only... (Score:2, Insightful)
What I think I'm hearing is that apart from complaints about syntax and such, the true weakness of AppleScript is that the application writers have to go out of their way to support it, and they don't. After all, how many of their customers are clamoring for this as opposed to fixes of fi
Re:AppleScript could rock, if only... (Score:2)
The problem is that many developers don't want to learn more, and do more work, to support a capability that not too many people are asking for. So while many applications are scriptable,
Re:AppleScript could rock, if only... (Score:2)
You just described QuicKeys. It does things at a semantic level. It records your actions and then creates a script that has things like "click the button marked 'OK'" and "select the menu iten labeled 'Options...'"
Then it lets you do things like run this script whenever I hit Ctl-F4, or run this script every 30 minutes, or run this sc
Re:AppleScript could rock, if only... (Score:3, Interesting)
BTW - I think you misunderstand what the author meant by "semantic level."
Re:AppleScript could rock, if only... (Score:2)
That's not at a semantic level like the grandparent is talking about, that's a GUI level. That action at a semantic level would read more like "Open the options window" - describing really what you're trying to do, not *how* go about doing it.
The menu item you click on is irrelevant, what's important is that you want to get at the options window. And that's something that can really only be implemented application-level, not by a third-party program peeking into w
Re:AppleScript could rock, if only... (Score:2)
Re:AppleScript could rock, if only... (Score:1, Informative)
In my mind, the m
Recording AppleScripts... Nah. (Score:2)
It would be great if more applications were recordable, but back when I used Applescript every day to make a living, recorability was so unimportant I even forgot it existed.
Most scripts created through simple recording means are trivial, which doesn't make them worthless, but you know where I'm going with this.
Re:AppleScript could rock, if only... (Score:2)
Winton
Re:AppleScript could rock, if only... (Score:2)
Re:AppleScript could rock, if only... (Score:4, Interesting)
I really like the AppleScript system in the Mac OS. I have always found that most apps support AS scripting decently. However, I have no idea if support for recording is lacking in some apps- I only record a macro *very* rarely.
What I like about the OSA- Open Scripting Archtecture, of which AppleScript is the default language- is the ability is using it to call into apps that otherwise are isolated from my program. I like to be able to eval a line of AppleScript and get a string with the returned value; or, in Perl, Ruby, Tcl, JavaScript and others, I can call into those commands directly.
See, AppleScript is but one language in the OSA. Any language can hook into it, giving it AppleScript's powers, without the need to ever touch AppleScript. I love the OSA and what AppleScript provides, but the language itself is not my style.
Why should I be recording my scripts? A lot of what I do with AppleScript isn't neccesarily accessible with a straight-forward button or other GUI action. Which is why I access the Apple event directly.
A Python-Objective C bridge has been around since OpenStep days.
If you think AppleScript/OSA lack supporting-apps, it's good you don't use Windows with the WSH.
Re:AppleScript could rock, if only... (Score:2)
Possibly because so few applications thoroughly support recordability? So the first time you try, you see it isn't there, and the next time, and so on, until finally you just give up and code it manually.
I would also suggest that AppleScript should be usable by non-programmer types. Maybe *you* don't need to use it, but others could get a lot of mileage from it.
Why should I be recording my sc
Re:AppleScript could rock, if only... (Score:4, Interesting)
Nope. The reason I only rarely record my AppleScript is that I often can't record what I want to do. And not because the poor support you claim, rather because there often isn't a way to do it in the GUI. It's the wrong style, at least for what I'm usually trying to do.
For instance, one way I have used AppleScript is to make a little window/app switcher for Squeak Smalltalk, a language that doesn't use the Carbon or Cocoa APIs in its GUI, other than to use as a fancy framebuffer. Squeak has its own windowing system. Anywho, I want to be able to switch to the "real" Mac apps I have running, so I wrote a ditty that brings up a menu with the apps running in Squeak and in Mac OS, and when selected switches to it. The AppleScript used involves asking the Finder what apps are running, and what windows are a part of those apps, information about apps and windows, switching to them, etc etc. Those actions are not the sort of thing I really could record, nor would I want to. This example is pretty representative of what I do with AppleScript. I call out to AppleScript and get a return value, which I may or may not parse and use in my program.
But let's say I just had a task I wanted to be done over and over again. I may record parts of it, and then edit the code, put it in the loop, etc etc. I have never had a problem with doing things this way- no matter if the OSA has any idea about the semantics of what I'm doing. I don't care that it knows what I am doing in the end, just as long as it does it for me.
It isn't accessible because the application has poor support for recording. Ideally, *everything* that you do with an application would be recordable.
Sounds like a fine dream, but not one that makes a whole lot of sense for some actions. Using my example, how do you think AppleScript or the app should support those kinds of things? Have some far more elaborate system of visual programming? Or just have all of those more programmatic actions be in a list that I can get in a menu? If so, why not just use the Dictionary?
Yeah, but I was talking about first-class support, with tools that are installed with the OS and/or developer tools CD, and with docs that are aimed at Python coders, and so I can release a distributable and not make a half-million Mac users try to figure out how to install Python and PyObjC and so forth.
I haven't used 10.3 that much, but in 10.2 you got Perl, Python and Ruby installed by default. What's so hard about having your users install a framework first, and then double-clicking your app? After all, this is OS X, not Linux or Windows. One should be able to drag PyObjC.framework to the frameworks folder, either the local user's frameworks folder or the system-wide one. Or, you could put it in your app's bundle, then they wouldn't have to ever see it. You don't even need to use an installer script.
Everyone wishes their favorite pet language had full first-class support in their favorite OS. There really isn't an answer to this. The other guy wants perl. Other folks want Ruby. I wish Smalltalk runtimes shipped at OS X's core. I mean, Objective-C is just C plus Smalltalk- a natural fit! If that's what you want, do it; OS X opens up a lot of ways to give your users what they want and do it easily.
Re:AppleScript could rock, if only... (Score:2)
You never really had the opportunity to use it in the first place, so how can you credibly claim it to be an option you've rejected?
For instance, one way I have used AppleScript is to make a little window/app switcher for Squeak Smalltalk...
That's one example only, and a fairly bizarre one at that. I didn't say that there weren't uses that precluded recordability, and I'm not sure I would describe you as bei
Re:AppleScript could rock, if only... (Score:3, Interesting)
Read the post, man. I said I rarely use the recording funcitonality, usually doing things programatically. I have made recorded AppleScripts- usually to do repetitive interaction with a few apps so I don't have to, often moving data between them. I didn't say that I rejected this method, nor did I say that I have never used it.
Any "position" I have regarding this is based
Re:AppleScript could rock, if only... (Score:2)
If you had done me the same favor at the outset, we could have saved ourselves both a bit of time.
but unlike you, I am not saying that everyone should do things my way or that I have discovered the one true way to do things.
I never said this either, except in the most general sense.
how do you propose to replace programatic use of AppleScript in the ways I've described?
I'm not interested in your uses. Again, if you could actually bother yourself to read what I am writing here, y
Re:AppleScript could rock, if only... (Score:2, Funny)
Re:AppleScript could rock, if only... (Score:1)
Re:BBedit IS recordable (Score:3, Informative)
I'm talking about actually treating the text of a document as an AppleScript object. You should be able to do things like
and so forth.
In other words, BBEdit doesn't support the Text Suite, one of the standard (and first) suites of AppleScript commands published back in the 80's.
To not support even this basic level of functionality and then call yourself recordable is really misleading.
Re:BBedit IS recordable (Score:1)
Re:BBedit IS recordable (Score:3, Informative)
I just run the following AppleScript:
It worked.
JPRe:BBedit IS recordable (Score:2)
But thanks for playing anyways.
Re:BBedit IS recordable (Score:1)
As the developer of BBEdit, how would you record this? There are a dozen different ways that BBEdit could interpret a user highlighting a word. Yes, the user might mean he wants word 1 of line 43, but he might want to highlight the word "However" when it appeared at the beginning of a line. Or he may want the first word of the 5th displayed sentence. Or all words starting with a capital "H". Or words containing the string "wev". Or the 150th word of the document.
And if BBEdit dared get the script wro
Re:That's right, blame NeXT (Score:1, Informative)
The low-level event recording mechanism was called NSJournaler [channelu.com]. It's no longer part of Cocoa (it relied on the display postscript server, which Cocoa doesn't have).
Examples of macro languages and applications which used NXJournaler:
You might also be interested in TickleServices [doubleu.com], which was an early example of macro languages applied to a GUI. TickleServices worked via the Services menu in all
Great.... (Score:3, Funny)
Re:Great.... (Score:3, Funny)
AppleScript may or may not be an English-like language for, perhaps, scripting applications on computers alleged to be Apple Macintoshes. This book might or might not have something to do with that
A wonderful book but... (Score:5, Interesting)
Is there a case for Applescript to answer?
I am not trying to start and argument, and I do not think OS evolution will irradicate a language, maybe just reduce it's use. After all a system (Mac) dependent language is not a useful as multiplatform code.
In fact.. (Score:5, Informative)
"UNIX foundation
With its Open Source, UNIX-based foundation, Mac OS X Panther lets you script with your choice of languages: Perl, PHP, Python, Rexx, Scheme, Tcl and more. You can work with built-in development tools such as gcc, gdb, vi, emacs and pico and take advantage of UNIX shell tools such as grep, chmod, ps, crontab, top and tail. If you?ve written utility software on another UNIX platform, you can quickly get it running in Mac OS X Panther.
In addition to leveraging the gamut of UNIX tools, you can easily extend the power of your software by using QuickTime?s complete multimedia architecture, including support for Flash 4, Cubic VR, RTP/RTSP video streaming, MPEG and a wide array of graphic file formats. New in Panther, you can script the Mac OS X graphics architecture, Quartz, with python."
Re:In fact.. (Score:3, Informative)
Granted, these same tasks could probably be accomplished by a shell script if the appropriate flags were put into the Apple applications to allow full command line operation of them. Since it is unlikely that Apple and all Apple developers are going to replace their appleScript libraries with shell flags in the near future, Applescript will fill that void in t
Um... No. (Score:2)
Applescript talks with applications via OSA, the Open Scripting Architecture. You can just add OSA compliance to any language you like, and you get all the same scripting access as Applescript. People have allready done this for mac versions of Perl, javascript Tcl/tk, Python, etc...
Re:In fact.. (Score:4, Interesting)
See, you're missing the point. Despite the name, Apple doesn't really consider AppleScript to be a Scripting Language, per se. They consider it to be a root language. Check out the AppleScript Developer Page [apple.com]. To quote, "A peer to the Aqua GUI, AppleScript is the language interface for Mac OS X." There's even a handy little chart that shows AppleScript and Aqua at the top, with Cocoa, Java, Carbon, and Classic underneath, etc.
To Apple, AppleScript is no longer a scripting language so much as it is the underpinnings of the Operating System. It's a different way to communicate with Applications, rather than just through the Aqua interface.
=Brian
Re:In fact.. (Score:1)
Re:In fact.. (Score:2, Informative)
That's because AppleScript is not a Unix utility. As someone else explained, it's a language for controlling applications, including shell scripts, not a part of the "Unix foundation."
AppleScript, as well as any books discussing the topic, is nowhere near irrelevant. For example, I use Retrospect to backup my various machines. Retrospect cannot be scripted except wit
Re:A wonderful book but... (Score:1)
Re:A wonderful book but... (Score:4, Insightful)
Applescript's power is in its ability to control other, already running applications. Hell, to do this under Linux, the program needs to support it in some strange manner (ala MPlayer's "slave mode," which requires a wrapper written in another language (like Perl))
And now with GUI scripting, Applescript is incredibly useful for a huge number of things, enabling you to script literally everything on your computer.
It's a shame that Apple crippled this ability with an awkward interface (odd, since interfaces are usually what they're known for), but you take what you can get. I, for one, am looking forward to reading this book because it's damn hard to find good AS resources online.
thaen
AppleScript provides a good frontend to sh (Score:2, Informative)
I can do this in the terminal using tr, (tr '\r' '\n' unixfile), but the staff who prepare the files are not terminal savey. They just need something simple they can use to do this translation on .csv files before uploading to a remote PeopleSoft server.
An AppleScript droplet that calls the shell commands "magically" when the file is dr
Re:A wonderful book but... (Score:1)
Apple Events are what drive most programs on the Mac. Button presses, Key Downs, 'New Document', etc. are all expressed in terms of Apple Events, or some more language-specific term (NSEvent in Cocoa) that maps cleanly to Apple Events.
AppleScript is basically a way to target and send these events. You tell an application to open a new do
Re:A wonderful book but... (Score:2)
I'm not trying to sound critical, but your argument demonstrates that you really don't know what AppleScript is. Although both AppleScript and Unix scripting languages can both be used to automate repetitive tasks, they're not really in the same ballpark. Sure, you could do some data processing in AppleScript, but the whole point of AppleScript is not so much to be a scripting language as it is to provide an API for sending and receiving Apple Events -- a special kind of interprocess communication on MacO
Even as a Linux weenie... (Score:2, Interesting)
Re:Even as a Linux weenie... (Score:5, Informative)
Bingo. AppleScript is a language for executing/controlling other programs. It can do some things on its own, but it's power is in controlling others. It's the shell script for when you don't have a shell.
If you just want to get a look at the language I'd say start with the scripts included with OS X. They're free, and you already have them. (If you can use AppleScript at all.) Apple's site has some fairly good basic docs too.
Re:Even as a Linux weenie... (Score:1, Interesting)
Why do people insist on inventing their own scripting languages instead of picking one of the handful of fine existing languages? Imagine if Apple were to have picked Tcl or Ruby or Python and given it the power of AppleScript, rather than inventing their own "user friendly" scripting languag
Re:Even as a Linux weenie... (Score:2, Informative)
The first time I saw Tcl was in the Alpha editor under MacOS 7, so it was available there. Wether or not Tcl would have been a good choice for a system-wide scripting language is another arguement.
Note
Re:Even as a Linux weenie... (Score:1)
Re:Even as a Linux weenie... (Score:2)
Not true... A/UX was running on the Mac II series before AppleScript was released.
Re:Even as a Linux weenie... (Score:2)
Why do people insist on inventing their own scripting languages instead of picking one of the handful of fine existing languages?
Actually, AppleScript's roots harken back to HyperTalk [c2.com], the inner scripting language of HyperCard. (With minor changes, such as "it" now being called "(the) result"). [apple.com]
They wanted to make "system interaction and direction" as easy as making usable stacks was in HyperCard. With AppleScript Studio, it seems like they've finally succeeded.
I wish they'd do something with HyperCa [wired.com]
Re:Even as a Linux weenie... (Score:3, Insightful)
There isn't a syntactic similarity between Tcl and Applescript, but there are some deeper similarities. In Tcl and the Tk Toolkit [aw-bc.com] John Ousterhout describes Hypercard as an inspiration for Tk for an easy to use to to create graphical applications.
The design of Tcl command extensions is also very similar to the classes and events that an application exposes to Applescript. Tcl statements are in the form "command arg ...". When you extend Tcl, you take libraries, maybe even existing libraries, and add them
Re:Even as a Linux weenie... (Score:1)
AppleScript (and JavaScript as well, maybe) is more of an external scripting language. It can be used within a single app, but generally AppleScripts run outside of any app.
Re:Even as a Linux weenie... (Score:5, Informative)
Re:Even as a Linux weenie... (Score:2)
Actually let me take that back somewhat. DCOP attempts to do something like Applescript or VBA. It only works with KDE but I believe it has limited support. Basically it lets you automate any KDE application. However few apps really provide much
Re:Even as a Linux weenie... (Score:2)
AppleScript is based on AppleEvents. AppleEvents are messages that applications can send to eachother. These messages appear in the event loop of the receiving application, just like mouse click events and window resize events. There are a number of predefined AppleEvents, such a
Re:Even as a Linux weenie... (Score:1)
Compared to applescript, Perl and Python and all the shell scripting languages are virtually the same. Yeah, don't think of "scripting" in the Unix sense: you have a text file that's sortoff a list of shell command lines...
Step 1: forget about the command line. Forget about stdin/stdout/stde
Neuberg (Score:3, Interesting)
Back-handed compliment (Score:2, Funny)
I don't think Mr. Neuberg will be requiring your services as a press agent any time soon.
Re:Back-handed compliment (Score:1)
More to the point, he is capable of tranferring an enormous amount of knowledge within a limited amount of space.
I have a lot of books on Safari, but this is one of those I want on my desk..
-zvoid
Re:Back-handed compliment (Score:1)
Okay, and now for me to be fair: one, my comment was a bit of a joke (glad to see you have a sense of humor); and two, the great thing about my comprehension and memory is that if I put a book down for a week, when I pick it back up it's like getting a new book for free ;-)
Not just for scripts anymore (Score:5, Informative)
While this is still true, AppleScript has evolved into something much more useful: small application and application prototyping.
There was a tool, FaceSpawn, that started it it all. Just like Visual Basic on Windows (and now, RealBasic on Mac), it allowed the creation of complete applications, UI and all, with AppleScript as a back-end.
Apple leveraged this idea with AppleScript Studio, wich is now rolled into XCode.
Basically, you use Interface Builder to create your UI, with the same widgets and capabilities a Cocoa would (and unlike Carbon-based Interface Builder NIB files).
Basically, XCode allows you to create complete AppleScript applications that are actually hosted by a Cocoa application. Therefore allowing you to mesh both languages (and runtime environment) into a single executable. Similarly, this also allows regular Cocoa applications to have AppleScripts embedded in their UI.
Easy and powerful scripting and application programming for the masses.
And if this isn't enough for your typical Unix geek, just pipe your AppleScripts to the BSD command line with scripts like and voila.
Re:Not just for scripts anymore (Score:2, Informative)
FaceSpan was the tool to which you're referring. And you're right
Re:Not just for scripts anymore (Score:3, Interesting)
And if this isn't enough for your typical Unix geek, just pipe your AppleScripts to the BSD command line with scripts like do shell script "ps -auxwww" and voila.
That is a nice feature - I hadn't played around with Applescript before this week, but in an evening I was able to create a small GUI for checking, starting and stopping a MySQL server, and I could see a lot of scope for easily adding functionality to it. Not revolutionary, but it works and saves me a little time - and more importantly, demons
Agonistic programming (Score:5, Informative)
Re:Agonistic programming (Score:2, Funny)
Not to flame, but "Wow!"
Re:Agonistic programming (Score:1)
Umm, I really hope that's a formatting error and you weren't suggesting that people use Excel and FilemakerPro to do AI in games!!!
:)
Applescript Problems (Score:2)
There is, of course, an alternative. Do "Applescripts" in Python or Perl. They are very p
Re:Applescript Problems (Score:5, Interesting)
Apple had a Japanese dialect and a C-like dialect built during the development phase. These were never tested enough to release, primarily because of a management decision to shift a lot of the team over to work on OpenDoc after AppleScript's first release.
However, that said, it can be terribly frustrating to figure out the syntax of the current system. This is because a number of language extensions have been built through a mechanism known as OSAX extensions, over the years. The language elements which come from applications work pretty well, because there's a block structure which wraps them into easily detectable blocks. OSAXen, though, tend to interact globally with the syntax of everything, and a lot of the OSAXen have really gnarly syntax that causes all sorts of unforeseen interactions. Unfortunately, the core language was missing some important features, and OSAXen were the easy way to add some of that back, so it got completely out of hand rather early on.
The original team never imagined that the current syntax would be the only one. Quite the contrary, we viewed it as a syntax that HyperCard users would find familiar, but many other folks would find rather verbose.
StepTalk (Score:3, Interesting)
StepTalk [agentfarms.net] is a scripting environment for GNUstep applications (this is why I remembered to mention it: AppleScript -> OSX -> NeXTSTEP -> GNUstep -> Scripting -> AppleScript...). The level of integration with GNUstep apps and the possibilities are enormous, and since Objective-C OO paradigm was based in SmallTalk it feels very natural.
Now that GNUstep is having more and more applications be sure to give StepTalk a look.
cheers
AppleScript open to any scripting language (Score:5, Informative)
Apple offers their "Open Scripting Architecture", code away in whatever you're most comfortable in and take advantage of those AppleScript hooks. Perl, TCL, Phython, JavaScript, whatever, all can manipulate the applications using their built-in AppleScript support
Thus this book isn't just for hardcore Mac folks, it's also for anyone who uses Macs and would like to write scripts that interact with Adobe Photoshop and MS Excel and and, well, pretty much anything else "Mac".
From Unix.
Pretty powerful, eh?
Now it's widely interesting!
Matt Neuberg (Score:4, Informative)
Anyways, his book on REAL Basic was definitely good. He takes a philosophical approach to things (As he has an advanced degree in philosophy) and has a conversation like approach. For a more experienced programmer it may seem like more reading than necessary but for a novice or someone willing to take the time to read about the insights of the language they are attempting to learn, he makes it worth the effort.
His book provided many examples as well which I think most experienced and novice programmers generally appreciate.
Another good thing about Matt is he posts often to Newsgroups so if you have a particular question regarding his book(s) you will almost always get an answer from him. It's nice when an author is accessible as it gives the feel of a teacher.
Haven't played much with Apple Script myself though. I have done enough though where I think Matt Neubergs writing style would fit the audience that would want a book for this.
Favorite quote from the book (Score:2, Funny)
Applescript to Dial Phone from Entourage Contact (Score:2, Informative)
Get the power without the "Englih-like" syntax (Score:1)
http://www.latenightsw.com/freeware/JavaScriptO
Simple Applescript stopped working after OS update (Score:1)
I also tried to the "create a network" by script but it seems there are no comands for doing that. Millions of things I could tell "Internet connect" application but not simple things like that. Probably I would have to use the beta gui enhancement for Applescript. No thanks, this gui thing is so slow I rather use the trackpad. I gave up on Applescript.
Implementation vs. specification (Score:2)
This sounds reassuring, but is not the correct way to approach a programming language or a program. Such things are defined by specifications, not implementations. (If they're not, avoid them.) Besides the fact that implementations are frequently buggy, a particular implementa
Re:Pfft. Applescript? Who needs applescript. (Score:3, Funny)
cat
Enjoy!
You like? Want some more? (Score:2)
cat "say `cat
Now we just need a line to insert before that one that cranks the volume up to max.