Difference between revisions of "If"

Jump to navigation Jump to search
423 bytes added ,  09:51, 15 April 2006
added info about logical operators being unaffected by parenthesis
imported>Gblues
(Added overview, else/elseif/endif information)
imported>Gblues
(added info about logical operators being unaffected by parenthesis)
Line 65: Line 65:
| <nowiki>if x == 1 || y == 1 ; considered true unless both x and y equal 0.</nowiki>
| <nowiki>if x == 1 || y == 1 ; considered true unless both x and y equal 0.</nowiki>
|}
|}
Note that while multiple logical operators can be used, the operators are always evaluated from left to right regardless of parentheses. For example:
<nowiki>if myVar1 == 1 && (myVar2 == 1 || myVar2 == 5)</nowiki>
Logically, this should say "if myVar is 1 AND myVar2 is either 1 or 5..." but in Oblivion, this will be evaluated as "if myVar is 1 AND myVar2 is 1, or if myVar2 is 5, ..." (thanks MaXiMiUS and JOG for testing this)


== Comparisons and Expressions ==
== Comparisons and Expressions ==


The comparison operators can be used with any expression that can be evaluated into a number. Assuming "a = 17", "b = 20" and "c = a - b", all of the following expressions work as expected.  Parentheses are only needed when they're necessary for mathematical or logical reasons.
The comparison operators can be used with any expression that can be evaluated into a number. Assuming "a = 17", "b = 20" and "c = a - b", all of the following expressions work as expected.  Parentheses are only needed when they're necessary for mathematical reasons.


  IF c == -3 && b == 20
  IF c == -3 && b == 20
Anonymous user

Navigation menu