manual:Dictionaries
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| manual:Dictionaries [2017/09/04 05:50] – created 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}} |
| - | ===== See Also ===== | ||
| - | === Actions === | + | '' |
| - | * [[action:Set_Dictionary_Value# | + | {{:manual: |
| - | === Forum === | + | '' |
| + | |||
| + | {{: | ||
| + | |||
| + | '' | ||
| + | |||
| + | You can list the dictionaries with the [[collection: | ||
| + | |||
| + | |||
| + | ===== AppleScript ===== | ||
| + | |||
| + | You can read and write dictionary values from AppleScript. | ||
| + | |||
| + | ```applescript | ||
| + | tell application " | ||
| + | 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 | ||
| + | ``` | ||
| + | |||
| + | ```applescript | ||
| + | tell application " | ||
| + | set dictKeyList to dictionary keys of dictionary "Shop Prices" | ||
| + | end tell | ||
| + | ``` | ||
| + | |||
| + | ```applescript | ||
| + | tell application " | ||
| + | set value of dictionary key " | ||
| + | end tell | ||
| + | ``` | ||
| + | |||
| + | ===== See Also ===== | ||
| - | - [[https:// | + | See also the [[action: |
manual/Dictionaries.1504504256.txt.gz · Last modified: by peternlewis
