Users Manual

CLASS 3
144
Tori Secret Safe door close comparison coding
Finally, let's create a script when we receive the 'Check_Password' broadcast. When you receive the 'Check_
Password' script, the role of the script compares the entered numbers against the passwords to see if they match,
and if it does not match, it will broadcast 'Password_error'.
Let's make it.
Create a script like the one above. First, when we receive the broadcast, we compare the 'Pointer' variable, which is
the number of digits entered by the user, and the 'keycnt' variable, which is the number of digits in the password.
If the two values are not the same, broadcast 'Password_error' and stop the script. If the number of digits is not
the same, the numbers entered in the list are not compared at first, and the password error notification is given.
Then, store a '1' in the 'index' variable. Save '1' and use 'repeat to block'.
The condition is 'index = Pointer'. The current 'Pointer' variable stores the number of digits (number of items) that
you enter. Increase the 'index' variable by 1 and compare the number 1 item in the list of 'Code' with the number
of the item '1' in the list of 'Key' where the password is stored. If it does not match, broadcast 'Password_error'
and stop the script. If the 'index' variable is incremented by 1, the two lists are compared. If all the items in all the
positions are matched, exit the block 'Repeat to' to broadcast 'Open_Door' (open the door) After deleting all the
items in the 'Key' list, save the initial value 0 in the 'keycnt' variable.
※ The whole script can be found at http://www.robotori.com/web_eng -> Moretips -> Manual ->EDU ->Logic
boost CODING CLASS 3 ->download whole script
Commentary