#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.