Welcome, Guest
Username: Password: Remember me

TOPIC: Tag Value Comparison

Tag Value Comparison 9 months 2 weeks ago #1708

  • arifcorp
  • arifcorp's Avatar
  • Offline
  • Senior Member
  • Posts: 46
  • Karma: 0
Hi Ruslan,


I have 2 Tags. Assume A and B which both are booleans

I cannot do this

If (Tags.A == Tags.B)
{
print("same");
}

It return the following error
Unsupported mathematical operation for Boolean

Any method to compare the Boolean Tags

Thanks
The administrator has disabled public write access.

Tag Value Comparison 9 months 2 weeks ago #1710

  • fatkhrus
  • fatkhrus's Avatar
  • Offline
  • Administrator
  • Posts: 643
  • Thank you received: 98
  • Karma: -114
Hello,

No, it's not possible to compare boolean tags in this way. You can cast these values into byte. And compare them:
byte a = Tags.A;
byte b = Tags.B;
if (a==b){
print("same");
}

Or use XOR operator:
if (Tags.A ^ Tags.B){
print ("not same");
}
else{
print("same");
}

Best regards,
Ruslan
The administrator has disabled public write access.
Go to top