@peternlewis, you have provided us with a large set of KM Functions, but I believe all of them operate only on numeric data.
There are a few choices for Variable and Clipboard Filter Actions, that seem to me to be more like functions, than filters (at least as I understand the word "filter").
Would it be possible in the next major version of Keyboard Maestro to provide the following "filters" as functions, so that they could be used anywhere a function can be used:
Add to Functions
Count the characters, words or lines and return the
result.
Calculate an expression and return the result, see the Calculations
section.
Process Text Tokens and return the result, see the Text
Tokens section.
It is counter-intuitive to me to replace a variable with something that does not contain any part of the variable, and call this a "filter". An example is the Filter "Character Count".
When I'm looking to manipulate strings, I often forget that these functions are embedded in "Filters", and not "Functions".
So, I'd like to be able to use, "Set Variable to" Action, and use a function that works on strings, like "Character Count".
It would also be great to use these string functions in IF Then Else Actions, like with the "Calculation" condition:
If All Conditions Met
The calculation âCharacterCount (My Text Var) > 20â returns true (non-zero)
Well, this depends on the content quality of the text. I have seen many texts that could rather losslessly be replaced by their character count. This can save huge amounts of disk space!
In that sense the character count filter can very well act as a highly efficient clean-up filter, stripping unnecessary characters
Ha, you see now how useful the Character Count filter is, and why itâs called a filter?!
My filtered post above is â320â and your last post is â111â. And the whole thread would just be â1830â, without the quoted text. Much less work for the forum server!
Functions can only be used in numeric fields. Currently they have no support for strings, and I donât really plan to add support for strings - the cost/benefit on that seems prohibitively negative.
There could be a COUNTCHARACTERS(Variable) (COUNTWORDS, COUNTLINES) function that takes a variable name and returns the result. There could also be a CALCULATE(Variable) function that returns the numeric result of the variable after it is calculated.
Iâm not sure about processing text tokens. I suppose I could suspend the calculation engine until the matching closing bracket, just like the %Calculate% text token does, and then it would work if and only if the text tokens returned a numeric result (so %ICUDateTime%yyyy% for example).
So all that is relatively straight forward.
What I donât plan to do is something like âabcâ + âdefâ to produce âabcdefâ or anything like that.
Whether a case can be made for anything like COUNTCHARACTERS(âHelloâ) or COUNTCHARACTERS("%ICUDateTime%yyyy%"), that Iâm not sure. Maybe.
If any of these are added as functions, then they will work in the calculation condition as well as any other numeric field.
Thought you meant there was something called âSet Variable to Actionâ whatever that would mean. I had tried what you suggested. It actually worked â had I looked at the âold value â new valueâ in gray in the concatenation action. Instead I was looking at a Display Text Briefly that followed, which didnât display anything, so I thought there was a failure to concatenate. I still donât know why the text isnât displaying.
This is done for the next version. New functions that take text token processed strings and produce either the number of characters, words or lines in the resulting string, or the value of calculating the string
CALCULATE(%ICUDateTime%yyyy%+3) â Process Text Tokens and then calculate
CHARACTERS(%Variable%Text%) â Process Text Tokens and then count characters
WORDS(%Variable%Text%) â Process Text Tokens and then count words
LINES(%Variable%Text%) â Process Text Tokens and then count lines