Default to last-used "friendly" value in User Input dialog

I'm using the "Prompt for User Input" Action to get values for Month and Year. These are stored as variables, by number. I built my form using "friendly" values in order to allow users to select Months by name rather then number. I want the form to default to the last used value. How can I (simply and elegantly) have this value show as the corresponding "friendly" value?

Here is the Action:

Here is the dialog that shows after selecting July 2013 previously:

Looking ahead: Does KM has a built-in spinner control to click to go to next/previous values?

Thanks.

Chapeau! to @JMichaelTX for the exemplary help page https://wiki.keyboardmaestro.com/action/Prompt_for_User_Input .

1 Like

In your prompt, use something like: %Variable%Month%|January (01)|February (02)|…

Then instead of using the Month variable directly, use:

Search Variable Month for regex (\d\d) and put that in a new variable which you use as appropriate.

A stepper you mean? No.

2 Likes

This is a great question, and the answer is far from obvious.

The solution is to build the "friendly" default value to be used in the Prompt Action.

Here's an example which should show you how.
Let me know if you have any questions:

The RegEx to Get the Friendly Value
(%Variable%SDP__Value%__.+?)(?:\||$)

The Prompt Default Value:
|%Variable%SDP__ValueFriendly%|%Variable%SDP__Choices%

##example Results


###MACRO:   Set Default for Prompt to Friendly Value @Example

~~~ VER: 1.0    2017-02-20 ~~~

####DOWNLOAD:
<a class="attachment" href="/uploads/default/original/2X/8/8c4acecf342c8eddbb6b6a51c95dd78c9d0ebc57.kmmacros">Set Default for Prompt to Friendly Value @Example.kmmacros</a> (3.6 KB)


---

<img src="/uploads/default/original/2X/2/218276bc7bb4b73b27f916a831e7e3b107b89548.png" width="703" height="1253">
3 Likes

Thank you @JMichaelTX and @peternlewis very much — I sense what you’ve done and will parse my way through the Regex sorcery. Clever, useful, informative, and instructive! I very much appreciate your answers.

1 Like

Please feel free to post any follow-up questions.

This worked great! I was able to modify this (only slightly) to suit my purposes perfectly. Love when that happens.

Thanks for posting.

1 Like