Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Detect boolean state change


Snohomish County SWM Mar 6, 2023 06:47 PM

Is there a built in function to test if a boolean has changed states? I could always record the state of a boolean and compare the last value to the current value and then update the last value to the current value but am interested in knowing whether a built-in function to handle this scenario.


JDavis Mar 6, 2023 08:22 PM

I think what you described is the way to handle it. Have a second variable to store the previous state. Check if current value is not equal to previous value.


hanajijang Jan 22, 2024 03:32 AM

This post is under review.


Snohomish County SWM Apr 24, 2024 02:48 PM

Responding to oilumiun12, I used JDavis' suggestion. The following code triggers an event only if the a change in boolean status is detected.

'Detect change in ForceModemOn flag and set CELL210 power state accordingly
If ForceModemOn<>ForceModemPrevious Then
If ForceModemOn=True
CELL210_PowerUp
Else
CELL210_PowerDown
EndIf
ForceModemPrevious=ForceModemOn
EndIf

Log in or register to post/reply in the forum.