After Reading the Relevant KBM Wiki Page I'm Still Not Clear on What a Token Is

you are right on all points including constants.
thank you for your comment

1 Like

Sorry, that doesn't fly. You are introducing a broader use of functions in programming that does NOT apply here. So, your follow-on statements about "Actions", "Conditions" does not follow.

I'll stand by my above statement:

Both KM Tokens and KM Functions return some information, some with parameters, and some without parameters.

  • KM Tokens return text data that can contain numbers
  • KM Functions return only numbers
  • In most languages, functions can return numbers or text (and other types), but you have limited KM Functions to return ONLY numbers.

Yes, you have restricted where KM Tokens can be used, and where KM Functions can be used, and this also is a constant source of confusion among new users.

But other than that, how are they functionally different?

Let's think about this from a non-programmers POV:

I need some information about some object, some thing. How do I get it?

I Need KM Tool Example Results
The width of the main screen FUNCTION SCREEN(main,width) 2560
The frame coordinates of the main screen TOKEN %Screen%Main% 0,0,2560,1440

image

So now, both Tokens and Functions return info about the screen.
How can I remember which list to look in for what I need?

  • Edit > Insert Token
    OR
  • Edit > Insert Function

So, Peter, please tell me how KM Tokens are NOT very much like KM Functions?
Or, put another way, what is a better way to describe KM Token than to say they are very much like Functions, but always return text data, and can only be entered into KM Text fields?

I'm afraid I don't have time for a debate on the subject.

I have explained how they are different, and why they have different terminology. “function” is a generic term that covers any mapping from inputs to outputs, and when including side effects, encompasses everything. So fine, everything is a function. Which is useless as far as terminology goes. There are many differences between what Keyboard Maestro classes as a function and what Keyboard Maestro classes as a token.

1 Like

Sorry, I don't see "many" differences. I only see two:

  1. Type of data that is returned (numeric vs text)
  2. Where the command can be used (numeric field vs text field)

More importantly, is that ==the primary purpose of both is to return information about some object in the user's environment==. (Yes, I know that KM Functions also have a few that are just pure math functions).

Do you disagree with the primary purpose I have stated?

I don't wish to debate this either. My ONLY objective is to come up with a revision to the Wiki article for Tokens that will be clear to most KM users.

Amen!

-Chris

1 Like

The best way to to make it easier for novice Keyboard Maestro users to understand what a token is is with more examples that show how they would be used to solve problems they want to solve.

Currently the page (like most of the wiki) is heavy on reference (which is good, because that helps with clarity and precision), but light on usage. It does a good job of documenting the specifics of “what?”, but it does a poor job of answering the “why?” and “how?” questions.

For someone to understand what a token is, they primarily need to understand what problem they would use it to solve, and how they would use it to solve that problem.

2 Likes

Attention All Readers Interested in Tokens

I have made a major rewrite of the Wiki Tokens page.
I have tried to address all of the concerns posted in this thread, as well as other concerns that have been identified.

My sincere thanks to all that have participated here.

Please review and feel free to submit your comments and suggestions at:

Wiki: Update to Tokens (manual page)

3 Likes

@ccstone @JMichaelTX

Thanks very much JMTX for the wiki page on tokens. It is well written and will clarify the issue for many users.

3 Likes

Since it might now be relevant. I found the 'debate' between @JMichaelTX and @peternlewis very enlightening as a matter of fact. Some discussions are like that, one learns a lot from them unwittingly from the point of view of the debaters you might say. Thanks for the time and trouble all of you on this thread. As I said I don't want to bend this discussion to much my way being a very narrow niche user. Looking at the discourse pages over all I am guessing that most, maybe nearly all the users who post much here have programming experience?

I will look carefully at your rewrite @JMichaelTX when I can over the next week or so. I and I think others really appreciate the efforts you guys put into this. With much IT these days it is 'sink or swim' or pay me x dollars to do it though I could show you in one minute...

2 Likes

Just to show you what lies behind what I say and doing exactly what you say should clarify things: it didn't though Peter to be fair to Jim here.

This macro is REALLY useful to me. I modified it from the short date token in the drop down menu. As I said I don't really know how I got there. I added two other actions here just to show what I mean to folk. The first action is what I want, formatted as I want, the other one is what %ShortDate% gives and the other one gives the same result but with an explicit format. I maybe confused myself here? Even the question of what the name is a bit vague to me, is it the name in the drop down menu or is it " %ShortDate% " ? Same goes for variables which I think are dawning on me slowly in KM usage. It is fine to delelop ones own usages as you say and as you also rightly say, happens all the time in science and technology.
Thanks for your time, I am now going to re-edit that macro back to just the first action. :smiley:

1 Like

2 posts were split to a new topic: Choosing Typed String Triggers

@ronald I created a new topic, I thought it best for this. It is relevant I think to this thread but I think it is getting over complicated, partly due to me I confess. I hope folk don't mind me opening a new topic. It shows really how one can modify the date format from the date tokens. If you like. Something a lot of people on this site take for granted I think to be honest. I think it is kind of programming abc?
For triggers, to repeat what I say in the new thread, I would stick with the one that Sparks and others tend to use. $ is used a lot for markup in some places. I think I have LaTeX stuff uses it a lot so I avoid it for other things. double letters I use a lot and make sure I have them only trigger AFTER a space. Works ok. For example I have "p p e n" expand to Pennsylvania but only after a space. Otherwise I get it trigger in the middle of "happen" :slight_smile: things like that one can usually sort out when they come up I have found, no need to plan too far ahead. I put the caveat that most of the experts here put in. If you have a large number of expansions it is best to use a dedicated app like TextExpander. I have found KM is better for me actually. More control somehow?

2 Likes

Good idea! Thanks.

One way to create a new Topic that is related to an existing topic/post, is to click on the Link button at the bottom of the post. This will cause a link to be placed on both the old and new topics connecting the two.

2 Likes

A post was split to a new topic: Use of Variables in Mathematics

@JMichaelTX Thanks! I really think that has clarified a lot for me since the re write. I really think you have re written it usefully.

It helped me understand how "variables" in KM terminology work at the same time. FYI it clarified, I am not sure what you changed, this one for me;

% Variable % < VariableName > %

see I was reading that as

%Variable%VariableName%

The use/mention distinction is one I know well too, but I just didn't click until I saw your rewrite. I might just have read it wrong initially of course: too much 'speed reading' :laughing:
and it made no sense to me and examples I tried just wouldn't work, I think that might have been for other reasons now though: you can see how hard it is for a beginner to work through this.

1 Like