pxt-calliope/docs/reference/variables/change-var.md

41 lines
886 B
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# Change Value
2016-04-02 01:22:47 +02:00
Set the value for local and global variables.
2016-03-26 00:47:20 +01:00
### @parent blocks/change-value
Change the value of a variable
```blocks
let x = 0
x += 1
```
### Declare a variable
2016-04-13 17:27:45 +02:00
Use the assignment operator to set the value of a [variable](/reference/variables/var). Change the value of a variable from 0 to 1 using the change item block. Like this:
2016-03-26 00:47:20 +01:00
```blocks
let x = 0
x += 1
```
### Example
2016-04-13 17:27:45 +02:00
Use the assignment operator to set the value of a [variable](/reference/variables/var). Change the value of a variable from 0 to 1 using the change item block. Then display the new value of the variable on the LED screen. Like this:
2016-03-26 00:47:20 +01:00
```blocks
let x = 0;
x += 1;
basic.showNumber(x);
```
### Notes
2016-04-18 17:33:09 +02:00
* You can use the assignment operator with variables of each of the supported [types](/reference/types).
2016-03-26 00:47:20 +01:00
### See also
2016-04-18 17:33:09 +02:00
[variable](/reference/variables/var), [types](/reference/types)
2016-03-26 00:47:20 +01:00