Retrieve list of property identifiers from a list of records

I have a list of records:

{identifier1:property1, identifier2:property2, identifer3:property3}

How do I extract just the identifiers, either individually or as a new list?

Model: MacBookPro
AppleScript: 2.4.3
Browser: Safari 6.0.3
Operating System: Mac OS X (10.7)

It can be done with Shane’s ASObjC runner

tell application "ASObjC Runner" to return all labels of {identifier1:1, identifier2:2, identifer3:3}

download can be found here. It’s an faceless app just like system events.

My final script will have to run compiled on unknown Macs throughout the company.

Would each Mac also have to be running ASObjC at the time the compiled AppleScript ran?

Yes, but you can Embed ASObjC Runner in applets…
http://www.macosxautomation.com/applescript/apps/runner_vanilla.html

Thank you. If I can get my superiors to agree to an applet being distributed with the compiled AppleScript, that’s the way I’ll go.

I have found a number of “brute force” handlers posted online which could also be used.

I consider this question answered.

Another option is to make your script an ASObjC app itself. Depending on what it’s doing, it may not involve much more work.

Hi,

Another way to do it is with the clipboard. Ex:


set r to {a:1, b:2, c:3}
tell application "Finder"
	activate
	set the clipboard to r
	set c to the clipboard
end tell
set the_list to list of c
tell the_list
	item 1 & item 3 & item 5
end tell

gl,

Model: MBP
AppleScript: 2.2.3
Browser: Safari 536.26.17
Operating System: Mac OS X (10.8)

This looks very promising with some tweaks for lists whose number of items may vary.

Thanks

Hello.

This should work for a variable number of items, it extract the property names from the list gotten by kel1’s way, in the post above.

set the_List to ...
set propsList to {}
repeat with i from 1 to (count the_List)
	if i mod 2 ≠ 0 then
		set end of propsList to item i of the_List
	end if
end repeat

Edit

Corrected.

or shorter, the Finder is not needed to access the clipboard


set theRecord to {a:1, b:2, c:3}
set the clipboard to theRecord
set recordAsList to the clipboard as list

set identifierList to {}
repeat with i from 1 to (count recordAsList) by 2
	set end of identifierList to item i of recordAsList
end repeat


Elegant.

Thanks, StefanK