In SX Microcontrollers, SX/B Compiler and SX-Key Tool, PJMonty wrote: Keith, Actually your answer has a potential subtle bug in it - If both conditions happen to be true at the same time, then "somesubroutine" will get executed twice. If you want to prevent this possibility and SX/B won't allow an OR, the better solution is something like this: [code]ConditionMet = 0 If X = 1 then ConditionMet = 1 If P = 7 then Condition Met = 1 If ConditionMet = 1 then Somesubroutine[/code] By using a separate flag to see if either (or both) conditions are met, you can then check the flag and call the subroutine exactly once. This exactly meets the definition of the OR truth table which looks like this: [code]0 or 0 = 0 0 or 1 = 1 1 or 0 = 1 1 or 1 = 1[/code] This technique can also be extended to have as many conditional checks as you like. You just have to make sure the flag is cleared before the first conditional check so it is in a known state. You definitely do [b]not[/b] want to do this: [code] if X = 1 then ConditionMet = 1 else ConditionMet = 0 if P = 7 then ConditionMet = 1 else ConditionMet = 0[/code] ...or else you end up turning the flag off unless both "If/Then" checks are true, or if only the second condition is true. Not the same results at all. [list]Thanks, PeterM[/list] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=156195#m156211 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)