#
# usage:        tbxquery.sh
#
# abstract:     This Bourne Shell script queries the user for the answers
#		to toolbox questions which will eventually be handled
#		by the update procedure NOT install.
#
# note(s):      1. This routine must be called using a . (period)
#
# Copyright (c) 1993-1998 The Mathworks, Inc. All Rights Reserved.
# $Revision: 1.21 $  $Date: 1998/12/24 17:31:47 $
#----------------------------------------------------------------------------
#
# Query user for toolbox questions.
#
#----------------------------------------------------------------------------
# Symbolic:
#----------------------------------------------------------------------------
#    
    libname="@symlibs"
    libmsg="Maple"
#
#----------------------------------------------------------------------------
# Maple libraries (Maple V5.4 has only one set for 32-bit and 64-bit)
#----------------------------------------------------------------------------
#
    if [ "$batch" = "1" ]; then
#
#----------------------------------------------------------------------------
# batch:
#----------------------------------------------------------------------------
#
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo ''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        mesg="Check Symbolic toolbox for $libmsg library directory? ([y]/n) "
        . $dir/$echon_sh
        read ans
        echo $ans
        if [ `expr "//$ans" : '//[Nn].*'` -ne 0 ]; then
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo ''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        elif [ ! -d $MATLAB/toolbox/symbolic ]; then
	    read ans
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo ''
    echo '    No Symbolic toolbox - $Maplelib'" = '$ans' skipped"
    echo ''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	else
	    (cd $MATLAB/toolbox/symbolic/$libname) >/dev/null 2>&1
            if [ $? -ne 0 ]; then
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo ''
    echo '    No Maple library directory found.'
    echo ''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        	mesg='What is the path to the directory? ([]) '
        	. $dir/$echon_sh
        	read ans
            	echo $ans
		if [ `expr "//$ans" : '//[ 	]*$'` -eq 0 ]; then
            	    Maplelib=$ans
        	else
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo ''
    echo "    Sorry! Directory path is blank . . ."
    echo ''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                    . $dir/$abort_sh
		fi
        	(cd $Maplelib) >/dev/null 2>&1
        	if [ $? -ne 0 ]; then
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo ''
    echo "    Sorry! Directory '$Maplelib' does not exist . . ."
    echo ''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                    . $dir/$abort_sh
		else
		    rm -f $MATLAB/toolbox/symbolic/$libname > /dev/null 2>&1
		    (cd $MATLAB/toolbox/symbolic; ln -s $Maplelib $libname)
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo ''
    echo 'Symbolic link created . . .'
    echo ''
    echo '     $MATLAB/toolbox/symbolic/'"$libname"' -> '"$Maplelib"
    echo ''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		fi
            else
#
# Symbolic toolbox already exists. Output message that it already exists
# and the supplied path is ignored.
#
	        read ans
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo ''
    echo '-----------------------------------------------------------------'
    echo "The directory for the $libmsg libraries was found in the"
    echo 'symbolic toolbox.'
    echo ''
    echo 'The directory was NOT changed to:' 
    echo ''
    echo "        $ans"
    echo ''
    echo 'If you want to use your copy please be sure that your version'
    echo "is compatiable with MATLAB's version. You will have to manually"
    echo 'make the changes in'
    echo ''
    echo '        $MATLAB/toolbox/symbolic'
    echo '-----------------------------------------------------------------'
    echo ''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            fi
	fi
    else
#
#----------------------------------------------------------------------------
# interactive:
#----------------------------------------------------------------------------
#
        if [ -d $MATLAB/toolbox/symbolic ]; then
	    (cd $MATLAB/toolbox/symbolic/$libname) >/dev/null 2>&1
            if [ $? -ne 0 ]; then
                while true
    	        do
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo ''
    echo "Symbolic toolbox: No $libmsg library directory found." 
    echo ''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        	    mesg='What is the path to the directory? ([]) '
        	    . $dir/$echon_sh
        	    read ans
		    if [ `expr "//$ans" : '//[ 	]*$'` -eq 0 ]; then
            	        Maplelib=$ans
        	    else
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo ''
    echo "    Sorry! Directory path is blank . . ."
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		        continue
		    fi
        	    (cd $Maplelib) >/dev/null 2>&1
        	    if [ $? -ne 0 ]; then
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo ''
    echo "    Sorry! Directory '$Maplelib' does not exist . . ."
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		        continue
		    else
		        rm -f $MATLAB/toolbox/symbolic/$libname > /dev/null 2>&1
		        (cd $MATLAB/toolbox/symbolic; ln -s $Maplelib $libname)
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    echo ''
    echo 'Symbolic link created . . .'
    echo ''
    echo '     $MATLAB/toolbox/symbolic/'"$libname"' -> '"$Maplelib"
    echo ''
    echo ''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		        break
		    fi
	        done
	    fi
#
	fi
    fi
