Since updating to the latest release of Great Cow Basic v0.98.03, I am seeing this warning:
Warning: Comparison will fail if [variable] is any value other than 0 or 1
I assume this was always the case (that the comparison would fail) but I hadn't given it a whole lot of thought until I saw the warnings. When comparing the state of a pin with a variable I find it useful to store the 'idle' state of the pin in a variable so that I can then see if it has changed from the original value. I've been using byte variables for this (using bytes almost everywhere unless specifically needing a word or long) so the answer is to declare this variable of the type Bit. This does stop me from assigning a value of greater than one to indicate a 'starting' value and that the idle state should be tested.
Posting this as a reminder to myself as much as anything. Hopefully in a few months time when something stops working with this error I'll remember the answer. Perhaps it will help someone else too.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is a new feature within the compiler. We have a series of post when comparing values to bit. The feature resolves error that could occur. As you say using a BIT is the correct way forward.
:-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Since updating to the latest release of Great Cow Basic v0.98.03, I am seeing this warning:
Warning: Comparison will fail if [variable] is any value other than 0 or 1
I assume this was always the case (that the comparison would fail) but I hadn't given it a whole lot of thought until I saw the warnings. When comparing the state of a pin with a variable I find it useful to store the 'idle' state of the pin in a variable so that I can then see if it has changed from the original value. I've been using byte variables for this (using bytes almost everywhere unless specifically needing a word or long) so the answer is to declare this variable of the type Bit. This does stop me from assigning a value of greater than one to indicate a 'starting' value and that the idle state should be tested.
Posting this as a reminder to myself as much as anything. Hopefully in a few months time when something stops working with this error I'll remember the answer. Perhaps it will help someone else too.
This is a new feature within the compiler. We have a series of post when comparing values to bit. The feature resolves error that could occur. As you say using a BIT is the correct way forward.
:-)