SPC  Version 0.9.5
 All Files Functions Groups Pages

Once declared, variables may be assigned the value of an expression using the syntax shown in the code sample below.

variable assign_operator expression;

There are eleven different assignment operators. The most basic operator, '=', simply assigns the value of the expression to the variable. The other operators modify the variable's value in some other way as shown in the table below.

=Set variable to expression
+=Add expression to variable
-=Subtract expression from variable
*=Multiple variable by expression
/=Divide variable by expression
%=Set variable to remainder after dividing by expression
&=Bitwise AND expression into variable
|=Bitwise OR expression into variable
^=Bitwise exclusive OR into variable
>>=Right shift variable by expression
<<=Left shift variable by expression

The code sample below shows a few of the different types of operators that you can use in SPC expressions.

x = 2; // set x to 2
y = 7; // set y to 7
x += y; // x is 9, y is still 7