Re: Trouble Getting Into AppleScript
Re: Trouble Getting Into AppleScript
- Subject: Re: Trouble Getting Into AppleScript
- From: Daniel Todd Currie <email@hidden>
- Date: Mon, 1 Nov 2004 22:58:09 -0800
Ok, so I got the selection property working (sorta):
tell application "Address Book"
set oldSelectionList to selection
set newSelectionList to {person id
"D8B93B1D-49B2-11D8-B368-00306573E42C:ABPerson"}
set selection to newSelectionList
end tell
However I'm getting this error:
tell application "Address Book"
get selection
{person id "96BDA27C-7252-11D8-A085-00306573E42C:ABPerson"}
get person id "D8B93B1D-49B2-11D8-B368-00306573E42C:ABPerson"
person id "D8B93B1D-49B2-11D8-B368-00306573E42C:ABPerson"
set selection to {person id
"D8B93B1D-49B2-11D8-B368-00306573E42C:ABPerson"}
"Address Book got an error: NSUnknownKeyScriptError"
I've tried a million different variations on this... "set the
selection...", "set selection of application...", etc. Nothing seems
to make any difference. I have verified that the person id to which I
am trying to set the selection is in fact a valid id.
In one case, however, I have been able to get the script to complete
execution. When I have an empty group selected in the Address Book
application, the selection property is blank/null, so it somehow is
able to set the selection without popping an error. But it doesn't
actually change the selection value on screen. Perhaps it is allowing
this change of the selection property because it isn't in use?
Regardless, "get selection" still returns blank/null after setting the
selection in this way.
Is there something else to the language that I am missing?
Thanks,
-- DTC
On 2004 Nov 01, at 19:35, Christopher Nebel wrote:
On Oct 30, 2004, at 4:41 AM, Daniel Todd Currie wrote:
I'm having just a little trouble figuring out some basics in
AppleScript (pardon my undoubtedly droll questions).
I have a script like this, that works perfectly:
set abApp to application "Address Book"
set versionNumber to version of abApp
The event log reads:
tell application "Address Book"
get version
"3.1.2"
end tell
However, I go into the "Address Book.asdictionary" and look up some
application properties in the Address Book Script Suite, and
haphazardly choose "selection". My previous success means to me that
I should be able to do the following:
set abApp to application "Address Book"
set selectionList to selection of abApp
This generates an NSCannotCreateScriptCommandError, whatever that
means. What am I missing here?
A "tell" block targeting Address Book. The same word doesn't always
mean the same thing in AppleScript; the "tell" context matters. This
is, shall we say, less than ideal, but that's how it works. (The
complete answer has to do with how your script source gets translated
into Apple events, specifically, the internal codes used.)
On a side note, if there is a "selection" property, why isn't there a
"set selection" command? Perhaps I can set the value of the
selection property?
Got it in one. Properties may be "get" or "set", e.g., "set the
selection to ...". (Unless they're marked read-only, of course.
Version, for instance.)
--Chris Nebel
AppleScript Engineering
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
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