#!/bin/bash
if test $1 = '-h'
then
echo "********************"
echo "***  GNUplot 4.2 ***"
echo "********************"
echo "4.2_gnuplot.bash '[TYP]'(0: console, -d: pdf, -p: PostScript, -s: see) '[FILE]'(file.gnu) 'SEE ps'(rest: No 1: Yes)"
else
file=$0
llfile=`expr length $file`
path=`expr $llfile - 17`
foresthome=`expr substr $file 1 $path`
foresthome=${foresthome}/..
llarx=`(expr length $2)`
llcosarx=`(expr $llarx - 4)`
arx=`expr substr $2 1 $llcosarx`
case $1 in
'0')
gnuplot
;;
'-d')
${foresthome}/bats/change_in_file.bash $2 ${arx}'.ps' ${arx}'.pdf'
${foresthome}/bats/multiple_FILEchange.bash $2 2 'terminal postscript' 2 'terminal pdf'
gnuplot $2
if test $3 -eq 1
then
/usr/bin/xpdf ${arx}.pdf &
fi
;;
'-p')
${foresthome}/bats/change_in_file.bash $2 ${arx}'.pdf' ${arx}'.ps'
${foresthome}/bats/multiple_FILEchange.bash $2 2 'terminal pdf' 2 'terminal postscript'
gnuplot $2
if test $3 -eq 1
then
/usr/bin/display ${arx}.ps &
fi
;;
'-v')
gnuplot -persist $2 &
esac

fi
