Smart Rule scripts supporting inline AppleScriptObjC

I’ve recently seen posts where users used inline AppleScriptObjC in Smart Rules.

In the past it wasn’t possible to do that, instead we needed to call a script library. As I couldn’t find a mention of this new behaviour in the help I was sure that it won’t work.

Now tested and … whooooaaaaahhh … it’s possible now!

Thanks so much!!

-- Test - Smart Rules - Is inline AppleScriptObjC possible

use AppleScript version "2.4"
use framework "Foundation"
use scripting additions

on performSmartRule(theRecords)
	set theArray to current application's NSMutableArray's arrayWithArray:{"1", "2", "3"}
	set theList to theArray as list
	set theList_string to my tid(theList, linefeed)
	display dialog theList_string
end performSmartRule

on tid(theInput, theDelimiter)
	set d to AppleScript's text item delimiters
	set AppleScript's text item delimiters to theDelimiter
	if class of theInput = text then
		set theOutput to text items of theInput
	else if class of theInput = list then
		set theOutput to theInput as text
	end if
	set AppleScript's text item delimiters to d
	return theOutput
end tid

Actually there was no related change in DEVONthink, I’m not even aware that this wasn’t possible :confused: :confused:

It definitely wasn’t possible in the past, tried it myself, more than once.

After it didn’t work back then I searched the forum and found this thread. In this thread @clang thankfully came up with the solution of moving ASObjC into a script library. Since then I’ve been using his approach.

Again, tested quite often, it wasn’t possible in the past.

That’s unfortunate. As a forum search revealed others who already mentioned this problem I didn’t think about reporting it.

It’s sunday, what are you doing here after all? :slight_smile: