• 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
Re: [cocoa scripting] getting script class attribute name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cocoa scripting] getting script class attribute name


  • Subject: Re: [cocoa scripting] getting script class attribute name
  • From: Bill Cheeseman <email@hidden>
  • Date: Mon, 05 Sep 2005 17:46:32 -0400

on 2005-09-05 1:44 PM, Ken Victor at email@hidden wrote:

> given that i have the key and apple event code for an attribute of a
> class, is it possible to get the name of the attribute? ie, the name
> the user would use in a script?
>
> i want the name in order to be able to provide better error messages
> and i'd prefer to get this at runtime rather than having to build
> constants into my app.

I ran into this same issue recently and concluded that you must code the
AppleScript names into your app. You could probably avoid this if you were
willing to parse your sdef file via XML. I decided it was easier to code the
names.

I would be delighted if Apple or somebody would write a Cocoa class to get
the terminology out of an sdef file for use in error messages and the like.
I'm just not willing to get into parsing XML myself right now. I had hoped
that the various AppleScript "description" classes would fill this need.
However, as the documentation notes, the names provided in the "description"
classes are sometimes technical code names, such as "orderedWindows", not
the names a scripter would use in a script.

This issue doesn't come up only when writing custom error messages. It also
comes up when writing undo action names, if you choose to generate detailed
undo action names for each statement in a script (which is undoubtedly
overkill, but I've done it).

There is one other area where I had to hard-code names for error messages:
the singular and plural forms of classes. I can't find any way to access the
plural.

So, in my AppleScript error-generating routines, I have ended up passing a
dictionary with three keys: "command name", "singular object name" and
"plural object name". I assume that localization is not required, since
AppleScript is an English-only scripting language at this point.

--

Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com

PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes


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

This email sent to email@hidden

  • Follow-Ups:
    • Re: [cocoa scripting] getting script class attribute name
      • From: Dustin Voss <email@hidden>
References: 
 >[cocoa scripting] getting script class attribute name (From: Ken Victor <email@hidden>)

  • Prev by Date: Re: NSArrayController / NSTableView questions
  • Next by Date: Re: [cocoa scripting] default sub container
  • Previous by thread: [cocoa scripting] getting script class attribute name
  • Next by thread: Re: [cocoa scripting] getting script class attribute name
  • Index(es):
    • Date
    • Thread