How do you write an if statement for # range going up verse going down
sam_sam_sam
Posts: 2,286
I know to write an IF statement for range of #
Like
IF range >150 TO range < 300 THEN do something
_____________________________________________________________
Example 150 to 300 I only want the IF to be TRUE if value is going UP
how do write an IF statement one if you want it do something when the value is going up but not down
_______________________________________________________________
Example 300 to 150 I only want the IF to be TRUE if value is going DOWN
Then write an IF statement one if you want it do something when the value is going down but not going up
Would something like this work
IF Present_Reading > last_Reading + 1 THEN do something ' " value going UP "
IF Present_Reading < last Reading - 1 THEN do something ' " value going down "
Like
IF range >150 TO range < 300 THEN do something
_____________________________________________________________
Example 150 to 300 I only want the IF to be TRUE if value is going UP
how do write an IF statement one if you want it do something when the value is going up but not down
_______________________________________________________________
Example 300 to 150 I only want the IF to be TRUE if value is going DOWN
Then write an IF statement one if you want it do something when the value is going down but not going up
Would something like this work
IF Present_Reading > last_Reading + 1 THEN do something ' " value going UP "
IF Present_Reading < last Reading - 1 THEN do something ' " value going down "
Comments
Rich H
...
...
...
oldvalue=newvalue
return
THANKS to erco and W9GFO for your :idea:
checking:
DO
IF result0 = 0 OR result0 > 2070 THEN EXIT
IF result0 < 890 OR result0 > 2070 THEN EXIT
>>
>> Code in side
>>
IF result0 < 890 OR result0 > 2070 THEN GOTO checking
IF result1 <> Last_result0 THEN GOSUB OldReading ' This line reset Reading in RAM on power up
IF result0 > result1 + 2 THEN 'Stamp Value Going UP
GOSUB OldReading
' IF result0 < result1 - 2 THEN ' Stamp Value Going DOWN
' GOSUB OldReading
' ENDIF
ENDIF
PAUSE 100
LOOP
RETURN