#23728 - 2002-06-28 07:58 AM
Re: DOS Menu
|
punkie
Getting the hang of it
Registered: 2002-06-23
Posts: 67
|
I took a look at the script, did some modifications - added to following: menu position, width between colums, menu height and width. And it works perfectly now
I couldn't find any problems using the code either, but I guess I can post the whole thing on here. You did a wonderful job Dean.
code:
; KixMenu.kix ; version 1.0 for Kix2001 ; written by Dean E. Behrman ; created 06.25.2002
; modified by punkie june 28, 2002 ; $x,$y: Menu position. ; $colw: Width between colums. ; $width: Menu width. ; $height: Menu height.
function kixmenu ($_array,$_maxrows,optional $_title,$x,$y,$colw,$width,$height) ;$_array: Items to display in tabular format ;$_maxrows: Specify the maximum number of rows in the table ;$_title: Optional title for the window
cls if val(@kix) <> 4 ? "Requires Kixtart 2001" $kixmenu = -1 exit 1 endif
dim $_width,$_acount,$_cols,$_rows,$_currow,$_curcol,$_curitem,$_colitems[1],$_rowitems[1],$_x,$_key $_rc = setoption("HideCursor","ON") $_width = $colw $_currow = 0 $_curcol = 0 $_curitem = 0 if $_maxrows <= 0 $_maxrows = 24 endif
$_acount = ubound($_array) for $_x = 0 to $_acount $_item = $_array[$_x] if len($_item) > $_width $_width = len($_item) endif next
$_maxcols = 78 / ($_width + 1) if $_maxcols < 1 or $_acount > ($_maxcols * $_maxrows) $kixmenu = -1 goto end endif if $_acount / $_cols > $_maxrows $kixmenu = -1 goto end endif $_cols = ($_acount / $_maxrows) + 1 $_rows = ($_acount + 1) / $_cols gosub drawscreen gosub buildmenu gosub pickitem :end $rc = setoption("HideCursor","OFF") cls return
:drawscreen Color w+/b Box ($y,$x,$height,$width,"SINGLE") if $_title <> "" and $_title <> 0 at ($y,$x+1) $_title endif return
:buildmenu $_curitem = 0 redim $_colitems[$_cols], $_rowitems[$_rows] for $_curcol = 0 to $_cols for $_currow = 0 to $_rows - 1 if $_curitem <= $_acount at ($_currow + $y+1,$_curcol * ($_width + 1) + $x+1) $_array[$_curitem] $_colitems[$_curcol] = $_currow $_rowitems[$_currow] = $_curcol endif $_curitem = $_curitem + 1
next next return
:pickitem $_currow = 0 $_curcol = 0 $_curitem = 0 gosub showcursor at (0,0) do get $_key if asc($_key) = 224 ; Extended Key get $_key if asc($_key) = 80 ; Down Arrow gosub hidecursor $_currow = $_currow + 1 $_curitem = $_curitem + 1 if $_currow > $_colitems[$_curcol] $_currow = 0 $_curitem = $_curitem - $_colitems[$_curcol] - 1 endif gosub showcursor endif if asc($_key) = 72 ; Up Arrow gosub hidecursor $_currow = $_currow - 1 $_curitem = $_curitem - 1 if $_currow < 0 $_currow = $_colitems[$_curcol] $_curitem = $_curitem + $_colitems[$_curcol] + 1 endif gosub showcursor endif if asc($_key) = 75 ; Left Arrow gosub hidecursor $_curcol = $_curcol - 1 if $_curcol < 0 $_curcol = $_rowitems[$_currow] $_curitem = $_curitem + $_rowitems[$_currow] * $_rows else $_curitem = $_curitem - $_colitems[$_curcol] - 1 endif gosub showcursor endif if asc($_key) = 77 ; Right Arrow gosub hidecursor $_prev = $_curcol $_curcol = $_curcol + 1 if $_curcol > $_rowitems[$_currow] $_curcol = 0 $_curitem = $_curitem - $_rowitems[$_currow] * $_rows else $_curitem = $_curitem + $_colitems[$_prev] + 1 endif gosub showcursor endif endif until asc($_key) = 13 or asc($_key) = 27 ; ENTER or ESC
if asc($_key) = 13 $kixmenu = $_curitem else $kixmenu = -2 endif return
:showcursor color b/w+ at ($_currow + $y+1,$_curcol * ($_width + 1) + $x+1) $_array[$_curitem] color w/n at (0,0) return
:hidecursor color w+/b at ($_currow + $y+1,$_curcol * ($_width + 1) + $x+1) $_array[$_curitem] color w/n at (0,0) return
endfunction
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 809 anonymous users online.
|
|
|