Hi Saleem,One way is to build Windows-like textboxes with KiXtart's AT() and BOX() functions ... then read the keyboard and allow the user to make a selection :
Here's an quicky User Defined Function called MenuChoice (hope your running KiXtart 4.0) ...
You call it like this:
$choice = MenuChoice($prompt,$menu,x,y)
where:
$prompt is the window title to display
$menu is an array of strings (choices)
$x is the left position of the window (col)
$y is the top position of window (row)
and it goes like this:
code:
break on
$Departments = "North","South","East","West"
$NorthPrinters = "North1","North2","North3"
$SouthPrinters = "South1","South2"
$EastPrinters = "East1","East2","East3","East4","East5","East6"
$WestPrinters = "West1","West2"
CLS
$Dept = MenuChoice("Department ?",$Departments,5,5)
Select
Case $Dept = "North"
$Printer = MenuChoice("North Printer ?",$NorthPrinters,8,8)
case $Dept = "South"
$Printer = MenuChoice("South Printer ?",$SouthPrinters,8,8)
case $Dept = "East"
$Printer = MenuChoice("East Printer ?",$EastPrinters,8,8)
case $Dept = "West"
$Printer = MenuChoice("West ?",$WestPrinters,8,8)
EndSelect
If $Printer
?"You selected $Printer from the $Dept department"
Endif
exit 1
function MenuChoice($prompt,$menu,$x,$y)
;
; prompt - window caption
; menu - array of strings (choices)
; x - left position of window (col)
; y - top position of window (row)
;
dim $option,$n,$current,$previous,$key
dim $height,$width
$height = ubound($menu)+2
$width = len($prompt)
for each $option in $menu
if len($option) > $width
$width = len($option)
endif
next
$width = $width + 2
color w+/b
box($y,$x,$y+$height,$x+$width,"single")
at($y,$x+1) substr($prompt,1,$width-2)
$n=0
$option=0
for each $option in $menu
at($y+$n+1,$x+1) $option
$n=$n+1
next
$current = 0
$previous = $current
color b/w+
at($y+$current+1,$x+1) $menu[$current]
at(0,0)
color w/n
do
get $key
if $key = CHR(224) ; Extended Key
get $key
if $key = CHR(80) ; Down Arrow
$current=$current+1
if $current = ubound($menu)+1
$current=0
endif
endif
if $key = CHR(72) ; Up Arrow
$current = $current - 1
if $current = -1
$current = ubound($menu)
endif
endif
color b/w+
at($y+$current+1,$x+1) $menu[$current]
color w+/b
at($y+$previous+1,$x+1) $menu[$previous]
at(0,0)
color w/n
$previous = $current
endif
until $key = CHR(13) or $key = CHR(27) or $key = "Q" ; CR,ESC or Q ?
if $key = CHR(27) or $key = "Q"
$MenuChoice = ""
else
$MenuChoice = $menu[$current]
endif
endfunction
-Shawn
[ 21 October 2001: Message edited by: Shawn ]