#!/bin/csh
# This is a program for the example Genesis Tooling Forms.
# This file will exist in form genform1 (but will be called by functions
# in both forms)
# The purpose of this program is to calculate and update the last save time.
# It is called by every process function in both forms.
# 
# Written by Ian Ticehurst (Autom8 Ltd.)
# Version 1A. Date: 02.02.01 - Initial design and development.
# Version 1B. Date: 05.02.01 - Change month format to string instead of numbers.
# Version 1C. Date: 09.02.01 - Modify the setting and useage of $TMP.
######################################################################### 
# 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'

# Set up gui data and response files.
set GUI_DATA = $TMP/gui_data.$$
set GUI_RESP = $TMP/gui_resp.$$

# Go to correct local job directory.
cd $JOB_PATH/misc

# Set year digits.
set YR = `cut -c 3-4 last_save`

# Set day of month digits.
set DY = `cut -c 7-8 last_save`

# Set month (use fixed strings).
set MH_DGT = `cut -c 5-6 last_save`

if ($MH_DGT == "01") then
	set MH = "Jan."
else if ($MH_DGT == "02") then
	set MH = "Feb."
else if ($MH_DGT == "03") then
	set MH = "Mar."
else if ($MH_DGT == "04") then
	set MH = "Apr."
else if ($MH_DGT == "05") then
	set MH = "May."
else if ($MH_DGT == "06") then
	set MH = "Jun."
else if ($MH_DGT == "07") then
	set MH = "Jul."
else if ($MH_DGT == "08") then
	set MH = "Aug."
else if ($MH_DGT == "09") then
	set MH = "Sep."
else if ($MH_DGT == "10") then
	set MH = "Oct."
else if ($MH_DGT == "11") then
	set MH = "Nov."
else if ($MH_DGT == "12") then
	set MH = "Dec."
endif

# Set time digits.
set HR = `cut -c 10-11 last_save`
set MN = `cut -c 12-13 last_save`

# Set time saved elements in forms.
COM edit_form,job=$JOB,form=genform1,elem=last_save,value=Last Save ${HR}:$MN $DY $MH $YR
COM edit_form,job=$JOB,form=genform2,elem=last_save,value=Last Save ${HR}:$MN $DY $MH $YR

abort:

exit
