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.

Can the condition of a Flag be evaluated in an IF statement


alackey May 14, 2023 12:55 PM

I want to increment a counter by 1 only after a tank has filled to the high level H_lvl and empties below the L_lvl.

'When tank is full set Port 3 and Flag 3 to 1 to energize dump valve

If L_lvl > 0 AND H_lvl > 0 Then
PortSet (3,1 )
Flag(3) = 1
EndIf


'When tank is empty de-energize Dump valve
If L_lvl = 0 Then
PortSet (3,0 )
Flag(3) = 0
EndIf

Port 3 and Flag(3) clear as expected when the tank is empty

 'When tank is empty de-energize valve relay
If L_lvl = 0 AND Flag(3) = 1 Then
PortSet (3,0 )
Flag(3) = 0
EndIf

Port 3 and Flag(3) do not toggle as expected


Dana May 15, 2023 11:17 PM

I would review the code and ensure that these two conditions are True at the same time when the expression is evaluated.

If L_lvl = 0 AND Flag(3) = 1 Then

I am assuming that L_lvl is a measurement/variable being read, but how is Flag(3) set? That is where I would start troubleshooting. 

Dana W. 


alackey May 24, 2023 11:25 AM

Thank you

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