I see there are many string operators for conditions, but I can’t find an operator to check for string length. Why do I want this? There’s a string that contains a Precipitation type… I just want to know if there’s precipitation of any type…of not the string is empty. If there’s some precipitation, it will have some other value like rain or snow or hail or maybe something else. I don’t want to check for these all,I just want to see if the string is empty or not,
Expressions should work for this.
This is only an example and not a functional cut and paste, it’s just to give you an idea of how this can be done. I’m not sure what your precipitation data looks consists of, but for this example if your just checking length:
In expressions create a new Expression/Variable for your precipitation data.
Name the variable “myData”
Build the expression to populate that variable with your precipitation data. You can use the expression builder for this. To the right of the field between the icons of the running person and the “X” there is an icon of a box within a box. Select that and it will present you with an expression builder. It should be self explanatory. Build the expression and then click “Insert”. Then save. This variable should now hold your precipitation data.
Create a second variable in expressions
Name your second variable “myResult”
In the expressions field type “len(myData) > 0” (no double quotes)
This will test the length of your precipitation data which should at this point be the value of the “myData” variable and return TRUE if it is greater than 0.
The above will set “myResult” to TRUE if the length of “myData” is > 0
Create a Condition, select “Expression Value” from the drop down.
Select myResult from the dropdown
Select is TRUE from the drop down.
In actions create the desired activity.
You will need to modify the above to fit your needs by changing the operator after len() and the like.
In “Status” you can see these variables and their current states.
Hope this helps.
Ahh ok I didn’t think of making an expression for this. It would be nice to just have a condition for string length or at least “hasLength” or similar to simplify things hiwever.
Can you not set the condition to -
expression value - name of variable - equals or not equal - leave value blank.
If you happen to have an Expression that equates to null (or ‘empty’) such as:
testList := [ ]
…and wish to test it, I believe the preferred approach, using Conditions, would be:
Expression Value: testList is NULL
The alternative, mentioned above, of using another Expression:
testLen := len(testList)
and then checking this variable for value 0 is also valid.
I don’t know, in many many languages a null and empty string are not the same.
Is that the case here?
It would just be so mush easier to have a condition that doesn’t use an expression that just rests a string length. If the string is bull or empty, it returns 0
I tested with an emty expression variable and one with a string.
It worked for me, equal empty was true when the when the variable was empty. and false when a string.
When used in string context,
null is coerced to the empty string, so if you use the equals or not equals operator against a
null, it will compare like the empty string ("").
There is an is NULL operator in the Expression Value condition specifically for testing for