Copy XML for Macro

I am not sure if this is a bug but it seems like just an oversight to keep the following as part of the macro action. Everything else is preserved when copying the XML except the text.

The %PromptButton% text gets removed when running the XML.

Becomes this when the XML is run.
image

User Prompt XML

Create Action - User Prompt Macro (v11.0.3)

Create Action - User Prompt.kmmacros (59 KB)

It's never a bug.

OK, that is technically not true, but honestly, and with as much humility as I can muster, it's almost always true.

Your Insert Text by Pasting action is configured to process tokens, so it dutifully processed the tokens in the XML before pasting the result, and since the XML has unencoded tokens like %PromptButton% and others, the results are that the tokens are processed when you paste, not left unprocessed.

image

2 Likes

Isn't everything preserved when copied?

If the XML is copied and pasted into a text editor, and %PromptButton% is replaced with \%PromptButton\%, I think the XML will then behave as expected when pasted back into the KM Editor.

1 Like

I think changing %PromptButton% to %%PromptButton%% in the body of XML text will work too.

1 Like

Haha, I knew that felt off even saying that. I need to instead say can you explain this behavior as to not come across presumptuous.

Thanks for the explanation.

Thank you that was the ticket and worked!

As soon as I read this I thought to myself "duh me," I have done that before. I tried it and it too worked. The difference though is I had to go into the XML to do this where as with the former I just needed to do that before I copied to XML.

I also just realized that part of the problem was using the shortcut macro to copy XML. If I use it with something like this then @_jims will still work. However if I add the %%PromtButton%% and then run the macro I lose the Token altogether.

I don't know eneough about why but at least I know what to do now.

Insert XML By Pasting Action

Insert XML By Pasting Action.kmmacros (33 KB)

3 Likes

It would, except there are other places in the XML that also use % characters and tokens (at least I'm pretty sure I saw others when I skimmed the XML).

1 Like

I think those other uses of % in the XML text are for KM Variables and the intention was for those Variables to be expanded into their values, so those ones would work fine just left as they are I think. My advice was to turn the single % into %% manually where needed.

1 Like

Ahh, ok, I didn't look that closely. In that case, yes, the XML would need to be pre-quoted to preserve the things that need preserve while allowing the things that need processing to be processing.

But also you will then need to ensure that the variables being interpolated are legitimate XML (for example if they have < in them that would be a problem).

3 Likes