Way back when Matt Neuburg wrote AppleScript: The Definitive Guide, he stated that:
“There is no built-in way to obtain a list of the names of the items of a record…I have seen many elaborate attemtps to work around this problem, but I’m not going to show you any of them. This is a big shortcoming of AppleScript itelf, and it needs to be fixed on the level of AppleScript itself”.
I guess we’re still waiting for that fix, and I was wondering if anyone would care to share any "elaborate attempts” they know of?
TIA
Phil
#[SCRIPT]
system info
try
result as text
on error errMsg number errNbr
offset of "{" in errMsg
set errMsg to text (result + 1) thru -1 of errMsg
offset of "}" in errMsg
set errMsg to text 1 thru (result - 1) of errMsg
set listOfRecords to my decoupe(errMsg, ",")
set theLabels to {}
repeat with aRecord in listOfRecords
item 1 of my decoupe(aRecord, ":")
set end of theLabels to result
end repeat
theLabels
end try
#=====
on decoupe(t, d)
local oTIDs, l
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
set l to text items of t
set AppleScript's text item delimiters to oTIDs
return l
end decoupe
#=====
#[/SCRIPT]
Of course it's not perfect.
It would be useful to take care of possible encapsulated records.
But as I have a perfect answer to the problem in ASObjC Runner I will not spent more time upon that.
Yvan KOENIG (VALLAURIS, France) mercredi 9 avril 2014 18:54:10