How To Dereference Text-Tokens in Variables?

Hi...I'm needing help again!

I'm reading tokens from a file and attempting to dereference them. So when reading a file containing %NumberDate%, for example, I want to convert it to 2/20/22. I tried this:

image

and got this result:

Screen Shot 2022-02-20 at 2.02.41 PM

I want to get 2/20/22 for both. Is there some function I can apply to the variable containing the string %NumberDate% to turn it into the actual date, or some other way to do it?

Thanks!

I think you can use the "Filter" action, and use the option "Process Text Tokens", or something similar to that.

Yes, Dan is correct, there's a KM action called Filter which has an option called "Process Tokens" which lets you evaluate the contents of a token whose name is stored in a variable.

Over the last week I've posted two or three macros in the Macros part of this website using that action. If you need to examine one of my examples, I'll post a link to one in this message in a few minutes.
...

Okay, here's one of my macros which uses that action if you want to see it in action:...

1 Like

Bingo! Thanks (again), Sleepy!

image

I'm happy if you are happy.

I was very happy when KM introduced this feature.

This method can be used to evaluate tokens, variables, dictionaries, or calculations.

I believe that there's also a way in AppleScript to "dereference" variables within AppleScript. So I think that even without this action in KM, there's another way to get this job done, since AppleScript can access KM variables (but probably not tokens or dictionaries. Hmm, that's making me think.)

JXA also, as well as Custom HTML Prompts.