August 2010
Intermediate to advanced
288 pages
13h 21m
English
It’s not unusual for a program to use several blocks with the same settings. For example, the WallFollower program contains seven Move blocks that all use the same Power setting. If you decide to change the setting from 35 to 45, you need to make sure you change that setting on all seven blocks. That can become problematic when you’re trying several different Power settings, in search of the perfect balance between speed and accuracy; it’s almost inevitable that you’ll forget to change the setting on one of the blocks.
To avoid this problem, use variables to group common settings. For example, Figure 11-15 shows a modified version of the AroundTheBlock program from Chapter 4. Here you use a variable (named Power) to control ...