Never saw this Applescript error

Tags ( )

I'm writing a script for my GTD notebook. This script should collect entries from a list of folders, based on certain criteria. It aliases the collected entries to another folder for inspection.

I want the script to look in that last folder, so it won't add a 2nd alias for entries that are already represented in that folder, and I can't get this to work. I have reworked the collection to build a list of names instead of entries, but still get the same error when I try to get the entries themselves.

Here's a sample (list 'theList' is declared at the top of the script):

repeat with aName in weededList -- change from names to references
set anEntry to (entry named aName)
set theList to theList & anEntry -- error occurs here
end repeat

The attempted conversion from names to entries gives this error message:
Can't make «class MLen» id 266 of document "xxx" of application "Mori" into type vector.
(when run from Scripteditor; running from Mori does nothing).
«class MLen» likely means "entry", but I have never seen the word "vector" in an Applescript error message.

It would appear that you cannot add entries to an (initially) empty list.
Am I equating dogs with cats, or is something else going on?

Any comment is greatly appreciated.

ThijsZ

I think anEntry is a

I think anEntry is a reference to the actual entry, and theList is a string.
Try this:
set theList to theList & aName

Mike

Mike, Thanks for

Mike,

Thanks for responding.

I think anEntry is a reference to the actual entry, and theList is a string.
That's what I thought, initially.
So I put this at the top of the script: property theList:{}.
Didn't work.
Yet a log (class of theList) right before the offending line gets me (*list*).
Putting the variable declaration inside the tell block didn't work either.

set theList to theList & aName
Well... weededList is already a list of names that I want to convert to references. How would your line improve on my code?

I feel there's a bug here, somewhere. How to go about identifying it?

I solved my problem by attacking from the other end; don't go looking in a folder for a specific alias, but collect the aliases, and find out if one of them is in the target folder. Like so:

repeat with anEntry in thisList
set addAlias to true -- first assume it's not in target folder
(* test for alias in target folder *)
if exists next alias of anEntry then
set allMyAliases to joined entries of anEntry -- get all aliases for this entry
repeat with anAlias in allMyAliases
if name of container of anAlias is targetFolderName then set addAlias to false -- yes, it's in there
end repeat
end if
(* end of test *)
.
.
end repeat

Not too fast, with nested repeats, but works..
ThijsZ

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.