Interactive Array Menu

This should be simple, but i haven't done it before...

KSH

I am reading a file into an array and currently displaying the values to the screen. What I need to do is to display a subset of those values, likely numbered, and prompt the user to select one. When they enter the number, it retrieves the assoicated array value and outputs it to the screen. (this will be used for more complex functions later)

For example, the program is run and the first 10 rows are displayed. I select a number or hit a character to proceed to the next page. This would dump the first 10 rows and load the next 10 (into another array?) I select a value and the row associated with that value echoes to the screen.

Any suggestions are greatly appreciated.
My code so far:

#!/bin/ksh
 
# define array
set -A line_array
# select input file
file_name="$scripts/cb_list.dat"
 
# populate the array
i=0
while read file_line
do
line_array=${file_line}
let i=${i}+1
done < ${file_name}
 
i=0
while [ ${i} -le ${#line_array
[*]} ]
do 
echo ${line_array}
let i=$i+1
done
# end of variable_define.sh

[/SIZE]

No need to 'dump' the values since you already have all of them loaded in the array, you can just calculate the current page offset, (say 10 for the second page), and just display items 11-20 in the array for that page.

Your code looks fine so far, what part are you having difficulty with?

EDIT:
I have it working now, code is below for anyone that it might help. I did what i needed with a nested function.

#!/bin/ksh
# define array
set -A line_array

# select input file
file_name="cb_list.dat"


# populate the array
i=1

while read file_line
do
   line_array=${file_line}
   let i=${i}+1
done < ${file_name}


#Display selection options
i=1
x=10

var_select ()
{
while [ ${i} -le ${x} ] && [ ${i} -lt ${#line_array[*]} ]
do
 echo
 echo $i ${line_array}
  let i=$i+1
done

#Select an option

    echo
    echo "Select an option number or press enter: \c"
    read num
disp_select
}


disp_select ()
{
if [ ${num} -le ${i} ]
  then
    echo "You have selected: ${line_array[num]}"
else
    x=${x}+10
    var_select
fi
}

var_select


# end