by Herman Semin
Version 1 (October 12, 2019)
Download (1,084 downloads)
Difficulty: easy (simple functions, 2 block/flow beginning)
Determine automate variable type with JSON encoding.
:: DISCLAMER ::
This is just a tutorial flow. I've used Variable Set's just to make explanation easier. More blocks = easier to understand how flow works.
So, since automate may be considered a scripting language (even though it's not really language), which is using dynamic typing, there has to be a way to check variable's type... Well, here's my solution.
Explanations (they are analogical for the other flow beginnings)
1. You set your variable in "Variable Set" (Block #3)
2. You cast json encoded value to string, then match it against integer-specific regular expression (string can only contain digits)
3. Result of regular expression matching is cast to boolean with double negation, so if variable type is integer, it returns 1, 0 otherwise.
Rate and review within the app in the Community section.