Revision as of 00:53, 20 July 2012 by Veggieman001 (talk | contribs)

Ask () and Wait
Ask () and Wait.png
Category Sensing
Type Stack
Introduced in 1.4

The Ask () and Wait block is a Sensing block and a Stack block. The block will make an input box (with the specified text above it) show at the bottom of the screen. Scratchers can input text into it and submit it — the input is stored in the Answer block. The Answer block automatically updates to the latest input.

The dialog the question is asked in.

In native Scratch and the Flash Player, text can be pasted in, but not in the Java Player.

Workaround

This block can be somewhat replicated with the following code:

say (question)
delete (all v) of [answer v]
set [count v] to [0]
repeat until <<touching [mouse-pointer v]?> and <mouse down?>>
if <key [a v] pressed?>
change [count v] by (1)
insert [A] at (count) of [answer v]
end
if <key [b v] pressed?>
change [count v] by (1)
insert [B] at (count) of [answer v]
end
if <key [c v] pressed?>
change [count v] by (1)
insert [C] at (count) of [answer v]
end
if <key [d v] pressed?>
change [count v] by (1)
insert [D] at (count) of [answer v]
end
if <key [e v] pressed?>
change [count v] by (1)
insert [E] at (count) of [answer v]
end
if <key [f v] pressed?>
change [count v] by (1)
insert [F] at (count) of [answer v]
end
if <key [g v] pressed?>
change [count v] by (1)
insert [G] at (count) of [answer v]
end
if <key [h v] pressed?>
change [count v] by (1)
insert [H] at (count) of [answer v]
end
if <key [i v] pressed?>
change [count v] by (1)
insert [I] at (count) of [answer v]
end
if <key [j v] pressed?>
change [count v] by (1)
insert [j] at (count) of [answer v]
end
if <key [k v] pressed?>
change [count v] by (1)
insert [K] at (count) of [answer v]
end
if <key [l v] pressed?>
change [count v] by (1)
insert [L] at (count) of [answer v]
end
if <key [m v] pressed?>
change [count v] by (1)
insert [M] at (count) of [answer v]
end
if <key [n v] pressed?>
change [count v] by (1)
insert [N] at (count) of [answer v]
end
if <key [o v] pressed?>
change [count v] by (1)
insert [O] at (count) of [answer v]
end
if <key [p v] pressed?>
change [count v] by (1)
insert [P] at (count) of [answer v]
end
if <key [q v] pressed?>
change [count v] by (1)
insert [Q] at (count) of [answer v]
end
if <key [r v] pressed?>
change [count v] by (1)
insert [R] at (count) of [answer v]
end
if <key [s v] pressed?>
change [count v] by (1)
insert [S] at (count) of [answer v]
end
if <key [t v] pressed?>
change [count v] by (1)
insert [T] at (count) of [answer v]
end
if <key [u v] pressed?>
change [count v] by (1)
insert [U] at (count) of [answer v]
end
if <key [v v] pressed?>
change [count v] by (1)
insert [V] at (count) of [answer v]
end
if <key [w v] pressed?>
change [count v] by (1)
insert [W] at (count) of [answer v]
end
if <key [x v] pressed?>
change [count v] by (1)
insert [X] at (count) of [answer v]
end
if <key [y v] pressed?>
change [count v] by (1)
insert [Y] at (count) of [answer v]
end
if <key [z v] pressed?>
change [count v] by (1)
insert [Z] at (count) of [answer v]
end
if <key [0 v] pressed?>
change [count v] by (1)
insert [0] at (count) of [answer v]
end
if <key [1 v] pressed?>
change [count v] by (1)
insert [1] at (count) of [answer v]
end
if <key [2 v] pressed?>
change [count v] by (1)
insert [2] at (count) of [answer v]
end
if <key [3 v] pressed?>
change [count v] by (1)
insert [3] at (count) of [answer v]
end
if <key [4 v] pressed?>
change [count v] by (1)
insert [4] at (count) of [answer v]
end
if <key [5 v] pressed?>
change [count v] by (1)
insert [5] at (count) of [answer v]
end
if <key [6 v] pressed?>
change [count v] by (1)
insert [6] at (count) of [answer v]
end
if <key [7 v] pressed?>
change [count v] by (1)
insert [7] at (count) of [answer v]
end
if <key [8 v] pressed?>
change [count v] by (1)
insert [8] at (count) of [answer v]
end
if <key [9 v] pressed?>
change [count v] by (1)
insert [9] at (count) of [answer v]
end
if <key [right arrow v] pressed?>
change [count v] by (1)
end
if <key [left arrow v] pressed?>
change [count v] by (-1)
end
if <key [space v] pressed?>
change [count v] by (1)
insert [] at (count) of [answer v]
end
wait (0.001) secs
end
say []
Note Note: This does not work perfectly. See this project for more information.

The list "answer" will replace the answer block.

Example Uses

As this block allows users to input any text they want, it is widely used when a user must communicate with the project.

Some common uses for the Ask () and Wait block:

  • Chatbots — receiving information from the user
ask [What's your name?] and wait
say (join [Hello, ] (join (answer) [.]))
  • Setting preferences — coordinates, color, and so on
ask [Color?] and wait
set [color v] effect to (answer)
  • Receiving input — asking the user to give a command
ask [Move how many steps?] and wait
move (answer) steps

See Also