Quantcast
Channel: DEVONtechnologies Community - Latest posts
Viewing all articles
Browse latest Browse all 16859

Ability to choose alias from a group specific drop down list

$
0
0

The following script generates a list of tags, in alphabetical order, that are used by at least one child of the current group. It then creates and opens a plain text document containing the link.

tell application id "DNtp"
	set currentWindow to viewer window 1
	set theGroup to root of currentWindow
	set listTags to {}
	if (children of theGroup) is {} then return
	repeat with theRecord in (children of theGroup)
		set theTags to (tags of theRecord)
		repeat with aTag in theTags
			if listTags does not contain aTag then set listTags to listTags & aTag
		end repeat
	end repeat
	set listTags to my sortList(listTags)
	set textOfList to my convertListToString(listTags, return)
	set listRecord to create record with {name:"List of tags", type:txt, content:textOfList} in theGroup
	open tab for record listRecord in currentWindow
end tell

on sortList(theList) -- This handler copied from Apple's Mac Automation Scripting Guide
	set theIndexList to {}
	set theSortedList to {}
	repeat (length of theList) times
		set theLowItem to ""
		repeat with a from 1 to (length of theList)
			if a is not in theIndexList then
				set theCurrentItem to item a of theList as text
				if theLowItem is "" then
					set theLowItem to theCurrentItem
					set theLowItemIndex to a
				else if theCurrentItem comes before theLowItem then
					set theLowItem to theCurrentItem
					set theLowItemIndex to a
				end if
			end if
		end repeat
		set end of theSortedList to theLowItem
		set end of theIndexList to theLowItemIndex
	end repeat
	return theSortedList
end sortList

on convertListToString(theList, theDelimiter)
	set AppleScript's text item delimiters to theDelimiter
	set theString to theList as string
	set AppleScript's text item delimiters to ""
	return theString
end convertListToString

Successfully tested in a group containing 10 tagged documents.


Viewing all articles
Browse latest Browse all 16859

Trending Articles