Everybody was contributing, I couldn't stay behind.Below is my select routine. I've rewritten it completely, so it's back to the original version (without page-up & -down).
If I find some more time, I'll implement these again.
code:
function kixsel($select,$top,$left,$height,$width,$escape,$helptxt); *** Define default variables ***
$crlf=chr(13)+chr(10)
$frec=0 $mrec=Ubound($select)
if $height>$mrec+1 $height=$mrec+1 endif
$oline =0 $aline =$top+1 $fline =$top+1 $mline =$top+$height
; *** Add default Helptext ***
$helptext=$helptext+$crlf+$crlf+
" Valid keys are: "+$crlf+" <Arrow Up> / <Arrow Down> "+$crlf+
" <Page Up> / <Page Down> "+$crlf+" <Enter> = Exit with selection "+$crlf
if $escape $helptext=$helptext+" <Esc> = Exit without answer "+$crlf endif
; *** Display Box ***
$nul=box($top,$left,$top+$height+1,$left+$width+1,"double")
; *** Push Key Routine ***
ushkey
gosub showlines
get $key
select
case @ERROR=59 ; * Function key {F1} *
$nul=messagebox($helptext,"Select",32,0)
case $key="P" ; * ARROW DOWN *
if $aline<$mline
$aline=$aline+1
else
if $frec+$height<=$mrec
$frec=$frec+1
endif
endif
case $key="H" ; * ARROW UP *
if $aline>$fline
$aline=$aline-1
else
if $frec>0
$frec=$frec-1
endif
endif
case $key=chr(27) and $escape=1 ; * ESCAPE *
$kixsel=""
exit
case $key=chr(13) ; * ENTER *
$kixsel=$select[$frec+$aline-1]
exit
endselect
goto pushkey
:showlines
$tline=$fline $rec=$frec
while $tline<=$mline
$thisrec=substr($select[$rec],1,$width)
while len($thisrec)<$width $thisrec=$thisrec+" " loop
if $tline=$aline
color w+/b AT ($tline,$left+1)$thisrec color w/n
else
AT ($tline,$left+1)$thisrec
endif
$tline=$tline+1 $rec=$rec+1
loop
at (15,3) $frec" - "$aline
$oline=$fline
return
endfunction
You can run it with something like this:
code:
$fields="aaaa","bbbb","cccc","ddddd","eeeee","fffff","ggggg","hhhhh","iiiii"$test=kixsel($fields,0,0,5,10,1,"txt")
? $test
get $x
the first var is an array of fields.
field 2 = starting colomn
field 3 = starting row
field 4 = number of lines to be displayed
field 5 = length of string to be displayed
field 6 = escape allowed (1 = yes, 0 = no)
field 7 = specific help text for these records.
------------------
Greetz,
Roger the Young
------------------------
The code is out there...
------------------------