Page 181 - The Ultimate Palm Robot
P. 181

Color profile: Generic CMYK printer profile
           Composite  Default screen
                                                      Bots / The Ultimate Palm Robot/ Mukhar & Johnson / 222880-6 / Chapter 7






                    164     The Ultimate Palm Robot




                     Command                 Description
                     form btn x,y, width,    Creates a form button at the given x,y coordinate and with the
                     height, label$, 1       given width and height. The label of the button is given by the
                                             string parameter.
                     fn formbtn( )           Returns the key code of the last form button that was tapped.
                     draw -1                 Clears the display.
                     draw t$, x,y            Draws text t$ at given screen position.
                     fn wait(n)              Delays for n seconds.
                    Table 7-1
                    Some of the More Common or Useful HotPaw Functions (continued)


                                 Creating and drawing forms is fun and leads to strong minds and bodies,
                               but to work with the PPRK, we need to be able to communicate over the serial
                               port. Some of the commands for sending and receiving data over the serial
                               port are shown in Table 7-2.


                     Command                 Description
                     open “com1:”,9600 as #5  Opens the serial port. Note that you must always use the command
                                             as shown. COM1 is the only valid serial port, 9600 baud is the
                                             speed that the Pontech SV203 controller is using, and only
                                             descriptor #5 is valid for serial port communication.
                     print #5, a$            Prints the string a$ to the serial port.
                     get$(#5, n)             Returns a string up to n bytes long.
                     input #5, a$            Waits for one line of text.
                     close #5                Closes serial port.
                     fn serial(5)            Returns the number of bytes to be read from descriptor #5.
                     Table 7-2
                     HotPaw Basic Commands for Using the Serial Port of the Palm


                    PPRK Programming with HotPaw Basic
                               Now that we’ve seen a simple application using HotPaw Basic and some of the
                               HotPaw Basic commands and functions, let’s actually write some code for the
                               PPRK. We’ll first discuss what the program is intended to do, and then show
                               the code.

                               The Simple Jig Program

                               This program will be simple in concept, but as you will see, it does involve a
                               bit more code than we saw earlier. The program will run in a loop. Within the






           P:\010Comp\Bots\880-6\ch07.vp
           Monday, May 12, 2003 4:29:22 PM
   176   177   178   179   180   181   182   183   184   185   186