#!/bin/csh
# File Name:    post_output
# File Purpose: This file is a c-shell script that is called after any output
#               is performed. It can be used to post process files, copy data,
#               compress files for achiving etc.
# Written by:   Ian Ticehurst (Autom8 Ltd.)
# Version 1A.:  Date: 17.08.00 - Initial design and development.
# Version 1B.:  Date: 27.10.00 - Addition of $TMP definition and useage.
# Version 1C.:  Date: 05.12.00 - Removal of "gui" alias.
############################# Start of notes ###############################
# This file is called whenever any output is created using the output page. It is
# called after the file(s) have been created. As this hook is a c-shell script it
# can perform any action required. It gets passed a sinle parameter, which is the
# name of a file that should be sourced. This will import the following variables:-
#    $outDIR - set to the output directory.
#    $outFORMAT - set to the output format used.
# In addition to this the script can also use the environment variables $JOB and
# $STEP. Thus it becomes a simple task to create a program which can perform many
# functions dependant on the step type being output, the format used, or the output
# directory defined.
# Some simple example functions are written below, however all the lines have been
# commented out to avoid the script running everytime the output is used. In order
# to see how each section works simply remove the coment (#) marker from the start
# of the code lnes (take care not to remove this character from real comment lines).
# Note that the format definition is case sensitive.
############################# End of notes ###############################
# 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 up gui data and response files
set GUI_DATA = $TMP/gui_data.$$
set GUI_RESP = $TMP/gui_resp.$$

# Source the system created file (set the outDIR and outFORMAT variables).
source $1

## Example One - Put a window on screen showing the variables used.
#echo "WIN 200 200" >> $GUI_DATA
#echo "FONT tbr14" >> $GUI_DATA
#echo "BG 222299" >> $GUI_DATA
#echo "FG 999999" >> $GUI_DATA
#echo "LABEL Frontline Default Hook Pop-up" >> $GUI_DATA
#echo "LABEL This is the default hook post_output" >> $GUI_DATA
#echo "LABEL It is located in $GENESIS_DIR/sys/hooks" >> $GUI_DATA
#echo "LABEL The hook is designed to perform actions after output of data" >> $GUI_DATA
#echo "LABEL Comments and possible applications can be found in the header of this hook" >> $GUI_DATA
#echo "LABEL Also see the hooks readme file and on-line manual 0203 (chapter 9) for more details" >> $GUI_DATA
#echo "FONT tbi14" >> $GUI_DATA
#echo "BG 883355" >> $GUI_DATA
#echo "LABEL EXAMPLE SECTION ONE..............." >> $GUI_DATA
#echo "LABEL Variables available to this hook are:-" >> $GUI_DATA
#echo "LABEL JOB is set to $JOB" >> $GUI_DATA
#echo "LABEL STEP is set to $STEP" >> $GUI_DATA
#echo "LABEL outDIR is set to $outDIR" >> $GUI_DATA
#echo "LABEL outFORMAT is set to $outFORMAT" >> $GUI_DATA
#echo "FONT tbr14" >> $GUI_DATA
#echo "BG 222299" >> $GUI_DATA
#echo "END" >> $GUI_DATA

#gui $GUI_DATA
#\rm $GUI_DATA

## Example Two - If gerber output is used, list all files in output directory.
## Test output format used
#if ($outFORMAT == "Gerber") then
#	# Create window to display file list.
#	echo "WIN 200 200" >> $GUI_DATA
#	echo "FONT tbr14" >> $GUI_DATA
#	echo "BG 222299" >> $GUI_DATA
#	echo "FG 999999" >> $GUI_DATA
#	echo "LABEL Frontline Default Hook Pop-up" >> $GUI_DATA
#	echo "LABEL This is the default hook post_output" >> $GUI_DATA
#	echo "LABEL It is located in $GENESIS_DIR/sys/hooks" >> $GUI_DATA
#	echo "LABEL The hook is designed to perform actions after output of data" >> $GUI_DATA
#	echo "LABEL Comments and possible applications can be found in the header of this hook" >> $GUI_DATA
#	echo "LABEL Also see the hooks readme file and on-line manual 0203 (chapter 9) for more details" >> $GUI_DATA
#	echo "FONT tbi14" >> $GUI_DATA
#	echo "BG 883355" >> $GUI_DATA
#	echo "LABEL EXAMPLE SECTION TWO..............." >> $GUI_DATA
#	echo "LABEL Files located in the output directory are:-" >> $GUI_DATA
#	# Get list of files in output directory.
#	set FILES = `ls $outDIR`
#	# Set maximum number of files to display (to avoid window getting bigger than screen).
#	set MAX_LIST = 20
#	set COUNT = 1
#	# For every file (up to maximum number) add line to pop-up.
#	foreach FILE ($FILES)
#		if ($COUNT != $MAX_LIST) then
#			echo "LABEL $FILE" >> $GUI_DATA
#			@ COUNT ++
#		endif
#	end
#	# If number of files exceeded maximum warn user.
#	if ($COUNT == $MAX_LIST) then
#		echo "FONT tbr14" >> $GUI_DATA
#		echo "BG 992222" >> $GUI_DATA
#		echo "LABEL WARNING - Unable to display all files" >> $GUI_DATA
#	endif
#	echo "FONT tbr14" >> $GUI_DATA
#	echo "BG 222299" >> $GUI_DATA
#	echo "END" >> $GUI_DATA

#	gui $GUI_DATA
#	\rm $GUI_DATA
#endif

## Example three - If excellon 2 output is used, count tools used in every available file.
#if ($outFORMAT == "Excellon2") then
#	# Create window to display file list.
#	echo "WIN 200 200" >> $GUI_DATA
#	echo "FONT tbr14" >> $GUI_DATA
#	echo "BG 222299" >> $GUI_DATA
#	echo "FG 999999" >> $GUI_DATA
#	echo "LABEL Frontline Default Hook Pop-up" >> $GUI_DATA
#	echo "LABEL This is the default hook post_output" >> $GUI_DATA
#	echo "LABEL It is located in $GENESIS_DIR/sys/hooks" >> $GUI_DATA
#	echo "LABEL The hook is designed to perform actions after output of data" >> $GUI_DATA
#	echo "LABEL Comments and possible applications can be found in the header of this hook" >> $GUI_DATA
#	echo "LABEL Also see the hooks readme file and on-line manual 0203 (chapter 9) for more details" >> $GUI_DATA
#	echo "FONT tbi14" >> $GUI_DATA
#	echo "BG 883355" >> $GUI_DATA
#	echo "LABEL EXAMPLE SECTION THREE..............." >> $GUI_DATA
#	echo "LABEL Number of tools in each file is:-" >> $GUI_DATA
#	# Get list of files in output directory.
#	set FILES = `ls $outDIR`
#	# For every file count "T" commands.
#	foreach FILE ($FILES)
#		# Set tool count to be number of lines with "T", that do not contain "C" (filter out line in header).
#		set T_COM = `grep -v "C" $outDIR/$FILE | grep -c "T"`
#		echo "LABEL $FILE has $T_COM tools" >> $GUI_DATA
#	end
#	echo "FONT tbr14" >> $GUI_DATA
#	echo "BG 222299" >> $GUI_DATA
#	echo "END" >> $GUI_DATA
#
#	gui $GUI_DATA
#	\rm $GUI_DATA
#endif

abort:

exit 
############################ END OF PROGRAM #####################