trouble looping in script

I am having problem looping this script
I want to give the user option to decide if they want to continue after each entry but then also loop it back to beginning so they can more to content of there testcase they just created. I fam new to scripting so loops are little tricky for me.

code I presently have

print "Please enter test case name"
read testcasename
echo $testcasename
while [ $CHOICE -nq N ];
do
print "Please enter in field 1 Version"
read version
if [[ "${#version}" -lt 4 ]] ; then
print -n $version >> $testcasename
else
print "too many bytes"
print "Do you want to continue Y/N?"
read CHOICE
fi
 
print "Pleasent in field 2 Date"
read date
if [[ "${#date}" -lt 9 ]] ; then
print -n $date >> $testcasename
else
print "too many bytes"
print "Do you want to continue Y/N?"


fi
exit

Q: Did you initialize correctly $CHOICE ?

Are you looking for something like this?

#!/bin/bash

read -p "Please enter test case name : " testcasename

while true
do
  read -p "Please enter in field 1 Version : " version
  if [[ "${#version}" -lt 4 ]] ; then
    echo  $version >> $testcasename
  else
    read -p "Invalid Data. Do you want to continue Y/N? : " CHOICE
    test "$CHOICE" = "N" && break
  fi
  read -p "Please enter date : " DATE
  if [[ "${#DATE}" -lt 9 ]] ; then
    echo  $date >> $testcasename
  else
    read -p "Invalid Data. Do you want to continue Y/N? : " CHOICE
    test "$CHOICE" = "N" && break
  fi
  read -p "Do you want to continue Y/N? : " CHOICE
  test "$CHOICE" = "N" && break
done

--ahamed

I have something like this but not sure why I am getting errors now:

Ok this is new code:

#!/bin/ksh
set -x

print "This script creates test messages"

print "Please enter test case name"
read testcasename
echo $testcasename

CHOICE=Y

while [ $CHOICE -ne N ];
do
print "Please enter in field 1 Version"
read version
if [[ "${#version}" -lt 4 ]] ; then
print -n $version >> $testcasename
else
print "too many bytes"
fi
print "Do you want to continue Y/N?"
read CHOICE

done

CHOICE2=Y
while [ $CHOICE2 -ne N ];
do
print "Pleas enter in field 2 Date"
read date
if [[ "${#date}" -lt 9 ]] ; then
print -n $date >> $testcasename
else
print "too many bytes"

print "Do you want to continue Y/N?"
read CHOICE2

done

fi

exit

and output is

$ ./"andrew_testter.ksh"
+ print This script creates test messages
This script creates test messages
+ print Please enter test case name
Please enter test case name
+ read testcasename
andytest
+ echo andytest
andytest
+ CHOICE=Y
+ [ Y -ne N ]
./andrew_testter.ksh[12]: Y: bad number
+ CHOICE2=Y
./andrew_testter.ksh[26]: syntax error at line 40 : `done' unexpected

 
before
while [ $CHOICE2 -ne N ];

after
while [ $CHOICE2 != "N" ]
 
Also you may want to use typeset so the user does
not need worry about entering the respone in the
the correct case
 

[/SIZE][/FONT]

Code is a lot easier to read (and debug) if you indent it properly. Also, use

 tags.

$CHOICE -ne N

-ne is a numeric test - != for strings.

read CHOICE2

done

fi

fi and done are in the wrong order.

the second done is before fi...

Thanks you I will update the script accordingly with the changes