OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Mandoble on 06 Jul 2007, 12:33:16

Title: defined || undefined
Post by: Mandoble on 06 Jul 2007, 12:33:16
Take care of that, as these sentences will return false always:

_a = true
?_a || _b: hint "at least one of them is true"

You will never get the hint as _b is undefined.

_a = true
_b = false
?_a || _b: hint "at least one of them is true"

This time you will get the hint.
Title: Re: defined || undefined
Post by: Mr.Peanut on 06 Jul 2007, 15:24:09
That is why we need short circuit and and or in ArmA, a suggestion I made on the BI forums...
Kegety did post a workaround for xor:
Code: [Select]
if({_x}count[A, B] == 1) then {
   // true
} else {
   // false
};

Would the following work for your case i.e. _a and _b possibly undefined?:
Code: [Select]
if  ({_x} count [_a,_b] > 0) ...