Can't use if Label1.TextColour=<Colour>, it will just jump to else for any result





Everytime I try and it will just jump to else instead of then.

Connect companion and use Do it to debug your your blocks. See how

Animation1

Export your .aia file and upload it here.
export_and_upload_aia

How do we know if you are using the same text color in the place you set the Label.TextColor as you use in your tests?

The Logic Block doesn't understand colours in that way. What you can do is break the colours down to their Red, Green, Blue values (numbers)

Sorry Ken, from TimAI2's tests I see that the Logic of your code should work as-is. Perhaps it actually is working correctly, are you sure all four Labels have the exact same text colour?

There appear to be @ 12 labels, interspersed with ands and ors. This is likely to be the issue.

Ken, If you upload your Project File, we might be able to suggest a more efficient and reliable way to meet your requirement.

okay, actually this problem not only in ai2, I even tried it at Visual Studio as well.

st1.aia (658.3 KB)

appears to work just fine with some debugging in companion....

image

image

But idk why the code of mine can still not use the result "then", it use "else"

Capture
Notice the different numbers for green colors used when you set the text color versus when you test the text color.

You made several mistakes in this app:

  • You did not set aside constant global variables RED, YELLOW, GREEN with your color choices, to be referenced in both the assignments and the tests
  • You used a rubber stamp instead of parametrized procedures, proliferating your mistakes all over your app instead of concentrating them in a single procedure.
  • You did not use a table of Labels to help loop through your labels by index
  • You used Label2 and Label3 instead of appropriately named LblMoveNumber and LblRemainingMoves, abusing the time of people who would have otherwise had more time to examine your code more closely

See this sample app for how to do this type of game without a rubber stamp:

3 Likes