Jump to content
Sign in to follow this  

Recommended Posts

Why is there no XOR in ArmA?! I don't wanna have to ((A AND NOT B) OR (B AND NOT A)) ... mad_o.gif Use 5 ops instead of 1 ? I think I'm gonna be sick!

Share this post


Link to post
Share on other sites

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

If you need it often, write a function... so you don't have to type that much at least. smile_o.gif

Share this post


Link to post
Share on other sites

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

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

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

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

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

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
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... thumbs-up.gifbiggrin_o.gif

Share this post


Link to post
Share on other sites

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
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

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 ...

}

wink_o.gif

Thumbs up Keg! Nice solution! smile_o.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×