# File Name:    out_file
# File Purpose: This file is called during the ADM process. It is a c-shell
#               script which is used to manipulate various parts of the output
#               file dependant on the tool parameters and the machine file being
#               used etc.
# Written by:   Ian Ticehurst (Autom8 Ltd.)
# Version 1A.:  Date: 15.09.00 - Initial design and development.
# Version 1B.:  Date: 27.10.00 - Addition of specific routines to match machine file names.
# Version 1C.:  Date: 05.12.00 - Removal of "gui" alias and "gui" data and response settings (not used).
# Version 1D.:  Date: 16.01.01 - Add check for NT shell version. Also modify gawk calls dependant on version.
# Version 1E.:  Date: 20.02.01 - Ensure that all "gawk" calls are modified to "awk" and that "awk95" is aliased.
############################# Start of notes ###############################
# This file is located in the hooks/ncd directory and forms part of the Auto Drill
# Manager file set. It is a c-shell script which can be configured to provide user
# and site specific modifications to the drill output files dependant on the different
# parameters allocated to each tool (type, size, hole/slot etc.) and also the machine
# file being used. 
# This script is started with one parameter passed to it. This parameters is a file
# which can be sourced ($1). This source file contains details of the drill table and
# the ADM parameters and this is the information that can be used to define any actions
# required. The file contains the following formatted information:-
#
#set ncLAYER = (drill )
#set ncSET = (test)
#set ncMACHINE = (hittachi )
#set ncNUM_STAGES = (2 )
#set ncNUM_SPLITS = (1 )
#set ncSTAGE = (2 )
#set ncSPLIT = (1 )
#set ncFORMAT = (Excellon2 )
#set ncZEROES = (trailing )
#set ncINCREMNTAL = (no)
#set ncREPETITIONS = (sr)
#set ncUNITS = (inch )
#set ncTOOL_UNITS = (inch )
#set ncNF = (2.4 )
#set ncHEADER_PATH = ("" )
#set ncEOF_PATH = (/genesis/tmp/genesis186b5.1471 )
#set ncTOOL_NUM      = (1      2      3      )
#set ncTOOL_SIZE     = (35.354 74     94     )
#set ncTOOL_SIZE2    = (.035   .074   .094   )
#set ncTOOL_MAX_HITS = (5000   500    500    )
#set ncTOOL_HITS     = (134    14     12     )
#set ncTOOL_SPEED    = (300    300    300    )
#set ncTOOL_FEED     = (85     85     85     )
#set ncTOOL_NIBBLE   = (no     yes    no     )
#set ncTOOL_SLOT     = (yes    no     no     )
#set ncTOOL_CHANGE   = (""     ""     ""     )
#set ncTOOL_FINISH   = (""     ""     ""     )
#set ncFULL_STEP      = ('c1'                              )
#set ncFULL_SR_START  = ('/genesis/tmp/genesis18715.14636' )
#set ncFULL_SR_END    = ('/genesis/tmp/genesis18716.14636' )
#set ncSR_NAME   = (pcb     pcb     pcb     coupon  panel)
#set ncSERIAL    = (1       2       3       4       5)
#set ncSR_DX     = (1.025   1.025   1.025   0.53    0)
#set ncSR_DY     = (0.75    4.75    8.75    6.5     0)
#set ncSR_ANGLE  = (0       0       0       270     0)
#set ncSR_MIRROR = (0       0       0       0       0)
#set ncFULL      = (0       0       0       0       0)
#
# This file can control the following parts of the output files:-
# 1. The header.                   --- ncHEADER_PATH 
# 2. The end of file.              --- ncEOF_PATH 
# 3. The tool changes.             --- ncTOOL_CHANGE
# 4. The tool finish.              --- ncTOOL_FINISH
# 5. The step and repeat start.    --- ncFULL_SR_START 
# 6. The step and repeat finish.   --- ncFULL_SR_END  
# (Note: the last two options are only available when full step and repeat mode is used
# which is set by the step entity attribute output drill output (yes/no))  
#
# It should be noted that there is no single output file (as with the set_table hook)
# and the output files are defined by the variables list in notes 1-7 above. These
# variables are only set if the machine file is set to use this out_file program for
# that specific section. Thus, by testing each variable it is possible to know if
# the custom output should be used. It will also be noted that some variables apply
# to the complete output file (ncHEADER_PATH for example) and some apply to each of
# the tool entries being passed.
# If the machine file has any of these sections set to yes, then the program must
# provide that section of the output file. Also, if the machine file has any of these
# sections set to no, the program for that section is ignored.
############################# End of notes ################################ 

