• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Scripting stylistic question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scripting stylistic question


  • Subject: Scripting stylistic question
  • From: "Grimm, Kenneth" <email@hidden>
  • Date: Tue, 5 Apr 2005 10:08:12 -0400

Good morning:

I've been wondering if there is a style guide or something similar to
consult when writing AppleScript to help in making scripts more readable.

Here is a relevant example of the point I'm hopefully trying to make. I work
at a newspaper and thus deal with programs that address advertisments.

This is an example what I write now:

set countOfAds to count ads

repeat with thisAd from 1 to countOfAds
   set adnumber of ad thisAd to (characters 2 thru -1 of adnumber of ad
thisAd) as string
end repeat

The "problem" as I see it is divining a good name for "ad thisAd." The
programmer may address ads (or any number of items) using the form "ad
[integer]" and I'm have difficulty choosing good variable names for the
[integer] part that doesn't sound redundant when read aloud. I'd like to be
able to read my scripts aloud and it "sound proper" to a listener who
wouldn't know it was a programming language I was reading. If I can achieve
this, then I think I've done my part in helping make the script
"English-like."

Another goal is to make the script understandable to a non-programmer that
may come after me and have to do maintenance on the script. With the
shrinking resources of newspapers, this is a very real senario.

I hope that makes sense. Any suggestions?

Ken

As an aside:
I've read and tried to wrap my head around labled parameters, but as of yet
can't make that work consistently -- it seems a most elegant way of
expressing the purpose of the code. The examples I've seen are a good
example of what I'm trying to accomplish. Once written they are so elegant
and seemingly simple, it is getting the syntax to that elegant and simple
stage that is a wooly booger.

What I think would help me there is to see *side-by-side* examples of
positional parameters and labeled parameters to let me dissect and practice
with, but so far those *side-by-side* examples are few and far between. Do
many of those exist?

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Scripting stylistic question
      • From: Adam Wuellner <email@hidden>
  • Prev by Date: Re: Folder Actions Dictionary
  • Next by Date: Re: Folder Actions Dictionary
  • Previous by thread: Re: Folder Actions Dictionary
  • Next by thread: Re: Scripting stylistic question
  • Index(es):
    • Date
    • Thread