Page 157 - The Ultimate Palm Robot
P. 157
Color profile: Generic CMYK printer profile
Composite Default screen
Bots / The Ultimate Palm Robot/ Mukhar & Johnson / 222880-6 / Chapter 6
140 The Ultimate Palm Robot
The Code Component The Code component is used when you need to add
a line of code that is not provided by any of the existing code blocks. For
example, suppose you use the Variable block to create a variable named x.
Later in your code, you want to change the value of x by adding some number
to it or just setting its value directly. You could do that with the Code block.
The property for the Code block is the line of code that you want in your
program at that point. So, with the example just stated, you could change the
value of x with a line of code like this:
x = x + 1
This line of code takes the value of x, adds 1 to it, and finally assigns the new
value to the variable x. If you add a Code block and set its property to that line
of code, that line of code will appear in the translated source file.
The Sleep Component The button for the Sleep block is labeled with a
string of Zzzzzs. The Sleep block is used to pause the program for some
number of seconds. After the number of seconds has elapsed, the program
continues executing. The property for this block is the number of seconds to
sleep.
NOTE: If you are translating a program into TEA, you must be careful to set
the seconds to a value no greater than 3.2767 seconds. This is because the TEA
sleep function uses an int to count in ten-thousandths of a second, and 32,767
is the limit of an int variable. If you need to sleep for more than 3.2767 seconds,
you will need to add multiple Sleep blocks.
P:\010Comp\Bots\880-6\ch06.vp
Monday, May 12, 2003 1:06:25 PM