Page 177 - The Ultimate Palm Robot
P. 177
Color profile: Generic CMYK printer profile
Composite Default screen
Bots / The Ultimate Palm Robot/ Mukhar & Johnson / 222880-6 / Chapter 7
160 The Ultimate Palm Robot
Next, we’ll create some variables. Since these are string variables, the vari-
able name includes a trailing $. Note that you can put multiple code state-
ments on a single line if they are separated by a colon.
a$ = "Hello, " : b$ = "World!"
Now we’ll create a loop so that the program runs until we tell it to quit. In-
side the loop, we’ll draw the phrase to the screen:
while (1) : rem loop forever
draw –1 : rem clear the screen
draw a$ + b$,2,15
There are two commands for printing to the screen, print and draw. With
the draw command, you pass the string, followed by the screen position in x
and y coordinates where the upper-left corner of the screen is 0,0.
The line of code above draws the string “Hello, World!” at screen position
x=2 and y=15, which is just below the application title. Now, let’s create a form
button that will pop up an input box. The command for creating a form button
is form btn x, y, width, height, button_label, 1.
form btn 2,30, 55,15, "Enter Name", 1
This draws a button that is 55 pixels wide and 15 pixels high at screen posi-
tion x=2, y=30. When the user taps the button, we’ll pop up an input box that
P:\010Comp\Bots\880-6\ch07.vp
Monday, May 12, 2003 4:29:21 PM