TIP: Understanding KM Variables, Tokens, & Functions

==UPDATED==: 2021-06-17 20:50 GMT-5

After I wrote all of the below, I came back to the top to emphasize ==the most important way to learn and understand Macros, Action, Variables, Tokens, Functions: Write your own test macros to explore and understand what a particular thing does.==

OK, here is information about three of the key KM entities you mentioned.
Each provides a link to the main KM Wiki article about the entity. I highly recommend that you study each carefully, and construct some test macros that use each.

The ONLY entities that you can "pass on" to other Actions are Variables and Dictionaries .

Finally take a look at some of the Macros in the Best Macro List to see some good use of all of the below entities. If you have trouble understand what each Action does, then run the Macro using the Macro Debugger .

Key KM Entities (after Macros and Actions)

  1. Variables (Main reference in KM Wiki)

    • Are user-defined storage locations where you can set and get the value of their contents.
    • There are many Actions which use Variables (see above link for list), but the most common is Set Variable to Text Action.
    • One Action can SET a Variable, and a later Action can GET and use that Variable.
    • ALL KM Variables can contain ONLY text (strings).
      • Even if the text is a number, it is really just text.
      • However, when you use a KM Variable in a numeric or calculations field, KM will treat it like a number, allowing math and other operators.
      • KM Variables can also work like a pseudo array . Limited support is provided for handling pseudo arrays.
    • Variables vs Named Clipboards
      • There is no reason, no advantage, to using Named Clipboards over Global Variables , UNLESS you need something other than plain text stored in KM Variables, like images, rich text, objects, etc.
    • Please study this KM article since it provides an in-depth discussion of Variables, including some good examples.
      .
    • Also See:
  2. Tokens (Main reference in KM Wiki)

    • represent placeholders for information about a specific object. For example, the %SafariTitle% token returns the title of the current Safari tab. So the value of the Token will be determined at execution time.
    • Tokens work very much like classical program functions, where the function, with zero or more arguments, returns a value.
    • At execution time the Token will return a value, as if you had typed it in.
    • Again, please study the above KM article as it provides in-depth defintion, list of Tokens, and an animated GIF showing how to use Tokens.
      .
    • For more discussion, see:
  3. Functions (Main reference in KM Wiki)

    • allow you to calculate certain information for use in numeric fields, returning a value at execution based conditions (like Window size, location, etc) at that moment.
    • Some of the most often used Functions are those that relate to the Screen and Windows
      Here's an example:
7 Likes

great synopsis, thank you

1 Like

Just added this section to the OP.