pxt-calliope/docs/blocks/on-start.md
Peli de Halleux 92b60a251d On start support (#324)
* annotating APIs to support onstart

* missed file

* updated templates

* adding new lines in main.ts

* fixing docs

* removing onstart

* updated docs

* updated various docs

* more docs

* adding upgrade policies for blocks

* updated pxt reference

* placing on start under "basic"
2016-12-19 14:09:35 -08:00

23 lines
570 B
Markdown

# On Start
An event that runs when the program starts.
The ``on start`` is a special event that runs when the program starts, before any other event.
Use this event to initialize your program.
## Example
In this example, ``on start`` sets a dimmer brightness on the screen and the button handler shows a string.
```blocks
input.onButtonPressed(Button.A, () => {
basic.showString("Hello!")
})
led.setBrightness(50)
```
## What about JavaScript?
``on-start`` only exists in the block editor. In JavaScript, all code executes sequentially from the first line.