1. Menu Routine
- Posted by Steve Elder <SteveElde at AOL.COM>
Aug 05, 1997
-
Last edited Aug 06, 1997
--- Here is a routine that puts a text-only menu on the screen and traps
-- for F keys. Have fun.
-- Steve Elder
include graphics.e
include get.e
atom row,result
result = 0
global procedure draw_menu(sequence title) -- draw generic menu screen
cursor(NO_CURSOR) -- with a title
clear_screen()
row = 6
position(5,20) text_color(WHITE)
puts(1,title)
for i = 1 to 12 do
position(row + i,20) text_color(3)
puts(1, "F") ? i
end for
text_color(WHITE)
position(20,20) puts(1,"PRESS DESIRED FUNCTION KEY")
end procedure
global procedure menu_item(atom fkey, sequence label) -- add items to menu
text_color(BRIGHT_BLUE)
position(row + fkey,26) puts(1,label)
end procedure
global function menu_out(atom fkey_in) -- get results from fkey press
fkey_in = wait_key() -- f1 = 1, f2 = 2, etc.
fkey_in = fkey_in - 314
if fkey_in > 10 then
fkey_in = fkey_in -64
elsif fkey_in < 1 then
position(24,1) puts(1,"You did not press an F key.")
abort(0)
end if
return fkey_in
end function
-- usage
draw_menu("Show Me")
menu_item(1,"Show me a one")
menu_item(2,"Show me a two")
menu_item(3,"Show me a three")
menu_item(5,"Show me a five")
result = menu_out(result)
position(24,1) puts(1,"You pressed F") ? result