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 ...
Get Lego Mindstorms NXT-G Programming Guide, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.