From Test-Scratch-Wiki

Translate: - English - 中文 
This zho is about the block. For more information on the value this block reports, see Answer (value).
类别 侦测类积木
形狀 椭圆形积木

The Answer 积木 is a 侦测类积木 and a 椭圆形积木. The block holds the most recent text inputed with the 询问 () 并等待 block. When nothing has been inputted yet, the will hold nothing.

This block can be displayed as a 舞台监控视窗.


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

Some common uses for the Answer block:

  • Storing information (such as in 专案 that require a name to be inputted)
詢問 [What's your name?] 並等待
變數 [name v] 設為 (詢問的答案)
說出 (字串組合 (字串組合 [Hi, ] 和 (詢問的答案)) 和 [!])
  • Retrieving information (such as when the name must be retrieved)
詢問 [What's your favorite color?] 並等待
說出 (字串組合 (詢問的答案) 和 [ is my favorite color too!])
  • When a setting has been imputed with the 询问 () 并等待 block, keeping the selecting setting somewhere
詢問 [Which level do you want to play?] 並等待
變數 [level v] 設為 (詢問的答案)
廣播訊息 (字串組合 [start level] 和 (level)) //  This can actually be done in the Scratch editor. You can not, however, place reporters in "when I receive"
  • When quizzing
詢問 [What is 30 + 9?] 並等待
如果 <(詢問的答案) = [39]> 那麼 
  說出 [That is correct!]
  變數 [Score v] 改變 (1)

  說出 [That is incorrect]
  變數 [Score v] 改變 (-1)