Can the Snippet action save the results of each edit to its edit boxes?

The Snippet action can be pretty handy at times, but it would be much better if, when a user changed a field, the Snippet action then changed the actual value of the variable that was displayed and edited in the field.

https://wiki.keyboardmaestro.com/action/Prompt_for_Snippet

I'm fairly puzzled why the fields are editable if the resulting edits are just ignored. Sure, they are put into the final variable, if one is specified in the action, but doing that will combine all the text fields with it, so it's very difficult to use. (Am I wrong? Did I overlook anything?)

Here's an example. I created a macro that displayed this Snippet:

I was expecting that when the user edited the value "5" to "7", and pressed OK, the action would change the variable that contained the value "5" into a "7".

I was well on my way to creating a wonderful macro (for editing all 70 KM internal variables) but now that I realize the Snippet action cannot save any of its edit boxes, my life is about to become much more difficult.

If this action can't save individual Edit boxes, I'd like to make this into a feature request. Perhaps a flag can be placed onto the cogwheel of this action called, "Save Edits."

I'm not positive this is exactly what you wanted, but I do something similar by parsing the snippet for variable names via regex:

Apologies if that's not what you're trying to do; I don't fully understand your exact needs.

-rob.

The action's intended use? IMO it's for generating customised text -- like a mail merge only you get to enter the data on the fly -- rather than variable-setting. So yes, you'll have to parse the text to extract values and set variables as in @griffman's example.

What's stopping you from using a normal "Prompt for user Input" -- is it just that the layout options are better in "Snippet"?

I started with that action, but realized that there wouldn't be room for 70 values, while Snippet was compact enough to get much closer to 70. I guess now I'll have to break it up into several pages.

Thanks. I'm glad you showed me that macro. I hadn't seen that before (even though I did search a little on this site.) Of course, using regex will be very difficult because the 70 variables that I'm planning to let the user edit might contain colons or nearly any other character. So it's going to take me a lot of research before I can figure out how to use regex to solve my problem.

The float, int and boolean values won't contain colons, but the string values could.

Still it would be appreciated if The Architect could include a flag to let the action save its values.

Then I'd use a custom delimiter between the "variable" name (i.e. the input text) and the input area, so you have something to search on. (You can probably even skip the regex by using the split features in JXA or KM's array variables, but I didn't go that route with my macro.)

Set it up something like...

The descriptive text ➡️ [input value]

I guarantee you that the forward arrow emoji isn't in any of the string values :).

I actually asked about this at some point before I wrote my split-them-out macro, and he said he had no plans to do this, basically because of @Nige_S' explanation: It's an input form for a blob of text. I thought it was in a forum thread here, but I can't find it now, so it may have been an email exchange.

-rob.

That's a good idea. I'll mark it as the solution.

1 Like