mr.peanut 1 Posted June 12, 2007 Why is there no XOR in ArmA?! I don't wanna have to ((A AND NOT B) OR (B AND NOT A)) ... Use 5 ops instead of 1 ? I think I'm gonna be sick! Share this post Link to post Share on other sites
hardrock 1 Posted June 13, 2007 Well, apparently that's the way it currently is ... XOR isn't that widely used anyway. Share this post Link to post Share on other sites
raedor 8 Posted June 13, 2007 If you need it often, write a function... so you don't have to type that much at least. Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted June 13, 2007 There's better ways than xor. Always has been and always will be. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if (ConditionA xor ConditionB) then { Dostuff }; Can be easilly achieved like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Myroutine = { DoStuff }; If (ConditionA) Then { if (Not ConditionB) then { ExecVM Myroutine[] }; } Else { if (ConditionB) then { ExecVM Myroutine[] }; }; There's more typing like that, but it's an easier debug than trying to locate that little x (or lack of an x) in a 5000 line script. Share this post Link to post Share on other sites
crashdome 3 Posted June 13, 2007 Also, just because it is one command doesn't mean it is one operation. You are executing the same number regardless. Share this post Link to post Share on other sites
mr.peanut 1 Posted June 13, 2007 Urp! Didn't realize it took 5 ops to construct an XOR. For some reason I thought  it was a single binary op. @CSL: your logic doesn't look quite right to me... Yours looks like a short-circuit <s>AND</s> OR Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted June 13, 2007 I assure you, it's correct: If this, do this Else if that, do that You can also tack a neither onto there too: If this, do this Else if that, do that Else, do something else Edit: A short circut and looks like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> If (ConditionA) Then { if (ConditionB) then { DoStuff }; }; Edit again: You know, I haven't tested if arma's scripting engine is smart enough to automatically short circut compount conditional operators. I tested it in ofp way back when, and it wasn't. Now you got me thinking though... Share this post Link to post Share on other sites
mr.peanut 1 Posted June 13, 2007 In your XOR snippet the code is executed if A is true regardless of the value of B. How is that XOR? At second glance, your code is a short circuit OR. Share this post Link to post Share on other sites
kegetys 2 Posted June 13, 2007 This should work: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if({_x}count[A, B] == 1) then { Â Â // true } else { Â Â // false }; Share this post Link to post Share on other sites
raedor 8 Posted June 13, 2007 This should work:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if({_x}count[A, B] == 1) then { // true } else { // false }; As always... Share this post Link to post Share on other sites
mr.peanut 1 Posted June 13, 2007 Yet another WTFDITOT(Why The Fork Didn't I Think Of That?) from Keg. Answer: BITFS(Because I'm Too Forkin Stewpid) Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted June 14, 2007 In your XOR snippet the code is executed if A is true regardless of the value of B. How is that XOR?At second glance, your code is a short circuit OR. Whoops, you're right. Corrected: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Myroutine = { DoStuff }; If (ConditionA) Then { if (Not ConditionB) then { ExecVM Myroutine[] }; } Else { if (ConditionB) then { ExecVM Myroutine[] }; }; Share this post Link to post Share on other sites
hardrock 1 Posted June 14, 2007 Which is then exactly the same as <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if((A && !B) || (!A && B)) then { execVM ... } Thumbs up Keg! Nice solution! Share this post Link to post Share on other sites