# Variable

## What is a variable?

Think of a variable as a bucket. You can put values into it and remove values from it. To reference the variable, you must use its name.

{% hint style="info" %}
Keep in mind that variable values aren't saved, so when the app is closed, they get reset. You can use the [SharedPreference](https://wiki.sketchub.in/components/sharedpreference) block with a `ToStringWithoutDecimal` block to save their values.
{% endhint %}

## Different kinds of Variables

There are four different kinds of variables in Sketchware:

### Boolean

Booleans accept values like true and false

### Number

Number variables accept numbers

### String

String variables accept a string (text)

### Map

Map variables are for making maps with `key:value` pairs

## Blocks

### Set Boolean to

<div align="left"><img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-MV-Kbs8sOxhSzwwDPwd%2F-MV-LWka7jnuO0ORsMcs%2Fvariable_boolean_set_to.png?alt=media&#x26;token=0874adb7-db98-4b2a-a9a4-3f41acc51474" alt=""></div>

Sets a boolean variable to True or False

### Set Number to

<div align="left"><img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-MV-Kbs8sOxhSzwwDPwd%2F-MV-P8XVn8lMJ1hhu0Mm%2Fvariable_number_set_number_to.png?alt=media&#x26;token=7315979a-87f0-423c-b8b5-665d0537fed2" alt=""></div>

Sets a number variable to the specified value

### Increase 1

<div align="left"><img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-MV-Kbs8sOxhSzwwDPwd%2F-MV-PaouJyfuiBlxbXPR%2Fvariable_number_increase_1.png?alt=media&#x26;token=02cac0c5-7536-46c5-90ea-eeddeee5b432" alt=""></div>

Increases the number variable by 1

### Decrease 1

<div align="left"><img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-MV-Kbs8sOxhSzwwDPwd%2F-MV-Ptpkt85FH_CFyMMY%2Fvariable_number_decrease_1.png?alt=media&#x26;token=73192a9f-a073-47fc-9dae-66351adbd281" alt=""></div>

Decrease the number variable by 1

### Set string to

<div align="left"><img src="https://1589143646-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3AlXnP5kHENnvBXdKq%2F-MV-Kbs8sOxhSzwwDPwd%2F-MV-Q1kcsPNwS28a_lq6%2Fvariable_string_set_to.png?alt=media&#x26;token=27dda414-816b-4cfb-a905-a6c4bfce40ca" alt=""></div>

Sets a string variable to the specified value
