#!/bin/csh -f
#
# This script generate a shooting script 
#
# P. Martin  softimage France 
# Date : Thu Jul 20 10:34:07 GMT 1995
#
#	E Mail : pmartin@microsoft.com
#
#

        echo "----------------------------------------------"
        echo "Build shoot Process file Softimage France 1995"

if($#argv < 1 ) then
        echo
        echo "Usage : shootAuto <Name>"
        echo "----------------------------------------------"
        exit (-1)
endif
        echo "----------------------------------------------"


set File = $1
set Type = -t


if ( -e $File ) then
	echo -n "Warning: $File already exist, [R]eplace [A]ppen [E]xit : "
	set Test = $< 

	switch ($Test)
		case	'r' :
			echo "Creatting new $File file."
			echo "#" > $File
			breaksw
		case	'R' :
			echo "Creatting new $File file."
			echo "#" > $File
			breaksw
		case	'a' :
			breaksw
		case	'A' :
			breaksw
		case	'E' :
			exit -1
 		default :
	                exit -1
	endsw

else
	echo "Creatting $File"
	echo "#" > $File
endif

	set ADL = 0
	echo -n "\nAutomatic Down Loading [y/n] : "
	set Auto = $< 
	if ( $Auto == 'y' ) then
		set ADL = 1
	endif
	if ( $Auto == 'yes' ) then
		set ADL = 1
	endif

	echo ""

	set Time = `date`
	echo "\n\n#\n#==============  shootAuto $Time =================" >> $File
	
while ( 1 )
	echo ""
	echo -n "Images Name : "
	set Image = $< 
	if ( $Image == '' ) then
		break
	endif

	set Mask = ''
	set Mask_ = ''

	if ( $ADL == '1' ) then
		echo -n "Image Start : "
		set Start = $< 
		echo -n "Image End   : "
		set End = $< 

		echo -n "Shoot Mask [y/n] : "
		set YORN = $< 
		if ( $YORN == 'y' ) then
			set Mask = -m
			set Mask_ = mask
		endif

	endif

	echo -n "Time Code on beta : "
	set TC = $< 

	echo -n "Image on WSD : "
	set DIN = $< 

	set DUR = 0
	if ( $ADL == 1 ) then
		@ DUR = 1 + $End - $Start
	else 
		echo -n "Length       : "
		set DUR = $< 
	endif

	echo -n "Commentaire : "
	set COM = $< 

	if ( $COM != "err" ) then
		echo "#\n#  Commentaire : $COM    <$Mask_> \n#" >> $File

		if ( $ADL == 1 ) then
			echo "set Date = \140date\140" >> $File
			echo "echo \042\044Date - Warning Mask only\042 \076\076 ~/master.log" >> $File
			echo "echo \042\044Date - sent $Image $Mask_ from $Start to $End in wsd\042 \076\076 ~/master.log" >> $File
			echo "echo \042\044Date - sent $Image $Mask_ from $Start to $End in wsd\042 \076\076 $Image.log" >> $File
			echo "diskus_record $Image $Start $End 1 $DIN $Type $Mask" >> $File
		endif
	
		if ( $TC  != '' ) then
			echo "set TCode = $TC" >> $File
		endif

		echo "set Date = \140date\140" >> $File
		echo "echo \042\044Date - to Beta $Image $Mask_ TC In  : \044TCode  Duration : $DUR $Mask\042 \076\076 ~/master.log" >> $File
		echo "set TCode = \140diskus_vtr_record -b \044TCode -d $DIN $DUR -q -O\140" >> $File
		echo "echo \042\044Date - to Beta $Image $Mask_ TC Out : \044TCode  \042 \076\076 ~/master.log" >> $File
		echo "echo \042====================================================\042 \076\076 ~/master.log" >> $File
		echo "#=================================================================================" >> $File
	endif

end

cat 	$File
chmod a+x $File
echo 
echo "Done .\n"
echo "Just type <$File> to run it.\n"
