Question about %TriggerValue[0]%

I'm confused, which is very normal. The %TriggerValue% token can accept a number in brackets like %TriggerValue[1]% but the value %TriggerValue[0]% returns a 1 even when %TriggerValue[1]% is empty. Isn't the normal purpose of an "index of 0" to return the number of items it contains, like KM does for numeric arrays? Since it doesn't mean "number of items" here, what does it mean?

I couldn't find the answer here:

https://wiki.keyboardmaestro.com/token/TriggerValue "You can easily access the individual parts using the token array notation"
https://wiki.keyboardmaestro.com/manual/Calculations "If the index is 0, the size of the array is returned"

Correct. An empty string is an empty string, and when treated as an array, since it has no separator (comma in this case), it is an array of one item, that item being an empty string.

1 Like