Here is how to do it with Applescript:
tell application "Address Book" tell item 1 of (get the selection) to make new email with properties {label:"home", value:"email@hidden"} save addressbook end tell
And until you told me that, I would have had absolutely no idea.
Yes, a clear, well written appleScript snippet is very easy to understand.
The built in tools, like application dictionaries, are a big help too as are third party tools like Script Debugger's application explorer.
Still nothing is better than interactive learning with a more experienced scripter.
I wonder, is that the consensus here on the list? Does everyone agree that all the work put in to giving AppleScript an English- like syntax has failed to make it the most easily understood computer language?
Biased poll, given that there are plenty of folk on this list whose don't have any experience outside of AppleScript and are therefore hardly qualified to judge.
Who said anything about a poll? I was asking about the consensus on this list. And, if you're asking about statistical bias, people on this list probably have more experience with more languages than the general public.
What other language allows a novice to sit down with a script and understand exactly what's happening?
AppleScript certainly doesn't allow novices to "understand exactly what's happening".
Since you asked (and since you seem to dismiss all my concerns as some kind of syntax phobia):
Certainly not; I'm sure there are multiple reasons for your own hostility.
Have I been hostile? I don't think I've made personal comments about anyone or questioned their motives or their sanity or resorted to name calling. (I did suggest that some shell scripters have disdian appleScript and appleScripters, which may or may not be true but was not relevant to the discussion).
But you must agree that the alien-looking syntax of traditional languages like bash, Python, etc. scares off many non-programmers whereas the familiar-looking appearance of AppleScript does not - I know it did me when I started out.
OK, so we have found common ground, that's good, what does it mean. I believe that AppleScript can attract non-programmers and, with the proper supportive environment (which I hope this mailing list would be) they can enter the world of productive application scripting, and some may move on to programming.
When that happens it is a good thing. It happened to me and many others on this list.
Let's not pull the ladder up once we get on board.
Yet if someone like yourself can somehow manage to pick up one of those strange-looking languages, why not other folk?
If someone like me can do it, anyone can.
I think it borders on the patronising to say they shouldn't be exposed to it, as if they're not capable of understanding or asking for help to understand.
At the very least, when they come to the AppleScript list, they should get AppleScript solutions.
I think it's patronizing and counter productive to be told:
Rather than answer your question I'm going to tell you to learn Python or Perl or Automator or whatever other technology. I'm not saying there is no place for that at all on this list, but if someone is struggling with the language, at least help them get past whatever roadblock their facing is more important than promoting your pet technology.
It also ignores the benefits that other tools can provide users where AppleScript can't, and since you do have a bit of experience outside of AppleScript you must be aware that there are things that other languages do better than AppleScript.
If writing a solution in language A takes a dozen lines and writing it in language B takes just one,you need a better argument than "it requires a modicum of learning" to reject the second solution offhand.
It's got to be more than just keystrokes. I know in terminal you basically have to type each command from scratch and build as you go.
In AppleScript, once I've got a nifty handler I can use and reuse and repurpose and modify it to my heart's content. I've got scripts I wrote 10 years ago that are still working today, and handlers from my very first week with appleScript still show up in scripts.
If AppleScript wasn't such a grossly deficient language, you wouldn't get nearly as many folk resorting to shell scripting as a workaround to its inadequacies in the first place.
It's not the language that's deficient. They language is fine, robust. The problem is the lack of support, because it's an application scripting language it needs support from Apple and other developers. If you have a problem with this, do something about addressing those deficiencies yourself rather than complaining about other folks' solutions.
In the past I had a blog (justapplescript.manilla.com) and a web site (applescriptpro.com)
On the blog I had a comprehensive guide to appleScript training resources.
When macscripter.net started an appleScript blog, I stopped. Now they've stopped blogging.
Where "successfully" all too often means "driving themselves insane because they don't know enough to realise when they're doing things really badly". Been there, done that.
Again, I'm wondering if that's the consensus on this list? Is appleScript in such a sorry state that even being successful means driving yourself insane? Are we all doing things really badly because we don't know enough?
Also, while your solution works in situations where it's convenient and permitted to install third-party software on the end user's macs, that doesn't work for everyone.
Oh, and don't forget your solution simply failed to do what the OP asked for...
In my defense, the original poster posted a list of file segments and I wrote a simple script using his list that found them in a specific directory. It's only after an exchange with Mark did I realize that I the OP wanted to build the list from scratch.... ... was then followed by a bunch of hoop-jumping and make-work to fix that bug at further expense to simplicity and understanding.
So I added about four lines of script which solved the problem.
Don't confuse my sloppy list reading with a deficiency in the technology or language.
This is fine if the plain vanilla AppleScript answer is as simple as (or nearly as simple as) the alternatives. Otherwise it's just a self-indulgent make-work exercise or religious zealotry masquerading as "helpfulness".
How does isolating AppleScript and its community from the larger scripting world encourage it to thrive? Sounds more like a recipe for further ghettoization to me - as if AppleScript isn't ghettoized enough already.
I'm just curious, if I were to go on a python list or a perl list and constantly answer questions with "Here's how to do it in appleScript" and throw in a sales pitch for appleScript how would that go over?
Of course, this can be done with GUI AppleScript
Even though I loved Prefab's Player, and got it to do some very useful thing back in OS 9 days, it was still a patch for inadequate support. Many years later and I usually need to wash my hands in bleach after implementing a GUI solution in AppleScript. It's even uglier than it was with Player. We shouldn't have to do that for software that Apple ships. It's just another bit of evidence that they don't care about AppleScript.
In this case GUI scripting resolved the problem, without shell scripting, I might add.
disclaimer: the above is not intended to imply that Sal, or any other member of the AppleScript team doesn't care, it's just to say that from higher vantage point in the corporation they don't care, else they would never ship an application that didn't have "best in class" AppleScript support.
As I understand it, nearly all applications first ship without full AppleScript support (although the underpinnings are there), and the AppleScript team doesn't get their crack at it until after version 1 has closed. They don't want to delay shipping.
Maybe if there were more AppleScripters AppleScript would have a higher priority. Not to start anything, but I don't think it's really fair to say that these days. AppleScript has made great strides within Apple's application departments in recent releases, and I'm very optimistic about the future.
I'll second that, and also agree with Has,in that Apple is not entirely to blame.
The script editor is greatly improved, as has so many other smaller pieces of the technology.
Apple is has a lot on its development plate and AppleScript is on it, it's not the top priority, but they have incrementally improved parts of the technology with every release. Here's a good technical reason: AppleScript is good at application scripting and lousy at everything else.
HEllO NEWBIES, DON'T LISTEN TO THAT, APPLESCRIPT IS GOOD FOR MANY THINGS, AND GREAT AT APPLICATION SCRIPTING.
ES =
|