# Section to set up general parameters and variables.
# ---------------------------------------------------
# Define correct temp. dir. depending on env. vars.
if ($?GENESIS_TMP) then
	set TMP = $GENESIS_TMP
else if ($?GENESIS_DIR) then
	set TMP = $GENESIS_DIR/tmp
else
	set TMP = /genesis/tmp
endif

# Set the INFO alias and the tmp INFO file.
set INFO = $TMP/info
alias DO_INFO 'COM info,out_file=$INFO,write_mode=replace,args=\!:*;source $INFO;rm $INFO'

# Detect current operating system.
set CURR_OS = `uname -s`

# If current operating system is NT, set alias to call awk95 as "awk".
if ($CURR_OS == "WINDOWS_NT") then
	alias awk '$GENESIS_DIR/e${GENESIS_VER}/nt/bin/awk95'
endif

# Detect current tcsh version (old = 0, new = 1).
if ($CURR_OS == "WINDOWS_NT") then
	set NT_VER = `echo "$version" | awk -F'-' '{if ($7 < 5.0) print 0; else print 1}'`
endif

# Set variable names for parameter file to source and out_file to write to.
set source_script = $1

# Force units to inch.
COM ncset_units,units=inch

# Source standard parameter file.
source $source_script

# Header definition section.
# --------------------------
if ($ncHEADER_PATH != "") then
	if ($ncMACHINE == "default_excellon") then
		echo "M48" >  $ncHEADER_PATH
		echo "FMAT,2" >> $ncHEADER_PATH

		set i = 1
		while ($i <= $#ncTOOL_NUM) 
			echo "T"${ncTOOL_NUM[$i]}"C"${ncTOOL_SIZE2[$i]} >> $ncHEADER_PATH
			@ i ++
		end
		echo "VER,1" >> $ncHEADER_PATH
		echo "%" >> $ncHEADER_PATH
		if ($ncUNITS == "inch") then
			echo "M72" >> $ncHEADER_PATH
		else
			echo "M71" >> $ncHEADER_PATH
		endif
		echo "G90" >> $ncHEADER_PATH

	else if ($ncMACHINE == "default_sm3000") then
		# Note that in seibmeyer format the tool information is defined in the EOF section.
		echo "%%3000" >  $ncHEADER_PATH
		echo "G90" >>  $ncHEADER_PATH

	else if ($ncMACHINE == "default_hitachi") then
		echo "G48" >  $ncHEADER_PATH

		set i = 1
		while ($i <= $#ncTOOL_NUM) 
			if ($CURR_OS == "WINDOWS_NT") then
				if ($NT_VER == 0) then
					set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf (\"%2.2f\",($1 * 1.0))}'`
				else
					set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf ("%2.2f",($1 * 1.0))}'`
				endif
			else
				set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf ("%2.2f",($1 * 1.0))}'`
			endif
			echo "T"${ncTOOL_NUM[$i]}"C"${act_toolsize} >> $ncHEADER_PATH
			@ i ++
		end
		echo "%" >> $ncHEADER_PATH

	else if ($ncMACHINE == "hitachi_nd4p180e_20p") then
		echo "    M48" 			>  $ncHEADER_PATH
		echo "AFS,ON" 			>> $ncHEADER_PATH
		echo "ATC,ON" 			>> $ncHEADER_PATH
		echo "BLKD,OFF" 		      >> $ncHEADER_PATH
		echo "FMAT,2" 			>> $ncHEADER_PATH
		echo "ICI,OFF" 			>> $ncHEADER_PATH
		echo "METRIC,LZ,000.000" 	>> $ncHEADER_PATH
		echo "OM48,OFF" 	      	>> $ncHEADER_PATH
		echo "OSTOP,OFF" 		      >> $ncHEADER_PATH
		echo "R,T" 			      >> $ncHEADER_PATH
		echo "SBK,OFF" 			>> $ncHEADER_PATH
		echo "VER,1" 			>> $ncHEADER_PATH
		echo "R,H,T" 			>> $ncHEADER_PATH
		echo "/" 		      	>> $ncHEADER_PATH

		set i = 1
		set current_num = `echo "$#ncTOOL_NUM + 1" | bc`
		set current_num2 = `echo "$#ncTOOL_NUM + 2" | bc`
		while ($i <= $#ncTOOL_NUM) 
			echo $i"/"$current_num","$current_num2 >> $ncHEADER_PATH
			set current_num = `echo "$current_num + 2" | bc`
			set current_num2 = `echo "$current_num2 + 2" | bc`
			@ i ++
		end
		set i = 1
		while ($i <= $#ncTOOL_NUM)
			if ($CURR_OS == "WINDOWS_NT") then
				if ($NT_VER == 0) then
					set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf (\"%2.2f\",($1 * 1.0))}'`
				else
					set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf ("%2.2f",($1 * 1.0))}'`
				endif
				if (`echo $act_toolsize 0.7 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set n_hits = 1500
				else if (`echo $act_toolsize 0.7 | awk '{if ($1 > $2) print 1; else print 0}'` == 1 && `echo $act_toolsize 2.0 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set n_hits = 2250
				else if (`echo $act_toolsize 2.0 | awk '{if ($1 > $2) print 1; else print 0}'` == 1 && `echo $act_toolsize 3.05 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set n_hits = 500
				else
					set n_hits = 250
				endif
			else
				set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf ("%2.2f",($1 * 1.0))}'`
				if (`echo $act_toolsize 0.7 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set n_hits = 1500
				else if (`echo $act_toolsize 0.7 | awk '{if ($1 > $2) print 1; else print 0}'` == 1 && `echo $act_toolsize 2.0 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set n_hits = 2250
				else if (`echo $act_toolsize 2.0 | awk '{if ($1 > $2) print 1; else print 0}'` == 1 && `echo $act_toolsize 3.05 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set n_hits = 500
				else
					set n_hits = 250
				endif
			endif
			echo "T"{$ncTOOL_NUM[$i]}"C"{$act_toolsize}"H"$n_hits >> $ncHEADER_PATH
			@ i ++
		end
	
		echo "Z,XY" >> $ncHEADER_PATH
		echo "%" >> $ncHEADER_PATH

	else if ($ncMACHINE == "hitachi_nd1w21_modular") then
		echo "    M48" 			>  $ncHEADER_PATH
		echo "METRIC,LZ,000.000" 	>> $ncHEADER_PATH
		echo "VER,1" 			>> $ncHEADER_PATH
		echo "/0" 		      	>> $ncHEADER_PATH

		set i = 1
		while ($i <= $#ncTOOL_NUM) 
			if ($CURR_OS == "WINDOWS_NT") then
				if ($NT_VER == 0) then
					set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf (\"%2.2f\",($1 * 1.0))}'`
				else
					set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf ("%2.2f",($1 * 1.0))}'`
				endif
			else
				set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf ("%2.2f",($1 * 1.0))}'`
			endif
			echo "T"{$ncTOOL_NUM[$i]}"C"{$act_toolsize} >> $ncHEADER_PATH
			@ i ++
		end
	
		echo "Z,XY" >> $ncHEADER_PATH
		echo "%" >> $ncHEADER_PATH

	else if ($ncMACHINE == "excellon_mark6") then
		set DATE = `date`
		echo "M48" >> $ncHEADER_PATH
		echo ";Drill file for $JOB - $DATE" >> $ncHEADER_PATH
		echo "FMAT,2" >> $ncHEADER_PATH
		echo "VER,1" >> $ncHEADER_PATH
		echo "METRIC" >> $ncHEADER_PATH

		set i = 1
		while ($i <= $#ncTOOL_NUM) 
			if ($CURR_OS == "WINDOWS_NT") then
				if ($NT_VER == 0) then
					set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf (\"%2.2f\",($1 * 1.0))}'`
				else
					set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf ("%2.2f",($1 * 1.0))}'`
				endif
			else
				set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf ("%2.2f",($1 * 1.0))}'`
			endif

			if ($i <= 9) then
				echo "T0${i}C${act_toolsize}" >> $ncHEADER_PATH
			else
				echo "T${i}C${act_toolsize}" >> $ncHEADER_PATH
			endif
			@ i ++
		end
		
		echo "ICI,OFF" >> $ncHEADER_PATH
		echo "INCH,LZ" >> $ncHEADER_PATH
		echo "%" >> $ncHEADER_PATH

	else if ($ncMACHINE == "pluritec_giga88") then
		# Note that in seibmeyer format the tool information is defined in the EOF section.
		echo "%%3000" >  $ncHEADER_PATH
		echo "G90" >>  $ncHEADER_PATH

	else
		echo "HEADER SECTION IN out_file NOT DEFINED" > $ncHEADER_PATH
		echo "Current machine file does not have matching header details" >> $ncHEADER_PATH
	endif
endif

# End of file (EOF) definition section.
# -------------------------------------
if ($ncEOF_PATH != "") then
	if ($ncMACHINE == "default_excellon") then
		echo "M00" > $ncEOF_PATH
		echo "M30" >> $ncEOF_PATH

	else if ($ncMACHINE == "default_sm3000") then
		set i = 1
		while ($i <= $#ncTOOL_NUM)
			if ($CURR_OS == "WINDOWS_NT") then
				if ($NT_VER == 0) then
					set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf (\"%2.0f\",($1 * 100))}'`
				else
					set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf ("%2.0f",($1 * 100))}'`
				endif
			else
				set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf ("%2.0f",($1 * 100))}'`
			endif
			
			set CHAR = '$'
			if ($i == 1) then
				echo "${CHAR}T${i}D${act_toolsize}" > $ncEOF_PATH
			else
				echo "T${i}D${act_toolsize}" >> $ncEOF_PATH
			endif
			@ i ++
		end

	else if ($ncMACHINE == "default_hitachi") then
		echo "T00" > $ncEOF_PATH
		echo "M02" > $ncEOF_PATH
		echo "%" > $ncEOF_PATH

	else if ($ncMACHINE == "hitachi_nd4p180e_20p") then
		# Note that this machine file does not request special end of file definition.

	else if ($ncMACHINE == "hitachi_nd1w21_modular") then
		# Note that this machine file does not request special end of file definition.

	else if ($ncMACHINE == "excellon_mark6") then
		# Note that this machine file does not request special end of file definition.

	else if ($ncMACHINE == "pluritec_giga88") then
		set i = 1
		while ($i <= $#ncTOOL_NUM)
			set CHAR = '$'
			if ($CURR_OS == "WINDOWS_NT") then
				if ($NT_VER == 0) then
					set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf (\"%2.2f\",($1 * 1.0))}'`
				else
					set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf ("%2.2f",($1 * 1.0))}'`
				endif
				if (`echo $act_toolsize 0.5 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set speed = 100000
					set feed = 138
					set max_hits = 1500
				else if (`echo $act_toolsize 0.5 | awk '{if ($1 > $2) print 1; else print 0}'` == 1 && `echo $act_toolsize 1.0 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set speed = 70000
					set feed = 150
					set max_hits = 2500
				else if (`echo $act_toolsize 1.0 | awk '{if ($1 > $2) print 1; else print 0}'` == 1 && `echo $act_toolsize 2.0 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set speed = 35000
					set feed = 160
					set max_hits = 2000
				else if (`echo $act_toolsize 2.0 | awk '{if ($1 > $2) print 1; else print 0}'` == 1 && `echo $act_toolsize 3.0 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set speed = 25000
					set feed = 180
					set max_hits = 1800
				else if (`echo $act_toolsize 3.0 | awk '{if ($1 > $2) print 1; else print 0}'` == 1 && `echo $act_toolsize 4.0 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set speed = 23000
					set feed = 200
					set max_hits = 1600
				else if (`echo $act_toolsize 4.0 | awk '{if ($1 > $2) print 1; else print 0}'` == 1 && `echo $act_toolsize 5.0 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set speed = 20000
					set feed = 200
					set max_hits = 1000
				else
					set speed = 19000
					set feed = 210
					set max_hits = 900
				endif
				if ($NT_VER == 0) then
					set act_toolsize = `echo $act_toolsize | awk '{printf (\"%2.0f\",($1 * 100))}'`
				else
					set act_toolsize = `echo $act_toolsize | awk '{printf ("%2.0f",($1 * 100))}'`
				endif
			else
				set act_toolsize = `echo $ncTOOL_SIZE2[$i] | awk '{printf ("%2.2f",($1 * 1.0))}'`
				if (`echo $act_toolsize 0.5 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set speed = 100000
					set feed = 138
					set max_hits = 1500
				else if (`echo $act_toolsize 0.5 | awk '{if ($1 > $2) print 1; else print 0}'` == 1 && `echo $act_toolsize 1.0 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set speed = 70000
					set feed = 150
					set max_hits = 2500
				else if (`echo $act_toolsize 1.0 | awk '{if ($1 > $2) print 1; else print 0}'` == 1 && `echo $act_toolsize 2.0 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set speed = 35000
					set feed = 160
					set max_hits = 2000
				else if (`echo $act_toolsize 2.0 | awk '{if ($1 > $2) print 1; else print 0}'` == 1 && `echo $act_toolsize 3.0 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set speed = 25000
					set feed = 180
					set max_hits = 1800
				else if (`echo $act_toolsize 3.0 | awk '{if ($1 > $2) print 1; else print 0}'` == 1 && `echo $act_toolsize 4.0 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set speed = 23000
					set feed = 200
					set max_hits = 1600
				else if (`echo $act_toolsize 4.0 | awk '{if ($1 > $2) print 1; else print 0}'` == 1 && `echo $act_toolsize 5.0 | awk '{if ($1 < $2) print 1; else print 0}'` == 1) then
					set speed = 20000
					set feed = 200
					set max_hits = 1000
				else
					set speed = 19000
					set feed = 210
					set max_hits = 900
				endif
				set act_toolsize = `echo $act_toolsize | awk '{printf ("%2.0f",($1 * 100))}'`
			endif

			if ($i == 1) then
       			echo "${CHAR}T${i}D${act_toolsize}S${speed}F${feed}N${max_hits}" >> $ncEOF_PATH
			else
				echo "T${i}D${act_toolsize}S${speed}F${feed}N${max_hits}" >> $ncEOF_PATH
			endif
			@ i ++
		end
	else
		echo "EOF SECTION IN out_file NOT DEFINED" > $ncEOF_PATH
		echo "Current machine file does not have matching end of file details" >> $ncEOF_PATH
	endif
endif

# Tool change definition section.
# -------------------------------
set i = 1
while ($i <= $#ncTOOL_NUM) 
	if ($ncTOOL_CHANGE[$i] != "") then
		if ($ncMACHINE == "default_excellon") then
			if ($ncTOOL_NUM[$i] == 2) then
				echo "T${ncTOOL_NUM[$i]}" > $ncTOOL_CHANGE[$i]
				echo "M98,$JOB" >> $ncTOOL_CHANGE[$i]
				echo "X003Y005" >> $ncTOOL_CHANGE[$i]
			else
				echo "T${ncTOOL_NUM[$i]}" > $ncTOOL_CHANGE[$i]
			endif

		else if ($ncMACHINE == "default_sm3000") then
			if ($ncTOOL_NUM[$i] <= 9) then
				echo "T0${ncTOOL_NUM[$i]}" > $ncTOOL_CHANGE[$i]
			else
				echo "T${ncTOOL_NUM[$i]}" > $ncTOOL_CHANGE[$i]
			endif

		else if ($ncMACHINE == "default_hitachi") then
			if ($ncTOOL_NUM[$i] <= 9) then
				echo "T0${ncTOOL_NUM[$i]}" > $ncTOOL_CHANGE[$i]
			else
				echo "T${ncTOOL_NUM[$i]}" > $ncTOOL_CHANGE[$i]
			endif

		else if ($ncMACHINE == "hitachi_nd4p180e_20p") then
			if ($ncTOOL_NUM[$i] <= 9) then
				echo "T0${ncTOOL_NUM[$i]}" > $ncTOOL_CHANGE[$i]
			else
				echo "T${ncTOOL_NUM[$i]}" > $ncTOOL_CHANGE[$i]
			endif

		else if ($ncMACHINE == "hitachi_nd1w21_modular") then
			if ($ncTOOL_NUM[$i] <= 9) then
				echo "T0${ncTOOL_NUM[$i]}" > $ncTOOL_CHANGE[$i]
			else
				echo "T${ncTOOL_NUM[$i]}" > $ncTOOL_CHANGE[$i]
			endif

		else if ($ncMACHINE == "excellon_mark6") then
			if ($ncTOOL_NUM[$i] <= 9) then
				echo "T0${ncTOOL_NUM[$i]}" > $ncTOOL_CHANGE[$i]
			else
				echo "T${ncTOOL_NUM[$i]}" > $ncTOOL_CHANGE[$i]
			endif

		else if ($ncMACHINE == "pluritec_giga88") then
			if ($ncTOOL_NUM[$i] <= 9) then
				echo "T0${ncTOOL_NUM[$i]}" > $ncTOOL_CHANGE[$i]
			else
				echo "T${ncTOOL_NUM[$i]}" > $ncTOOL_CHANGE[$i]
			endif
		else
			echo "TOOL CHANGE SECTION IN out_file NOT DEFINED" > $ncTOOL_CHANGE[$i]
			echo "Current machine file does not have matching tool change details" >> $ncTOOL_CHANGE[$i]
		endif
	endif
   	@ i ++
end

# Tool finish definition section.
# -------------------------------
set i = 1
while ($i <= $#ncTOOL_NUM) 
	if ($ncTOOL_FINISH[$i] != "") then
		if ($ncMACHINE == "default_excellon") then
			echo "T0" > $ncTOOL_FINISH[$i]

		else if ($ncMACHINE == "default_sm3000") then
			# Note that extra tool finish commands are not usually required.

		else if ($ncMACHINE == "default_hitachi") then
			# Note that extra tool finish commands are not usually required.

		else if ($ncMACHINE == "hitachi_nd4p180e_20p") then
			# Note that this machine file does not request special end of tool definition.

		else if ($ncMACHINE == "hitachi_nd1w21_modular") then
			# Note that this machine file does not request special end of tool definition.

		else if ($ncMACHINE == "excellon_mark6") then
			# Note that this machine file does not request special end of tool definition.

		else if ($ncMACHINE == "pluritec_giga88") then
			# Note that this machine file does not request special end of tool definition.

		else
			echo "TOOL FINISH SECTION IN out_file NOT DEFINED" > $ncTOOL_FINISH[$i]
			echo "Current machine file does not have matching tool finish details" >> $ncTOOL_FINISH[$i]
		endif
	endif
   	@ i ++
end

# Full step and repeat start definition section.
# ----------------------------------------------
if ($?ncFULL_SR_START) then
	if ($ncMACHINE == "default_excellon") then
		echo "M25" > $ncFULL_SR_START

	else if ($ncMACHINE == "default_sm3000") then
		# Note that this section is not active in siebmeyer format.

	else if ($ncMACHINE == "default_hitachi") then
		# Note that this section is not active in hitachi format.

	else if ($ncMACHINE == "hitachi_nd4p180e_20p") then
		# Note that this machine file does not request special step and repeat start definition.

	else if ($ncMACHINE == "hitachi_nd1w21_modular") then
		# Note that this machine file does not request special step and repeat start definition.

	else if ($ncMACHINE == "excellon_mark6") then
		# Note that this machine file does not request special step and repeat start definition.

	else if ($ncMACHINE == "pluritec_giga88") then
		# Note that this section is not active in siebmeyer format.

	else
		echo "S+R START SECTION IN out_file NOT DEFINED" > $ncFULL_SR_START
		echo "Current machine file does not have matching s+r start details" >> $ncFULL_SR_START
	endif
endif

# Full step and repeat end definition section.
# --------------------------------------------
if ($?ncFULL_SR_END) then
	if ($ncMACHINE == "default_excellon") then
		echo "M02" > $ncFULL_SR_END
		echo "M08" >> $ncFULL_SR_END

	else if ($ncMACHINE == "default_sm3000") then
		# Note that this section is not active in siebmeyer format.

	else if ($ncMACHINE == "default_hitachi") then
		# Note that this section is not active in hitachi format.

	else if ($ncMACHINE == "hitachi_nd4p180e_20p") then
		# Note that this machine file does not request special step and repeat end definition.

	else if ($ncMACHINE == "hitachi_nd1w21_modular") then
		# Note that this machine file does not request special step and repeat end definition.

	else if ($ncMACHINE == "excellon_mark6") then
		# Note that this machine file does not request special step and repeat end definition.

	else if ($ncMACHINE == "pluritec_giga88") then
		# Note that this section is not active in siebmeyer format.

	else
		echo "S+R END SECTION IN out_file NOT DEFINED" > $ncFULL_SR_END
		echo "Current machine file does not have matching s+r end details" >> $ncFULL_SR_END
	endif
endif

exit


