Re: Loops
Re: Loops
- Subject: Re: Loops
- From: "Gary (Lists)" <email@hidden>
- Date: Fri, 01 Feb 2008 13:15:14 -0500
- Thread-topic: Loops
"Michael" wrote:
> So, is it as easy as checking for "Empty" to know if an action was not
> carried out? Let's say the command is to "Delete a file". Would the
> result be "File Deleted". Or let's say the command was to "Find a
> file"...Would you expect a "not found" to produce and error or simply
> return "Empty".
Well, 'Empty' and 'File Deleted' are not the kinds of terms one would
receive. I mean, those are not typical "terms" (errors, responses, etc.)
that one encounters in the AS language.
> I guess I am trying to get a feel for the syntax of AS.
I think that the best way to do that is to read other scripts, rather than
pick out some kind of "loop case" scenario and wonder what might happen,
what one might say, what results will be returned.
(For example, there is no "do"..."loop" syntax in AS, so you're already off
to a hobbled start.)
To examine other scripts, simply open the ones that came with your Mac.
Open your (or the computer's) 'Library/Scripts' folder and open some of
those scripts. (Make copies if you prefer, so you can leave the originals
in a pristine state.)
When I start working with folks who want to learn AppleScript, but know
nothing about it, I like to start off with some actual physical action that
they might perform, and then look at a script that does that action.
This way, I think, starts to give a sense of the primary "way" in which
AppleScript works ... By 'telling' applications/osax.
It's the very nature of the AS language to appear like a conversation (often
a one-sided conversation, with a script "telling" a bunch of stuff to some
other process.)
So, in order to just get a basic sense of the way that scripts are written,
look at some other scripts, particularly scripts for applications that you
think you will want to script. (But this is not required, and, as I said, I
don't even think that should come first, but second.)
Start with the Finder.
1. How do I make a script to create a new folder on my desktop?
2. How do I make a dialog box saying "Hello, World"?
3. How do I make a script to ask the user to select a file, then move that
file to the trash?
Once you do just those very basic kinds of things, you will have discovered
the "tell"/talk nature of AS syntax.
There are probably as many pedagogical styles to teaching/learning AS as
there are AS writers...but some basically sound pedagogical principles can
be inserted that will, I think, expose the new student to the underlying
paradigm -- the "way in which AS thinks" -- which can go a long way in
getting the student to the point where they can look at a brand new
application's scripting dictionary and write a basic script.
Others will offer their own approaches, but this may get you started without
the frustration of just grabbing some control structure (repeat loops) and
poking about.
--
Gary
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
References: | |
| >Re: Loops (From: Michael <email@hidden>) |