In my sdef I have some commands (subclasses of NSScriptCommand) from which I need to return lists and records.
To my surprise, the built-in support for AppleScript return types does not include lists. Records are also advised against, but I think I can handle building my own record-type elements (at least it seems straightforward enough).
However, most of the time, I just want to return a list (possibly of mixed types). I can’t find any examples of how this is done in the sdef’s on my own machine.
I note the docs mention that you can create your own value-types, but I’m not sure I fully understand how these work. Can I create my own return type for lists just by doing this (I’m assuming if it was that easy they’d be included to start with, but presumably I’m missing something – see Edit below)?
And if not, is there some other way I might achieve this?
Edit:
Trying it gave me this error message:
Error while returning the result of a script command: the result object…
(
hello,
world
)
could not be converted to an Apple event descriptor of type ‘List’. This instance of the class ‘Swift._SwiftDeferredNSArray’ doesn’t respond to -scriptingListDescriptor messages.
Reading up from where the docs mention results specifically and talk about parameters in general, I do now see an incidental mention of that. I expect I’d have continued to overlook it if you hadn’t pointed it out.
Edit:
Yay, bingo! Thx muchly (or is it ‘bigly’ these days? )
I do not pretend to teach you anything about it, nor to compete with Shane.
I just wanted to share (with you and others) a tool that saves me a lot of time…
Yes I understand that, but it wouldn’t have helped in this case. I did find that I had a copy sitting around on an archive and found that it wouldn’t have been able to provide the syntax for either lists or records in the results parameter.
But the suggestion was welcome, nonetheless!
(And the good news is I’ve got my records working now, too; and it looks like I should be able to use record-types to instantiate a mixed list as well, so all’s good!).