User Tools

Site Tools


Sidebar

dictionary:more:keysfromrecord

Keys From Record

The keys from record verb accepts a user created AppleScript Record and returns a list of all the keys in it. If there are embedded Records only the keys for the top level will be returned. This only works for user created records and not for Records that use enumerated values as described in the Scripting Dictionary.

Usage:

keys from record (AppleScript user defined record) returns an AppleScript list.

Example:

set myRecord to {myname:"James", height:"6 foot 4 and a half", shoesize:"extra large wide"}

set myKeys to keys from record myRecord

repeat with thisKey in myKeys
	write log thisKey
end repeat

will write 3 lines to the log containing:

myname

height

shoesize

Note: if your record contains reserved words as keys they may not be included in the output. For example if the key for “myname” above was simply “name” that would not be included as it is not treated as a user keyed name and instead uses a built in enumerated key. You’ll know if that is going to be the case as the word will be blue instead of green when the script is compiled showing you that it is a built in or dictionary defined value and not the green of a user variable.

See Also:

dictionary/more/keysfromrecord.txt · Last modified: 2020/04/27 13:41 by James Sentman