if [ $2 -eq 0 ]
then
	dialog --yesno "Automate names ?" 5 60
	an=$?
	msg="Save to file:"
	cname=$1
	error=0
	skp=0
	j=0
	fnt=`tail -1 $1`
	dialog --infobox "Starting..." 3 30
	while [ $error -eq 0 ]
	do
		(dd if=/dev/st0 of=sur bs=1024 skip=$skp)2>/dev/null
		if [ $? -ne 0 ] 
		then
			error=1
		else
			mt rewind
			if [ $? -ne 0 ]
			then
				error=1
			fi
			jj=`expr $j + 2`
			skp=`head -n $jj $1 | tail -n +$jj`
			if [ $skp -eq $fnt ]
			then
				error=1
			fi
			j=`expr $j + 1`
			conv.sol > /dev/null
			rm sur
			if [ $an -eq 0 ]
			then
				ddate=`head -n 1 temp0008.ds | tail -n +1`
				ddate=`echo "$ddate" | cut -c 4-5`
				ndate=`head -n 2 temp0008.ds | tail -n +2`
				symb=`echo "$ndate" | cut -c 2`
				if `test -z $symb`
				then
					ndate=`echo "$ndate" | cut -c 3-5`
					ndate=0$ndate
					ddate=$ddate$ndate
				else
					ndate=`echo "$ndate" | cut -c 2-5`
					ddate=$ddate$ndate
				fi
				(rm temp0008.ds)2>/dev/null
 				mv conv.out "$ddate.sds"
			else
				( dialog --inputbox "$msg" 8 60 )2>temp0002.ds
				sname=`cat temp0002.ds`
				rm temp0002.ds
				mv conv.out "$sname.sds"
			fi
			dialog --infobox "Readed $j record. $skp" 3 70
		fi
	done
	dialog --msgbox "Readed $j records" 8 60
else
	(dialog --inputbox "Save to file: " 8 60)2>temp0002.ds
	sname=`cat temp0002.ds`
	rm temp0002.ds
	dialog --infobox "Starting ..." 3 60
	if [ $2 -eq 1 ]
	then
		skp=0
	else
		skp=`head -n $2 $1 | tail -n +$2`
	fi
	(dd if=/dev/st0 of=sur bs=1024 skip=$skp)2>/dev/null
	mt rewind
	conv.sol >> /dev/null
	mv conv.out "$sname.sds"
	s=`ls -ks sur`
	rm sur
	num=""
	ef=1
	i=0
	while [ $ef -ne 0 ] 
	do
		i=`expr $i + 1`
		k=`echo $s | cut -c $i`
		scmp $k " "
		if [ $? -eq 0 ]
		then 
			num=$num$k
		else
			ef=0
		fi
	done
	dialog	--msgbox " Succsesfully readed $num KB " 8 60	 	
fi
