#!/bin/csh
# This is a program for the example Genesis Tooling Forms.
# This file will exist in both forms (1 and 2).
# The purpose of this program is to display the system input report to the user.
# It is called by the "View Input / Set-up Report" button.
# 
# Written by Ian Ticehurst (Autom8 Ltd.)
# Version 1A. Date: 07.09.00 - Initial design and development.
# Version 1B. Date: 11.12.00 - Add source of info. file to support gui creation.
# Version 1C. Date: 12.12.00 - Re-write the gui windows to use the sourced font and colours.
# Version 1D. Date: 05.02.01 - Modify to only check job path if job moved from original location.
# Version 1E. Date: 09.02.01 - Modify the setting and useage of $TMP.
#                            - Add check to ensure that files exist in the report directory.
# Version 1F. Date: 14.03.01 - Check how "$GENESIS_EDIR" is set to ensure paths are set correctly.
# Version 1G. Date: 14.03.01 - Change default texteditor to use the command "form_callback_editor".
######################################################################### 

source $_genesis_root/sys/scripts/include_me

set FOUND = 0
if (-e $JOB_PATH/user/input_reports) then
   set IR_TST = `ls $JOB_PATH/user/input_reports | wc -l`
   if ($IR_TST != 0) then
      set FOUND = 1
      # Put window on screen asking user to select input report to view.
      o_tooling
      o FONT $NORM_FNT
      o BG $NORM_COL
      o BW 0
      o LABEL Input File Selection Pop-up
      o LABEL Select the input file to view from the list
      o BG $LSTBG_COL
      o LIST inp_file 5 S
      ls $JOB_PATH/user/input_reports >> $GUI_DATA
      o END
      o BG $NORM_COL
      o END

      do_gui
	
      cp $JOB_PATH/user/input_reports/$inp_file $TMP/tmp_ir.$$
      chmod 444 $TMP/tmp_ir.$$
      cd $TMP
      COM form_callback_editor,path=$TMP/tmp_ir.$$
      \rm -f $TMP/tmp_ir.$$
   endif
endif

# If no dir. or files found warn user.
if ($FOUND == 0) then
   echo No input reports found
   exit 1
endif

exit 0
