replacing long data wires with variables

Variables can replace really long data wires in your programs. Instead of using a long data wire, you can use a pair of Variable blocks and a variable with a meaningful name. You use the first Variable block to write the value to a variable just after the block that creates the value. Later in the program, you can read the variable using a second Variable block placed next to the blocks that use the value.

When you can see both ends of a data wire, it’s usually easy to understand how it’s being used. When a program becomes too long to fit on the screen or you can’t see where a data wire starts, it’s much more difficult to follow the logic of the program. A short data wire attached to a Variable block (which ...

Get The Art of LEGO MINDSTORMS NXT-G Programming 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.