or: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) |
Lou Montana (talk | contribs) m (Fix Category:Pages using duplicate arguments in template calls and examples) |
||
Line 7: | Line 7: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| Returns [[true]] | | Returns [[true]] if one or both conditions are [[true]]. In case of the alternative syntax, [http://en.wikipedia.org/wiki/Lazy_evaluation#Control_structures lazy evaluation] is used (if left operand is [[true]], evaluation of the right side is skipped completely). | ||
Identical to | {{Informative | Identical to [[a or b|a || b]].}} |DESCRIPTION= | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| [[ | | a [[or]] b |SYNTAX= | ||
|p1= a: [[Boolean]] - | |||
|p2= b: [[Boolean]] - | |p1= a: [[Boolean]] - test condition or variable |PARAMETER1= | ||
|p2= b: [[Boolean]] - test condition or variable |PARAMETER2= | |||
| [[Boolean]] |RETURNVALUE= | | [[Boolean]] |RETURNVALUE= | ||
____________________________________________________________________________________________ | |||
|s2= a [[or]] b (''Since Arma 2:OA v1.62'') |SYNTAX2= | |||
|p21= a: [[Boolean]] - test condition or variable |PARAMETER21= | |||
| | |p22= b: [[Code]] - code that returns [[Boolean]]; it is not evaluated if ''a'' returns [[true]] |PARAMETER22= | ||
|r2= [[Boolean]] |RETURNVALUE2= | |||
____________________________________________________________________________________________ | |||
|r2= [[Boolean]] |RETURNVALUE2=____________________________________________________________________________________________ | |||
|x1= <code>[[if]] ( | |x1= <code>[[if]] (_obj1 [[or]] (_enemycount [[==]] 0) [[or]] ([[not]] [[alive]] _enemyGeneral)) [[then]] { [[hint]] "you win !"; };</code> |EXAMPLE1= | ||
|x2= <code>[[if]] (([[count]] _array [[==]] 0) [[or]] {(_array [[select]] 0) [[!=]] [[player]]}) [[then]] {[[hint]] "It works! | |||
|x2= <code>{{cc|without lazy evaluation [[select]] would throw an error if array was empty}} | |||
[[if]] (([[count]] _array [[==]] 0) [[or]] { (_array [[select]] 0) [[!=]] [[player]] }) [[then]] { | |||
[[hint]] "It works!"; | |||
};</code> |EXAMPLE2= | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| [[a or b|a | | [[a or b|a || b]], [[and]], [[Operators]]|SEEALSO= | ||
|mp= | |mp= |MP= | ||
}} | }} | ||
Line 42: | Line 51: | ||
<h3 style="display:none">Bottom Section</h3> | <h3 style="display:none">Bottom Section</h3> | ||
[[Category:Scripting Commands| | [[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting Commands OFP 1.46|{{uc:{{PAGENAME}}}}]] | |||
[[Category:Scripting Commands OFP 1.96|{{uc:{{PAGENAME}}}}]] | |||
[[Category:Scripting Commands OFP 1.99|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands OFP 1.99|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting Commands | [[Category:Scripting Commands ArmA|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]] | ||
Revision as of 13:15, 24 September 2019
Description
- Description:
- Returns true if one or both conditions are true. In case of the alternative syntax, lazy evaluation is used (if left operand is true, evaluation of the right side is skipped completely).
- Groups:
- Uncategorised
Syntax
- Syntax:
- a or b
- Parameters:
- a: Boolean - test condition or variable
- b: Boolean - test condition or variable
- Return Value:
- Boolean
Alternative Syntax
- Syntax:
- a or b (Since Arma 2:OA v1.62)
- Parameters:
- a: Boolean - test condition or variable
- b: Code - code that returns Boolean; it is not evaluated if a returns true
- Return Value:
- Boolean
Examples
- Example 1:
if (_obj1 or (_enemycount == 0) or (not alive _enemyGeneral)) then { hint "you win !"; };
- Example 2:
// without lazy evaluation select would throw an error if array was empty if ((count _array == 0) or { (_array select 0) != player }) then { hint "It works!"; };
Additional Information
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Notes
Bottom Section
Categories:
- Scripting Commands
- Introduced with Operation Flashpoint version 1.00
- Operation Flashpoint: New Scripting Commands
- Operation Flashpoint: Scripting Commands
- Command Group: Uncategorised
- Scripting Commands OFP 1.46
- Scripting Commands OFP 1.96
- Scripting Commands OFP 1.99
- Scripting Commands ArmA
- Scripting Commands ArmA2
- Scripting Commands Arma 3
- Scripting Commands Take On Helicopters