Apple WebObjects 3.5 User Manual
Page 176

Chapter 10
The WebScript Language
176
Control-Flow Statements
WebScript supports the following control-flow statements:
if
else
for
while
break
continue
return
Arithmetic Operators
WebScript supports the arithmetic operators +, - , /, *, and %. The rules of
precedence in WebScript are the same as those for the C language. You can use
these operators in compound statements such as:
b = (1.0 + 3.23546) + (((1.0 * 2.3445) + 0.45 + 0.65) - 3.2);
Logical Operators
WebScript supports the negation (!), AND (&&), and OR (||) logical operators.
For the most part, you can use these operators as you would in the C language,
for example:
if ( !(!a || a && !i) || (a && b) && (c || !a && (b+3)) ) i = 0;
WebScript handles logical operators slightly differently from C. In C, Boolean
expressions short-circuit. For example, in this statement:
(!a || (a && !i))
In C, an expression is only evaluated up to the point where the outcome can be
surmised. That is, if
!a
is true, the other side of the || expression is not evaluated
because the || operator only requires one side of the statement to be true.
Likewise, if the && statement is evaluated and
a
is false, the second half of the
&& expression is not evaluated because the && operator does require both
sides to be true.
In WebScript, Boolean expressions never short-circuit. The entire expression is
always evaluated.
Relational Operators
WebScript supports the relational operators <, <=, >, >=, ==, and !=.
In WebScript these operators behave as they do in C.