|
|
| Everything HP200LX: Knowledge, Products, Service |
|
Sample TIPI codeNo self-respecting developer article would be complete without sample code, so I've included a brief listing here to show you a bit more what TIPI is all about. This simple application will display the character for any key you press along with its keycode in decimal and hex. If you subscribe to the disk version of this publication, you will find a ZIP file containing the full shareware release of TIPI 2.0 which includes many more programs and a full TIPI reference manual. Alternately, you can obtain TIPI and all the code from CompuServe's HP Handhelds forum. If you have any questions or comments about TIPI, drop me some E-mail. The odds are that I'm up, the coffee's on and I'm hacking on TIPI.#DEMO.TPI by Kent Peterson 11/17/94 define hex$ ( n -- ) ( -- h$ ) # Returns hex equivalent of a number. "" begin dup 16 mod "0123456789ABCDEF" 1 + 1 mid$ swap$ +$ 16 / dup not until drop enddef
define showtime ( -- ) ( -- ) # Shows the current time # on the top row of the screen. 0 5 locate time$ print$ enddef
define spaces ( -- ) ( -- ) # Print$ four spaces. " " print$ enddef define asciiline ( c -- ) ( -- ) # Displays c as a character, # its hex code and its decimal code. dup chr$ print$ spaces dup hex$ print$ spaces print spaces enddef
define wait_for_key ( -- c ) ( -- ) # Waits until a key is pressed # and then returns the keycode. # While it's waiting it shows # the current time. begin showtime key dup if dup endif until enddef
#dow let's put all this stuff together. cls # Displays the column headings # and the instructions. | | | Char Hex Dec | ============== | | | | Press any key to see its code. | [ESC] exits.
0 cursor # Hide the cursor.
# This is the main loop. It will # loop until the user presses # the [ESC] key. begin wait_for_key 5 3 locate dup asciiline 27 = until
1 cursor # Set the cursor back to normal.
|
|
Copyright © 2005 Thaddeus Computing Inc
<