122-32000 Parallax Inc, 122-32000 Datasheet - Page 257

MANUAL PROPELLER

122-32000

Manufacturer Part Number
122-32000
Description
MANUAL PROPELLER
Manufacturer
Parallax Inc
Datasheets

Specifications of 122-32000

Accessory Type
Manual
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
For Use With/related Products
Propeller Education (PE) Kit
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Decrement, pre- or post- ‘
The Decrement operator is a special, immediate operator that decrements a variable by one
and assigns the new value to that same variable. It can only be used in run-time variable
expressions. Decrement has two forms, pre-decrement and post-decrement, depending on
which side of the variable it appears on. The pre-decrement form appears to the left of a
variable and the post-decrement form appears to the right of a variable. This is extremely
useful in programming since there are many situations that call for the decrementing of a
variable right before or right after the use of that variable’s value. For example:
Y := --X + 2
The above shows the pre-decrement form; it means “decrement before providing the value for
the next operation”. It decrements the value of
that result to the rest of the expression. If
in
statement,
Y := X-- + 2
The above shows the post-decrement form; it means “decrement after providing the value for
the next operation”.
expression, then decrements the value of
in this example,
evaluated later, then would store 4 in
7, is stored into
Since Decrement is always an assignment operator, the rules of Intermediate Assignments
(see page 253) apply here. Assume
Y := --X + X
Here,
Y := X-- + X
Here,
decremented to 4, then 5 + 4 is evaluated and
Increment, pre- or post- ‘
The Increment operator is a special, immediate operator that increments a variable by one and
assigns the new value to that same variable. It can only be used in run-time variable
X
, then the expression, 4 + 2 is evaluated, finally writing the result, 6, into
X
X
’s current value, 5, is saved for the next operation (the Add) and
would first be set to 4, then 4 + 4 is evaluated and
X
equals 4 and
Y
. After this statement,
X--
would provide the current value for the expression (5 + 2) to be
It provides the current value of
Y
equals 6.
+ +
- -
X
X
started out as 5 for the following examples.
. The expression 5 + 2 is then evaluated and the result,
X
X
equals 4 and
X
started out as 5 in this example,
by one and writes that result to
Y
is set to 9.
X
by one, writes that result to
Y
equals 7.
Y
X
is set to 8.
for the next operation in the
Propeller Manual v1.0 · Page 257
X
--X
. If
X
would store 4
Y
and provides
X
. After this
began as 5
X
itself is

Related parts for 122-32000