This macro demonstrates a Prompt For User Input Dialog Box with the following characteristics:
Includes additional descriptive information the first time the macro runs.
Dialog box settings are saved to a KM dictionary rather than separate global variables.
Contains three elements: Text Entry (New Color), Popup List (Color Selection), and Checkbox (Delete Selection).
The Text Entry value can be used to add an item to the Popup List item. Added items are sorted.
The Checkbox value can be used to delete an item from the Popup List item.
The default Popup List item changes based on the previous macro action.
DIALOG BOX SETTINGS
As mentioned above, the dialog settings are saved to a dictionary. The name is jsDDPL_dict, where js are my initials and DDPL represent the macro name. The structure is as follows:
1.0 initial version 1.1 No change to macro functionality. Defined local_DICT and used it rather than hard-codng dictionary name throughout.
DOWNLOAD Macro File: Dialog with Dynamic Popup List.kmmacros (50 KB) Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.
Here's a utility macro I created and used while I was learning about KM dictionaries. It's very basic but includes examples of these dictionary functions:
Add/Update a Key
View All Keys
View Two Specific Keys
Delete Dictionary By Setting All Keys to null
Delete Dictionary By Setting JSON {} [much simpler method]*
DOWNLOAD Macro File: Dictionary Functions-jsDDPL_dict.kmmacros (24 KB) Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.
Hi @_jims these Macros are great and I think your idea of using Dictionaries to store the default choices is really brilliant. Lots to copy and use here!
And the recommended way is as you are showing, with a For Each Loop and several Actions. I was doing that too, but the other day I stumble across the below by @kvanh
It uses one single Action (the Set Dictionary to JSON Action) to delete the dictionary in one simple step. It means you can clear whole Dictionaries at the end of a Macro as simply as you would delete Variables. And that makes them even easier to use as temporary storage for just one run of a Macro.