Actually I had already made a try but something doesn’t work
tell application id "com.devon-technologies.thinkpro2"
try
set thisSelection to the selection
set allTags to selected text of window 1
if allTags is not "" then
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ","}
set theTags to text items of allTags
set AppleScript's text item delimiters to od
set theTags to (parents of thisSelection) & theTags
set the tags of thisSelection to theTags
end if
end try
end tell
By the way, could it be possible to do it in a batch?
(I mean:
select some entries (that have the same text string before the tags (“tags:”)
getting the tags of each entry
apply the tags)
thisSelection is an array, you have to use a loop for each record in the array:
tell application id "com.devon-technologies.thinkpro2"
try
set thisSelection to the selection
set allTags to selected text of window 1
if allTags is not "" then
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ","}
set theTags to text items of allTags
set AppleScript's text item delimiters to od
repeat with theRecord in thisSelection
set tags of theRecord to (parents of theRecord) & theTags
end repeat
end if
end try
end tell
Sorry I’m really a dumb-scripter and don’t understand what’s an array or loop
What I meant to do with:
set thisSelection to the selection
was to get the current selected entry for later tagging it.
I rewrote the (wannabe)script and commented it:
tell application id "com.devon-technologies.thinkpro2"
try
--get the current selected entry
set thisSelection to the selection
--get the current selected text
set allTags to selected text of window 1
--split the text into tags
if allTags is not "" then
set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ","}
set theTags to text items of allTags
set AppleScript's text item delimiters to od
--save the tags in the current selected entry
set theTags to (parents of thisSelection) & theTags
set the tags of thisSelection to theTags
end if
end try
end tell