Re: What the heck is an AppleScript vector?
Re: What the heck is an AppleScript vector?
- Subject: Re: What the heck is an AppleScript vector?
- From: "Nigel Garvey" <email@hidden>
- Date: Wed, 2 Aug 2017 20:30:58 +0100
Rob Lewis wrote on Wed, 2 Aug 2017 08:38:50 -0700:
>Poking around in Evernote's scripting dictionary, I tried this:
>
> set my_note to item 1 of (get selection) --select a single note
> set tag_list to tags of my_note --returns list of note's tags: {tag
>"tagName" of application "Evernote", etc.}
> set tag_list to tag_list & tag "abo" --can't make into type vector
>
>The last line produces this error message:
>"Can’t make «class EVtg» \"abo\" of application \"Evernote\" into type
>vector." number -1700 from «class EVtg» "abo" to vector
>
>vector? Can't find anything online about AppleScript vectors. What's
going
>on here? tag_list seems to be a plain vanilla list.
A vector is the kind of list with braces. There's another kind called a
linked list which has square brackets and isn't supposed to be used.
When you concatenate something which isn't a list to a list, that
something is first coerced to a list (usually a list containing just
that thing) and it's the two lists which are then concatenated to
produce a third list containing all the items. It looks as if Evernote's
'tag' class doesn't cooperate with being coerced to list. The same thing
happens with Finder items:
tell application "Finder" to get startup disk
{1, 2, 3} & result --> error "Can’t make «class sdsk» of application
\"Finder\" into type vector." number -1700 from «class sdsk» to vector
The ways to avoid automatic coercion are either to present your tag
already in a list …
set tag_list to tag_list & {tag "abo"}
… or, more efficiently, to add the tag to the end of the existing list:
set end of tag_list to tag "abo"
NG
_______________________________________________
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