User Tools

Site Tools


Sidebar

dictionary:more:valueforkey

Value For Key

The value for key verb accepts an AppleScript user record and a text key and will return the value in the record that contains that key. Since user records use hard coded keywords usually there is no built in AppleScript way to get the value out of a record if you don’t know the key at compile time without using this verb. This only works on user created records with text keys and not with records for which the keys are enumerated in the scripting dictionary.

Usage:

value for key (the user defined record) key the text key name. Both parameters are required.

returns the found value or an error if the key is not found.

Example:

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

write log (value for key myRecord key "height”)

will write “6 foot and a half” to the log.

See Also:

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