WMLScript provides four operators as a conveniently short form for the common task of adding or subtracting one from a variable.
The preincrement and predecrement operators, written as:
++var
and:
var
respectively, each attempt to convert the contents of the variable to
an integer or floatingpoint value, add one to it
(++
) or subtract one from it
(
), and store it back into the variable. The
result of the operator is the new value of the
variable.
The postincrement and postdecrement operators, written as:
var++
and:
var
respectively, behave slightly differently. They still change the value of the variable, but the result of the operator is the value of the variable before the change.
For example, suppose that variable a
contains the
value integer 42
, b
contains
integer 0x7FFFFFFF
(the largest valid positive
integer value), c
contains floatingpoint
2.3
, d
contains string
"1e2"
, and e
contains string
"foo"
:
a++ gives integer 42 and sets a to integer 43

++a gives integer 43 and sets a to integer 43

a gives integer 42 and sets a to integer 41

a gives integer 41 and sets a to integer 41

b++ gives integer 0x7FFFFFFF and sets b to invalid (overflow) 
++b gives invalid and sets b to invalid (overflow again) 
c++ gives floatingpoint 2.3 and sets c to floatingpoint 3.3

c gives floatingpoint 1.3 and sets c to floatingpoint 1.3

d gives string "1e2" and sets d to floatingpoint 99.0

++d gives floatingpoint 101.0 and sets d to floatingpoint ... 
No credit card required