home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
tipi
/
menu.tpi
< prev
next >
Wrap
Text File
|
1993-11-06
|
2KB
|
89 lines
# MENU.TPI
# by Kent Peterson
# This program demonstrates a technique for making
# Menus
defvar menuitems
defvar menuchoice
defvar menurow
defvar menucol
defstr menuchoice$
define placepointer
menurow fetch menuchoice fetch + 1 - menucol fetch locate
enddef
define clearpointer
placepointer " " print$
enddef
define drawpointer
placepointer 205 chr$ 16 chr$ +$ " " +$ print$
enddef
define choice+
clearpointer
menuchoice fetch 1 + menuitems fetch
min menuchoice store
drawpointer
enddef
define choice-
clearpointer
menuchoice fetch 1 - 1
max menuchoice store
drawpointer
enddef
define menu ( -- choice )
( menustring$ -- choice$ )
# choice is set to 0 if ESC is pressed,
# number of menu choice if ENTER is pressed.
# The up and down arrow keys move the cursor
0 cursor
row menurow store # save the menu row
column menucol store # and column
menuitems fetch
do
menuitems fetch index - 1 + # counts up
menurow fetch + 1 - menucol fetch locate
" " print$ index pick$ print$
loop
drawpointer
begin
begin
key dup if dup endif
until
case 13 of 1 endof # return
27 of 1 0 menuchoice store endof # escape
328 of 0 choice- endof # up
336 of 0 choice+ endof # down
default 0
endcase
until
menuchoice fetch dup
if menuitems fetch swap - 1 + pick$ else drop "" endif
menuchoice$ store
menuitems fetch
do drop$ loop
menuchoice fetch
menuchoice$ fetch
1 cursor
enddef
4 menuitems store
1 menuchoice store
"Edit"
"Lookup"
"Run"
"Quit"
0 0 locate
cls
menu
5 0 locate
print " " print$ print$ cr
begin key until