In games, you sometimes need a switch that tells whether something is in the on or off state. Each variable acts as a Boolean, meaning the value indicates either true or false. A false value is zero while a true value is anything else. So, you just need to check to see if the value of the variable is zero:
If not(X // Check if the flag variable is zero
Because the X variable can be either true or false, you have the switch built-in for you. Naturally you'll want to change the value of the switch from active to inactive or vice-versa when a certain condition happens, and you can do that by simply using the not( operator:
not(X→X // Flip the value of the flag variable
not(not(X // Will make any value X into 1 if it's not 0, and will keep it 0 if it is
As with all things programming, the best way to learn and understand something is to actually try it out and experiment.