Found the answers to most of my problems here but this one has got me stumped.
I'm incrementing and decrementing a byte using buttons on a 12 button keypad. The values in the byte need to be limited to a range of 0-99. If I use the following...
then the increment is fine and dandy but the decrement wraps round from 0 to 255 rather than sticking at 0
If I use...
everything works perfectly (at the cost of a couple of extra bytes of space)
So is that the way the min function is meant to work? Does it not work for at zero or have I got my syntax mixed up somewhere?
Using a 28X2 and a AXE033 LCD for display
I'm incrementing and decrementing a byte using buttons on a 12 button keypad. The values in the byte need to be limited to a range of 0-99. If I use the following...
Code:
select key_value
case = 1
let b0 = b0 + 1 max 99
goto Store_and_set
case = 7
let b0 = b0 - 1 min 0
goto Store_and_set
endselect
If I use...
Code:
select key_value
case = 1
let b0 = b0 + 1 max 99
goto Store_and_set
case = 7
if b0 > 0 then dec b0 endif
goto Store_and_set
endselect
So is that the way the min function is meant to work? Does it not work for at zero or have I got my syntax mixed up somewhere?
Using a 28X2 and a AXE033 LCD for display