AppleScript – Calling a MacScript Lib function from within a ‘tell block’ to another app

When calling a function in the Library from within a tell block targetting another Application you need to use “tell me”

For example I’m telling Adobe Indesign to collect the names of the pages in a document where there’s a text overflow, but I want to collect all that info into a usable list without duplicates so I use the Library function GetUniqueListItems. The function needs to be called from within a ‘tell block’ targetting the application Adobe InDesign CS4 to do stuff. If you don’t use tell me when referencing the MacScript Library function(s) then the AppleScript will bomb because it is still telling/talking to InDesign which doesn’t have this function in its own dictionary.

--This line will load the Library at compile time. (The Library will be embedded when you export your script.)
property parent : load script alias (((path to scripting additions from local domain) as text) & " Library")

	uses GetUniqueItems() function from library
	calling a library routine from within an application tell Block.
	The secret is explicitly to "tell me"

global thePageNames
set thePageNames to {}

tell application "Adobe InDesign CS4"
		set myDoc to active document
		tell active document
			set thePageNames to (name of parent of every text frame whose overflows = true)
			--set thePageNames to {"168", "168", "168", "170"}
			tell me
				set theResult to GetUniqueListItems(thePageNames)
				set newResult to TextListToString(theResult, ", ")
				display dialog "" & newResult as string
			end tell
		end tell
	on error
		display dialog "no document open"
	end try
end tell