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

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
Parameters and Local Variables
Parameters and local variables are all longs (four bytes). In fact, parameters are really just
variables that are initialized to the corresponding values specified by the caller of the method.
Local variables, however, are not initialized; they contain random data whenever the method
is called.
All parameters are passed into a method by value, not by reference, so any changes to the
parameters themselves are not reflected outside of the method. For example, if we called
MoveMotor
Pos := 250
MoveMotor(Pos, 100)
When the
parameter, and the value 100 in its
change
250.
If a variable must be altered by a routine, the caller must pass the variable by reference;
meaning it must pass the address of the variable instead of the value of the variable, and the
routine must treat that parameter as the address of a memory location in which to operate on.
The address of a variable, or other register-based symbol, can be retrieved by using the
Symbol Address operator, ‘
Pos := 250
MoveMotor(@Pos, 100)
The caller passed the address of
receives in its
just a number, like any other, so the
address, rather than a value. The
PosIndex := LONG[Position]
...to retrieve the value of the caller’s
LONG[Position] := <some expression>
...to modify the caller’s
Passing a value by reference with the Symbol Address operator is commonly used when
providing a string variable to a method. Since string variables are really just byte arrays,
Position
using a variable called
MoveMotor
Position
and
Speed
method is executed, it receives the value of
Pos
parameter is the address of the caller’s
@
variable, if necessary.
at any time, but the value of
’. For example,
MoveMotor
Pos
Pos
Pos
Speed
for the first parameter, it may look something like this:
for the first parameter to
MoveMotor
variable, and something like:
parameter. Inside the
method then must use something like:
4: Spin Language Reference –
method must be designed to treat it as an
Pos
(the caller’s variable) remains at
Propeller Manual v1.0 · Page 289
MoveMotor
Pos
MoveMotor
variable. The address is
Pos
. What
in its
method, it can
MoveMotor
Position

Related parts for 122-32000