Page 238 - Learn To Program With Scratch
P. 238

Click the plus sign seven times to   Click inside the edit boxes and
                          add space for the seven days.  type your data.

                         Figure 9-5: Populating the dayList

                             Click the plus sign at the lower-left corner seven times to create seven
                         entries and then enter a day of the week inside each edit box. Use the tab
                         key to navigate through the list items. Pressing tab once highlights the next
                         list item with a yellow border. Pressing tab another time highlights the edit-
                         able text of the selected item and removes the yellow border. If you click the
                         plus sign while the currently selected item is surrounded by a yellow border,
                         the new list item will be added after the current item; otherwise, it will be
                         added before the current item. Try navigating the list!



                                                   try it out 9-1
                            Populate dayList with the names of the weekdays, as shown in Figure 9-5 .




                         List Commands
                         Figure 9-3 described all the blocks that Scratch added when we created
                         our dayList. In this section, we’ll look more closely at these blocks to better
                         understand their function.


                         Add and Delete
                         The add command places a new item at the end of a list, while the delete
                         command removes an item from a specific position. Figure 9-6 shows these
                         commands in action.
                             The script first executes the delete command to remove the second
                         item of the list, which is “Orange.” The script then puts “Lemon” at the
                         end of the list using the add command.









           216   Chapter 9
                                           www.it-ebooks.info
   233   234   235   236   237   238   239   240   241   242   243