I am trying to generate a list from a selection of records that match a particular property (eg type is markdown) without resorting to a repeat loop.
set markdownRecords to (items of selection whose type is markdown)
Unfortunately, this generates an error:
error "Can’t get selection of application \"DEVONthink Pro\" whose type = markdown. Access not allowed." number -1723
After searching through some threads here, I have noticed a few examples of something similar in DT3 but nothing that would work in v2 (2.11.3). For example in this post:
repeat with theRecord in (selected records whose (type is markdown))
Of course, there is no selected records
in DT2.
Sometimes I have found that you can use a reference to
in such a scenario but not in this particular one.
My purpose here is to simplify a library script that returns a list of markdown records regardless of the nature of the frontmost window. I then have a bunch of scripts that will work with the listed records.
Here is that script:
tell application id "DNtp"
set fw to front think window
if (class of fw) is document window then
if type of record of window id (id of fw) is markdown then
set returnedList to (record of fw as list)
end if
-- display dialog winClass as text giving up after 2 -- "document window"
else
-- display dialog winClass as text
if selection of fw is not {} then
set selectionList to selection of fw
set returnedList to {}
repeat with sel in selectionList -- each selected record
if type of sel is markdown then
set end of returnedList to content id (id of sel) of database id 2 -- list of markdown to be returned
else
display dialog "record is not markdown" with icon caution giving up after 2
end if
end repeat
end if
end if
return returnedList --> content id 339246 of database id 2
end tell
Any suggestions or is this not possible with DT2? Thanks.