Min Max limit code help reqd
Hi,
I would like BS2 code to ignore any values say between values -10 to +10
I have posted my code which appears to work below, but is this the correct way to go about this?
Thanks
' {$STAMP BS2}
' {$PBASIC 2.5}
' This code ignores any values between limits -10 to +10
x VAR Word
x = -9 'Change these test values
Main:
IF (x > -10) XOR (x < 10) THEN x = 0
DEBUG SDEC x,CR
GOTO Main
I would like BS2 code to ignore any values say between values -10 to +10
I have posted my code which appears to work below, but is this the correct way to go about this?
Thanks
' {$STAMP BS2}
' {$PBASIC 2.5}
' This code ignores any values between limits -10 to +10
x VAR Word
x = -9 'Change these test values
Main:
IF (x > -10) XOR (x < 10) THEN x = 0
DEBUG SDEC x,CR
GOTO Main
Comments
Welcome to the forum!
Your code will set x to zero if it's inside the interval (-10 .. 10), excluding -10 and 10. Is that what you want? If so, that's a very clever way to do it.
BTW, when posting code ...
-Phil
?
-Phil
I expect there must be several ways to do this.
I'll use the shorter version suggested.
Regards
Veitch
-Phil