#
# get to current GRASS location
cd $LOCATION
if [ -d SUBJ ]            # check for SUBJ directory
then cd SUBJ              # get to SUBJ directory
else mkdir SUBJ           # make one if it doesn't exist
     cd SUBJ
fi

# create a subject file
echo " Enter the subject name \c"
read NAME
if [ "$NAME" = "" ] 
then exit
fi

# start filling the file
echo "0:no data" > dum_data
repeat=yes
CAT=0
while [ "$repeat" = "yes" ]
do
echo " label: \c"
read LABEL
if [ "$LABEL" = "" ]
then repeat=no
     echo "# $CAT categories" > tmp_subj
     echo "Title $NAME" >> tmp_subj
     echo "\n0.00 0.00 0.00 0.00" >> tmp_subj
     cat dum_data >> tmp_subj
else
     CAT=`expr $CAT + 1`
     echo "$CAT:$LABEL" >> dum_data
fi
done
mv tmp_subj $NAME
rm -f dum_data
