O'Reilly logo

Lego Mindstorms NXT-G Programming Guide, Second Edition by James Floyd Kelly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 22. Your Own Filing Cabinet

In Chapter 18, I showed you how to use VARIABLE and CONSTANT blocks to hold data such as Numbers and Text. But the problem with the VARIABLE block is that when the program ends, the data disappears! Even worse, if the batteries die or the power is turned off on your robot while it's running, the VARIABLE blocks all lose whatever values they were holding. The CONSTANT block solves this problem by allowing you to create a global variable that can be reused by multiple programs, but you must create the constant and its value ahead of time, either using the Define Constants menu option (see Chapter 18) or the CONSTANT block's configuration panel. Another limitation to the CONSTANT block is the amount of data this ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required