Browse the docs

kmLength

Returns the length of text, the items in a list or the keys in a record.

Keyboard Maestro: LENGTH

Details #

kmLength() or kmLength(value) takes zero or one argument and returns a number.

A list gives its item count, a record its key count, and anything else its text length in characters. With no argument it measures the variable kmText, or empty text (0) if that isn't set.

Parameters #

Takes 0 to 1 argument. {{ kmLength(text?) }}

Examples #

kmLength("héllo")
→ 5
kmLength(items)
→ 3
Sample variableValue
items[1, 2, 3]

Gotchas #

  • Unlike length, nothing (null) isn't special-cased: it counts its text, which is empty, so 0.

  • Keyboard Maestro's LENGTH() with no argument measures the text the action works on; here it reads kmText.