Quote:
Originally posted by Joseph F
...
This may work. I'm not exactly sure about negations in pbasic. It could end up attempting to put in a negative... Use it at your own risk.
...
|
Uhhh.... that's not a negative sign (unary operator). That's a tilde (inverse operator).
Say you have a value of 0 (binary 00000000). The inverse sign inverses all the bits to 255 (11111111). Simplest way of doing it.
Example: 00010100 = ~11101011
Same concept for toggling relays....
Example:
relay_solenoid var bit
relay_solenoid = 0 'solenoid should be deactivated
relay_solenoid = ~relay_solenoid ' toggle the solenoid state
This code is simpler than using if-then statements to check the current state of the bit. All you're doing is altering it.
Suggestion is to read the stamp manual. I did and I learned more than I ever wanted to know about the PBASIC programming language. Just head over to
The PBASIC programming manual and check it out. Be careful, it's 2 mb.