Trying to implement 'more' command

Hi all, i'm quite new in the UNIX world. So maybe i'm going to ask simple questions but they are unsolvable for me...
I'm trying to implement the 'more' function or kinda of that, for improving my knowledges. But I encountered some problems that i hope u will help me to solve.
The code i developed till now follows below. I put in red the parts that I couldn't manage to implement with some comments.

#!/bin/ksh
clear;
a=$(stty -a|sed -n '2p'|awk '{print $3}'|nawk 'sub(".$","")') #returns the number of rows of the present shell and save it in the variable a
b=$(cat $1|wc -l) #returns the number of lines of the file
c=$(stty -a|sed -n '2p'|awk '{print $6}'|nawk 'sub(".$","")') #returns the number of columns of the present shell and save it in the variable c
count=$a;
temp=1;

while [ $count -le $b ] ; do
bold=`tput smso`
offbold=`tput rmso`
echo "${bold}Press 'c' if you want to continue, 'b' if you want to go back,'q' if you want to quit${offbold} \c"
read ANSW
case "$ANSW" in

[Cc])
e=0;
for <condition>; do #the following cycle must be done for each line that i want to observe
if ( col_line -gt $c ); do #if the number of columns of EACH line is bigger than the number of columns of the shell
d=col_line/$c; #d contains the ratio between the numb of col of the single line and the numb of col of the shell
d=round d; #d must be rounded to the SMALLER nearest integer
e=`expr $e + $d`
fi
done
count=`expr $count - $e` #count will be equal to the exact number of lines
sed -n "$temp,`expr $count - 1` p" $1
temp=$count;
count=`expr $count + $a`
;;
[Bb])
count=`expr $temp -$a + 1`
sed -n "$count,$temp, p" $1;
temp=$count;
;;
[Qq])
exit 1
;;
*) echo You answered a nonsense word, retype the answer
sleep 1
;;
esac

done

The main problems are:

  • what is the condition i should put in the while cycle
  • what is the condition i should put in the for cycle
  • how can i get the value of col_line (number of columns of each line of the text file)
  • how can i keep the value of count and temp to use them in case I press 'b'?
  • how can i make the written inside 'echo' disappear (as in 'more' command)?

Thanks in advance for answering

Cellofan