‎10-08-2020 02:59 AM
I can't believe I have to ask about this, but I am so confused why it doesn't work. It should be simple.
FileGlobal.ProductID = "07"
This is a string.
Why then, does this expression evaluate to True?
FileGlobals.ProductID == "01" || "02"
In order to debug, I made a Pass/fail step with it's Data Source expression set to:
(FileGlobals.ProductID == "01" || "02") ? (Step.Result.PassFail = True) : (Step.Result.PassFail = False)
This also evaluates to True.
I want it to be True for "01" or "02", but not for "03" etc...
Solved! Go to Solution.
‎10-08-2020
04:00 AM
- last edited on
‎11-04-2024
11:58 AM
by
Content Cleaner
I found this in the expression builder for "logical or":
String operands are converted to True if the text [...] contains the representation of a non-zero number, False otherwise.
This seems like odd behavior to me, but I'll just have to work around it. I didn't know this.
I'm trying to use StrComp(), but I can't make heads or tails of the documentation here:
"A number less than 0 if the first string is less than the second. A number greater than 0 if the first string is greater than the second. 0 if the strings are equal."
What does it mean for a string to be great than another string? Mathematically?
StrComp("Buddy","Budgy") evaluates to -1
StrComp("Budgy","Buddy") evaluates to 1
I don't understand the logic here.
If anybody can shed some light on this for me, it would be appreciated! I've decided to solve it in LabVIEW instead. What I want is a TestStand expression like this: StringsMatch("01","01") evaluating to True (boolean)
‎10-08-2020 06:45 AM - edited ‎10-08-2020 06:48 AM
FileGlobals.ProductID == "01" || FileGlobals.ProductID == "02"
🙂
The problem with "FileGlobals.ProductID == "01" || "02"" is that you're actually checking here if:
(FileGlobals.ProductID == "01" is TRUE) OR ("02" is TRUE)
While the first part is false (because FileGlobals.ProductID is actually "07"), the second part is true ("02" converts to boolean as TRUE) which results in TRUE as the "OR" result
‎10-08-2020 06:47 AM
Holy cow I spent a lot of time on this. And it was that simple... Thanks Mateusz!!
‎10-08-2020 06:53 AM
Glad I could help 🙂
‎10-08-2020 10:28 AM
Yes, I see you added more to your answer. After you posted your answer I understood the same thing as you described it.