Users Manual

SCRATCH CODING KIT
Activity
Tori secret safe door close comparison coding
Now create a script when you receive the 'Close_Check' broadcast. The 'Close_Check Received' script's role is to
compare the entered number against the password and close it if it matches, or 'Password_error' if it does not
match. Let's make it once.
First, when you receive the broadcast, save '1' in the 'Pointer' variable. The reason for storing '1' is that this
variable must compare the first item stored in the 'Code' list with the first item stored in the 'Key' list. If the first
item matches, the variable is incremented by 1 and the second, third, and fourth items are matched. Save '1' and
use 'repeat to block'. The condition is 'Pointer> 4'. If the 'Pointer = 4' condition is used, the 'Pointer' variable will
become 4 and exit the 'Repeat to' block and compared with items up to item 3.
Inside the script use the 'if' block. The condition is "Item = 'Code Pointer' item = 'Key Pointer' is not item '. If the
'Code' list stored with the entered number and the 'Key' list stored with the password '1234' are compared, if
they do not match, the condition of 'if' is satisfied, 'Password_error' is broadcast and the script will be stopped.
However, as the ‘Pointer’ variable is accumulated one by one, the items in the ‘Code’ and ‘Key’ lists are the same, it
exits ‘repeat to~’ block and deletes all items in ‘Code’ and broadcasts ‘Close_Door’.