Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Variable types
- Slam-
-
100+ posts
Variable types
Do they even exist? If so, how scratch decides which variable should be boolean or integer?
- SpaceExplorerPro
-
100+ posts
Variable types
Do you have a project that uses something associated with this? If so please provide a link.
- Slam-
-
100+ posts
Variable types
No, i dont have. Do you have a project that uses something associated with this? If so please provide a link.
- bgvikings08
-
100+ posts
Variable types
Some blocks like blocks with the orange color have a changeable integer. Blocks like ‘Costume name’ can contain names. Lists are a good way to make you own variable with things other than integers stored.
- legendary34678
-
1000+ posts
Variable types
Hello! The variables that Scratch uses can store characters (so letters as well as numbers). I don't think boolean variables exist, but you can set a variable to true/false or 0/1 and then check if that variable is a certain value to mimic a boolean.
- MaybeARandomFox
-
100+ posts
Variable types
Ok so briefly this is everything about it Do they even exist? If so, how scratch decides which variable should be boolean or integer?
Creatable variables:
- Creatable variables are universal
You can put it into a logical operation like this:
But if its a prompt then
for numbers
for logical operations like:
selectable prompt probably text
variable selector.
So these are the types of variables.

- CustomBlockMaker
-
25 posts
Variable types
So, there aren't really data types with scratch. But you can doNo, i dont have. Do you have a project that uses something associated with this? If so please provide a link.
- Jereb-co7
-
100+ posts
Variable types
1000+ posts? HOW? Hello! The variables that Scratch uses can store characters (so letters as well as numbers). I don't think boolean variables exist, but you can set a variable to true/false or 0/1 and then check if that variable is a certain value to mimic a boolean.
- Jereb-co7
-
100+ posts
Variable types
Like global (for Do they even exist? If so, how scratch decides which variable should be boolean or integer?all sprites) and local (for this sprite only) variables? Yea they exist
- Jereb-co7
-
100+ posts
Variable types
You can define a Boolean as 1=true and 0=false Do they even exist? If so, how scratch decides which variable should be boolean or integer?
- awesome-llama
-
1000+ posts
Variable types
Variables/list items do have types but a lot of stuff happens out of sight.
As far as I know, they can only be strings, double floats, or booleans.
Everyone saying above that there aren't types are wrong.
Here's an example where it matters: https://scratch.mit.edu/projects/649641539/
Scratch decides the type dependent on the situation and the data involved.
For example, doing maths on a variable will automatically convert the values into numbers. For this specifically, anything that can be a number will be converted into a float, strings that cannot be interpreted as a number (say they contain letters) will be converted into a 0, and booleans will converted into 1 and 0 for true and false (very useful to know).
Something else also worth noting here is Scratch also can convert strings representing hexadecimal or binary numbers into decimal numbers. The prefix 0x or 0b needs to be included for this to happen.
For the operators that work on strings such as the join block, the values are converted into strings.
The boolean blocks also have special behaviour.
The equals block compares inputted strings as strings and numbers as numbers except if a string is composed of numbers, it will be compared as a number (something to know when dealing with cloud variables which can handle long strings of numbers whilst not actually being a numerical datatype).
The greater than and less than blocks compare numbers as you would expect but strings are compared alphabetically. With booleans, true is bigger than false.
As far as I know, they can only be strings, double floats, or booleans.
Everyone saying above that there aren't types are wrong.
Here's an example where it matters: https://scratch.mit.edu/projects/649641539/
Scratch decides the type dependent on the situation and the data involved.
For example, doing maths on a variable will automatically convert the values into numbers. For this specifically, anything that can be a number will be converted into a float, strings that cannot be interpreted as a number (say they contain letters) will be converted into a 0, and booleans will converted into 1 and 0 for true and false (very useful to know).
Something else also worth noting here is Scratch also can convert strings representing hexadecimal or binary numbers into decimal numbers. The prefix 0x or 0b needs to be included for this to happen.
For the operators that work on strings such as the join block, the values are converted into strings.
The boolean blocks also have special behaviour.
The equals block compares inputted strings as strings and numbers as numbers except if a string is composed of numbers, it will be compared as a number (something to know when dealing with cloud variables which can handle long strings of numbers whilst not actually being a numerical datatype).
The greater than and less than blocks compare numbers as you would expect but strings are compared alphabetically. With booleans, true is bigger than false.
- Discussion Forums
- » Help with Scripts
-
» Variable types