adding control blocks

This commit is contained in:
Peli de Halleux
2016-03-25 21:13:09 -07:00
parent d14f977b85
commit c25049ee5f
3 changed files with 9 additions and 6 deletions

View File

@ -2,7 +2,7 @@
Run code in the background as a separate process or thread; for more information on this advanced construct, see [the micro:bit - a reactive system](/microbit/device/reactive).
```
```sig
control.inBackground(() => {
})
```
@ -11,7 +11,7 @@ control.inBackground(() => {
The example below shows how a background process can be used to display the current value of the global variable `num`, while code (like the `on button pressed` handler) can change the value of the variable.
```
```blocks
let num = 0
control.inBackground(() => {
while (true) {
@ -26,7 +26,7 @@ input.onButtonPressed("A", () => {
The code below using the `forever` loop is equivalent to the code above
```
```blocks
let num = 0
basic.forever(() => {
basic.showNumber(num, 150)
@ -40,7 +40,7 @@ input.onButtonPressed("A", () => {
If you have multiple processes that each show something on the LED screen, you may get unexpected results. Try, for example:
```
```blocks
basic.forever(() => {
basic.showNumber(6789, 150)
})