script CustomFieldCommand
property parent : class "NSScriptCommand"
on performDefaultImplementation()
-- For demo purposes, the data is just hard-coded here
set theScore to 100
set theTitle to "Just Because"
set isActive to true
-- return an NSDictionary whose keys match the property names defined in sdef's record-type
set aDict to current application's NSDictionary's ¬
dictionaryWithDictionary:{score:theScore, title:theTitle, active:isActive}
return aDict
end
end
And finally the test script:
tell application "TestRecordReturn"
retrieve custom info --> {score:100, title:"Just Because", active:true}
end tell
Notes:
The ASOC engine will use the SDEF to interpret the field names (keys) in the NSDictionary the command returns, and will automatically convert it into an AppleScript record.
The keys in the dictionary must match the property names in the SDEF record-type. If they don’t, the engine will silently omit them.
The cocoa class attribute in the command must match the name of the script class, CustomFieldCommand in the example code.
This is relatively simple, and is presented for comparison with the follow-up posting, which will show how to return a user-defined record.
— Ron