Count() won't count 'Off'


#1

Ran across a string issue where the count() function won’t count the single word ‘Off’. Here is my simplified piston and logs:


#2

Here is a more expanded test:

You can see Off or off does not get counted but offf does.


#3

Good find, this probably applies to any of the special boolean strings in webCoRE like “not present” and “not pressed”. They probably get interpreted as a boolean false then coerced back to a string ending up as an empty “” string.

For your case, just prefix the text with something to break those special strings, like count ('off' + sList). If your sList is blank you’ll just count ‘off’ which we already know is zero but otherwise ‘offoff’ or ‘offnot present’ will not interfere with the count.


#4

Thanks. Interesting observation. I tested and sure enough, ‘false’, and ‘not present’ do not get counted but for some reason ‘not pressed’ does. I tried your suggestion for count but this only addresses if the first item is ‘off’. Anywhere else in the list still does not get counted. anyway, this was just a test and I can change the ‘off’ to ‘not on’ or ‘off now’ and it will work fine.

Here is a final test I did FYI.