Re: Propriety, class, and XL confusion
Re: Propriety, class, and XL confusion
- Subject: Re: Propriety, class, and XL confusion
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 29 Dec 2002 20:39:09 -0800
On 12/29/02 8:00 PM, "Nelson Byrne" <email@hidden> wrote:
>
Apparently Elements can be Properties as well as Classes.
Correct. Elements _of the application_ are classes within the application.
AppleScript is quite object-oriented. By convention, 'application' - which
is an AppleScript term, appears in the Standard Suite, but some applications
like to put all their own defined elements in a separate listing of
'Application' in one of their own suites (leaving just the Standard events
such as get, set, count etc. and usually just window and document in the
Standard Suite.) It should really all be up there in one entry for
application in Standard Suite, but many applications - including all of the
new Apple Cocoa apps, split them too. In Excel's case, its AppleScript
events and classes plug into the VBA equivalents (which makes the scripting
not as object-oriented as it might be, since there are so many events
corresponding to VBA Methods, but fast and efficient).
Even in orthodox apps with just one entry for 'application' in the Standard
Suite, all the elements listed there are then found as Classes within the
proprietary suites. AppleScript defines the terms 'class', 'event' ,
'element' and 'property'. 'class' is like a noun, 'event' is like a verb.
Elements of classes are always classes themselves with their own
definitions, since they can be made within the object of which they form
elements. Properties can be anything: they may also be (single) instances of
some proprietary (application) class, or they might be a constant, or an
AppleScript object such as a string, list, record, or a constant. Or a type
(another applescript class). Or just about anything.
You should read up on the language's structure in the AppleScript Language
Guide available free in PDF at the Apple AppleScript webpage.
>
>
Oddly enough, Border is itself a Class.
Not at all odd.
>
>
Apparently
>
Classes can themselves be either Classes or Properties.
>
Properties can themselves be either Classes or Properties.
It's not so circular. Classes of course, are classes. Individual properties
of particular classes may be themselves classes (of Excel) or constants, or
AppleScript types, etc.
>
>
Be that as it may, Class Border (also in Charting Suite) has a Property
>
ColorIndex xlNone/xlAutomatic
xlNone and xlAutomatic are constants defined by the application (Excel).
>
>
I can find neither xlNone nor xlAutomatic defined anywhere in Microsoft
>
Excel.asdictionary so I guess these are primitives.
The Excel Dictionary is singularly uncommunicative, and no one has ever
documented it properly. I recommend that you go to Tools/Macros/Visual Basic
Editor/Help/Search, and look around for something with the same or similar
name (Border). You'll find that the Border Object has a ColorIndex
Property:
Returns or sets the color of the border, font, or interior, as shown in the
following table. The color is specified as an index value into the current
color palette, or as one of the following XlColorIndex constants:
xlColorIndexAutomatic or xlColorIndexNone. Read/write Variant.
Object ColorIndex
Border The color of the border.
Borders The color of all four borders. Returns Null if all four borders
aren't the same color.
Font The color of the font. Specify xlColorIndexAutomatic to use the
automatic color.
Interior The color of the interior fill. Set this property to
xlColorIndexNone to specify that you don't want an interior fill. Set this
property to xlColorIndexAutomatic to specify the automatic fill (for drawing
objects).
It's formatted much more nicely there, with further links to examples.
>
>
What's an element -- a class or a property?
>
What's a property --a class or a property?
>
And by the way, which events are handled by members of the above?
>
>
============================================
>
>
>
Even not knowing that I still can't understand the behavior of this
>
script:
>
>
tell application "Microsoft Excel"
>
tell Chart 1
>
get ColorIndex of Border of Series 1
>
tell Series 1
>
get ColorIndex of Border
>
end tell
>
end tell
>
end tell
>
>
The first get results in xlNone, as expected and correct.
>
>
The second one results in an error: "Can't get ColorIndex of Border."
You may not be specifying the border clearly enough. Whenever a property has
the same name as a class, and sometimes in other situations, you need to
articulate it. When you use the 'tell' syntax, it often helps to:
tell Series 1
get ColorIndex of its Border
end tell
That tells AppleScript that you want the Border of Series 1, not the class
(application element) Border.
Does it help here? (I haven't tested.)
>
>
Why can I get a whatsit of a border of a series
>
and yet not tell a series to get me a whatsit of a border?
Try 'its'.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.