"Answer" redirects here. For the information that this block reports, see Answer (value).
Answer
answer
Category Sensing
Type Reporter
Introduced in 1.4

The Answer block is a Sensing block and a Reporter block. The block holds the most recent text inputed with the Ask () and Wait block. When nothing has been inputted yet, the value will hold nothing. It was introduced in Scratch 1.4.

This block can be displayed as a Stage monitor.

Example Uses

As this block stores inputted text, it is very useful where a script has to refer to what has been inputted. For example, there are chatbots that let the Scratcher input their name. If the script needs to see their name, the Answer block can be used.

Some common uses for the Answer block:

  • Storing information (such as in projects that require a name to be inputted)
ask [What's your username?] and wait
if <(answer)=(username)> then :: control c
say [That's your username!]
else
say [That's not your username!]
end
  • Retrieving information (such as when the name must be retrieved)
ask [What's your favorite color?] and wait
say (join (answer) [ is my favorite color too!])
  • When a setting has been imputed with the Ask () and Wait block, keeping the selecting setting somewhere
ask [Which level do you want to play?] and wait
set [level v] to (answer)
broadcast (join [start level] (level)) // This can actually be done in the Scratch editor. You can not, however, place reporters in "when I receive"
  • When quizzing
ask [What is 30 + 9?] and wait
if <(answer) = [39]> then
say [That is correct!]
change [Score v] by (1)
else
say [That is incorrect]
change [Score v] by (-1)
end

See Also