On Jan 30, 2015, at 6:28 PM, Shane Stanley < email@hidden> wrote:
Ron also confirmed that if you define a return type of list, no result is returned.
On further investigation, if you sprinkle just the right amount of syntactic sugar on it, you can return a list.
In the SDEF:
<command name="retrieve list info" code="TESTlist"> <cocoa class="ReturnListCommand"/> <result type="list of text"/> </command>
In the implementation file:
script ReturnListCommand property parent : class "NSScriptCommand"
on performDefaultImplementation() set anArray to current application's NSArray's arrayWithArray:{"item1", "item2", "item3"} return anArray end
And the sample script:
tell application "TestRecordReturn" retrieve list info --> {"item1", "item2", "item3"} end tell
Notes: The "syntactic sugar" is that the result type must be specified as above. If instead you used this (legal) syntax: <result type="text" list="yes" /> it will not work without implementing -scriptingTextDescriptor in an Objective-C class category on NSArray.
You can also use "list of integer", "list of real", "list of boolean", etc. as long as your NSArray contains the specified data type. One might reasonably think that "list of any" might allow you to send an array like {"some text", 2, true} but… no. All items in the list must be of the type you specified in the SDEF.
— Ron
|