pxt-calliope/docs/reference/types/string.md
Thomas Denney bb97b57b01 Correct typo in string documentation
Note that currently you can't follow through with these instructions because string literals aren't supported, and there isn't support for converting the JS in this doc.
2016-07-19 09:25:48 +01:00

46 lines
1.3 KiB
Markdown

# String
a piece of text.
### @parent blocks/language
A *String* is a sequence of characters. For the BBC micro:bit, ASCII character codes 32 to 126 are supported; letters, digits, punctuation marks, and a few symbols. All other character codes appear as a ? on the [LED screen](/device/screen).
### Create a string variable
```block
salutation = "Hello";
```
To create a variable that holds a string:
1. Click `Variables` (in the Block drawer).
2. Type a name for your new string variable by clicking the down arrow, then click New Variable. Then type the variable name "salutation"
2. Drag a string block on the right side of the operator.
3. Click `"Hello"` and then type a string like `hello`.
Your code should look something like this:
```block
salutation = "Hello";
```
### The function `show string`
Use [show string](/reference/basic/show-string) to display a string on the [LED screen](/device/screen).
If the string is multiple characters, the string scrolls right to left. The following example displays `Hello world!` on the micro:bit screen:
```block
basic.showString("Hello world!");
```
The parameter of `show string` specifies the string
### See also
[string functions](/reference/types/string-functions), [Number](/reference/types/number), [show string](/reference/basic/show-string)