manual:Dictionaries
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| manual:Dictionaries [2017/09/04 06:04] – peternlewis | manual:Dictionaries [2021/10/04 07:24] (current) – [Accessing Dictionary Values] peternlewis | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| Keyboard Maestro includes permanently stored dictionaries that you can use or set. | Keyboard Maestro includes permanently stored dictionaries that you can use or set. | ||
| - | A dictionary is a mapping | + | A dictionary is a named set of mappings |
| Dictionary names start with a alphabetic character, followed by any number of alphanumeric, | Dictionary names start with a alphabetic character, followed by any number of alphanumeric, | ||
| Line 10: | Line 10: | ||
| Dictionary values are plain text and can include leading or trailing white space. | Dictionary values are plain text and can include leading or trailing white space. | ||
| + | |||
| + | For example, you might have a dictionary named "Shop Prices", | ||
| + | |||
| + | ^Dictionary^Key^Value^ | ||
| + | | Shop Prices \\ Shop Prices \\ Shop Prices| Coffee \\ Cake \\ Drink| 3.45 \\ 5.35 \\ 2.50| | ||
| ===== Setting Dictionary Values ===== | ===== Setting Dictionary Values ===== | ||
| Line 15: | Line 20: | ||
| Use the [[action: | Use the [[action: | ||
| + | {{: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | {{: | ||
| ===== Accessing Dictionary Values ===== | ===== Accessing Dictionary Values ===== | ||
| You can use the [[token: | You can use the [[token: | ||
| - | {{:token:dictionary-example.png? | + | {{:manual:dictionary_01.png}} |
| + | |||
| + | |||
| + | '' | ||
| + | |||
| + | {{: | ||
| + | |||
| + | '' | ||
| + | |||
| + | {{: | ||
| + | |||
| + | '' | ||
| You can list the dictionaries with the [[collection: | You can list the dictionaries with the [[collection: | ||
| + | |||
| ===== AppleScript ===== | ===== AppleScript ===== | ||
| Line 29: | Line 51: | ||
| ```applescript | ```applescript | ||
| tell application " | tell application " | ||
| - | name of dictionaries | + | set dictionaryNameList to name of dictionaries |
| + | end tell | ||
| + | ``` | ||
| + | |||
| + | ```applescript | ||
| + | tell application " | ||
| + | |||
| + | set newDict to make new dictionary with properties {name:" | ||
| + | |||
| + | # If you don't set a key/value pair the newly created dictionary above goes up in smoke. | ||
| + | tell newDict | ||
| + | make new dictionary key with properties {name:" | ||
| + | end tell | ||
| + | |||
| end tell | end tell | ||
| ``` | ``` | ||
| Line 35: | Line 70: | ||
| ```applescript | ```applescript | ||
| tell application " | tell application " | ||
| - | dictionary keys of dictionary "First Names" | + | set dictKeyList to dictionary keys of dictionary "Shop Prices" |
| end tell | end tell | ||
| ``` | ``` | ||
| Line 41: | Line 76: | ||
| ```applescript | ```applescript | ||
| tell application " | tell application " | ||
| - | set value of dictionary key "P" of dictionary "First Names" to "Fred" | + | set value of dictionary key "Coffee" of dictionary "Shop Prices" to "4.50" |
| end tell | end tell | ||
| ``` | ``` | ||
manual/Dictionaries.1504505059.txt.gz · Last modified: by peternlewis
