11.2. WMLScript
Assignment Operators  Assigning Values to Variables
Assignment
operators are used to assign a value to a variable. One of the
assignment operators, =, has been used many times earlier in this
WMLScript tutorial. Its usage is very straightforward and there is
nothing to explain further. Here is an example:
z
= 18;
The
z variable contains the value 18 after execution.
WMLScript
supports a number of shortcut operators that combine arithmetic
operations with value assignment operations. Below is an example of
the += operator:
var
z = 1; z += 2;
After
executing the above script, z contains the value 3. "z += 2;"
is equivalent to "z = z + 2;".
Below
is an example of the = operator:
var
z = 5; z = 3;
After
execution, z contains the value 2. The line "z = 3;" is
equivalent to "z = z – 3;".
The
following table summarizes the shortcut assignment operators
available in WMLScript:
WMLScript
Operator

Example

Equivalent
to

+=

x
+= y;

x
= x + y;

=

x
= y;

x
= x  y;

*=

x
*= y;

x
= x * y;

/=

x
/= y;

x
= x / y;

div=

x
div= y;

x
= x div y;

%=

x
%= y;

x
= x % y;

&=

x
&= y;

x
= x & y;

=

x
= y;

x
= x  y;

^=

x
^= y;

x
= x ^ y;

<<=

x
<<= y;

x
= x << y;

>>=

X
>>= y;

x
= x >> y;

>>>=

x
>>>= y;

x
= x >>> y;

Feedback Form (ExpandCollapse)

