Main challenge is learning syntax

Dear friends:

My biggest challenge in learning Applescript seems to be learning correct syntax for each command. As I attempt to construct scripts and put in individual commands for each application, I find that I am continually getting error messages because my usage of the command or syntax surrounding the command is incorrect. Although many people say that Applescript is forgiving and very “English like”, I find in many cases that the opposite is true. No matter how many times I try to alter a command so that the syntax is correct, there always seems to be a problem.

It also seems to me that there must be a resource somewhere that actually illustrates by example, how to use each command in each application. I’m not referring to the abstract list of the commands but rather examples of how that command can actually be used in a real sentence. I’m aware that by studying existing scripts I can learn this to some extent, but looking through tons and tons of scripts in order to find just the right command that I’m attempting to use properly can be very time consuming.

I would very much appreciate recommendations from experience scripters on this list for resources that will help me learn proper usage and proper syntax of each command. I’m also very interested in making personal contact with some moderately skilled scripters where some verbal exchange or at least email exchange of scripting techniques can be made. I’m not averse to paying someone if necessary for some help in this area providing the person can help me get past the hurdle or obstacle that I presently have.

I have done programming before on a limited scale without too much difficulty. For example, during the OS 9 days I wrote some fairly extensive scripts in the language “one click” which some of you may remember. It was a “basic” oriented scripting language that had a very logical “algebraic” type structure. In that language the usage of each command was clearly specified with examples so it was very easy to see the correct usage and syntax to be used with each command.

Thank you so much for reading my message and I appreciate all the possible help that you may be able to provide.

Sincerely,
Howard

Greetings, Howard… and welcome to macscripter.

You will find that macscripter is a fabulous source for finding clear examples of how to use a wide variety of scripting commands. As you state, there is often a huge gap between what is listed in a dictionary and what the actual syntax for a command is. Unfortunately there is no “universal repository” of examples for “all apps”. One simple reason for this is that there are LOTS of apps, for which few people are willing to sit down and learn and then document. Apple does have some decent examples hidden around their website, but there is hardly a comprehensive resource listing all commands. Usually, people who develop third-party apps don’t even bother to tell the community that their apps are even scriptable, and that’s assuming they take the extra steps to provide scriptability. Poking around in the scripts that apple and other developers install with their apps, and in scripts you find in obvious places on the internet is a good starting point for solutions related to specific apps.

Basically, if you’re serious about getting into scripting, you’ve got a few options. First, get involved in this or a similar scripting community. While apple and a couple other sites host forums for scripters, people here are generally helpful, kind, and quite knowledgeable about scripting and other mac topics. Second, search first. Google is your friend. I often read peoples’ posts, turn around and search google for an answer, and quickly find MANY answers that solve the problem. While some people claim to search before they post, I’m often skeptical, because 1 minute searching this forum or google turns up so many results that they should be embarrassed to make that claim. 3) Make friends. As you suggest, it’s often quite beneficial to get in with some of the more experienced scripters, so you can ask them questions directly. I personally would be happy to field your questions here on the forum and privately. That’s assuming that you put in some effort first, that you follow the posting guidelines of this forum, and that you treat me and everyone else with respect. I hang out here to help people in your exact position, and I know there are many others who are here to do the same.

My best advice to you is to practice, pay lots of attention, and to learn to effectively search the interweb for answers to your questions. As I mentioned, there really is no place to get all of the answers, but macscripter is a good place to start, and you can reach out from there. If you put in some time, I guarantee that things will get easier and that finding solutions will get much easier and more intuitive.

Take care, and have fun…
j

I have found that the amount of on-line support varies widely between applications.

Quark, for example, has an excellent scripting implementation, a decent set of documents, and a pretty good scripting forum on their site. Not surprisingly, there are a lot of designers who script Quark, and are usually pretty free in sharing techniques (though less free in sharing scripts, which I have found often have to be tweaked for the particular version of Quark and System I’m on… not to mention issues of networks, etc.)

Microsoft and Adobe now have scriptable apps, but the source material is thinner, and I had to google to find any documentation at all for Microsoft Word (turned out to be a 500 page pdf, with a few decent examples, but no real breakdown of how the scripting structure needs to address objects.) I’ve dabbled in Adobe Illustrator and Photoshop, but my professional needs haven’t been such that I’ve spent much time working with them. (Not as many repetitious tasks that I need to script in those apps.)

One-click was a neat environment, but it had a few abilities that neither native AppleScript nor most applications support very easily (e.g., dealing with dialog boxes.)

Good luck with your search. If you are looking for information about specific applications, give a shout.
(It would be great if there was a page here of links for references on each application.)

George

As Jobu points out, searching is your answer. If you search on “Quark” in the AppleScript | OS X forum for example, you’ll get 14 pages of hits. Searching for “Quark style” reduces that to 9 pages addressing style sheets, etc.