#!/bin/csh
# This is a program for the example Genesis Tooling Forms.
# This file will exist in form 1.
# The purpose of this program is to allow the user to select a pre-defined cleanup checklist
# that exists in the library.
# It is called by the "Select Cleanup Checklist" button.
# 
# Written by Ian Ticehurst (Autom8 Ltd.)
# Version 1A. Date: 11.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.
#                            - Add save time update to forms.
# Version 1E. Date: 09.02.01 - Modify the setting and useage of $TMP.
# Version 1F. Date: 14.03.01 - Check how "$GENESIS_EDIR" is set to ensure paths are set correctly.
######################################################################### 

source $_genesis_root/sys/scripts/include_me

set_in_progress genform1 sccl

# Close Form
COM close_form,job=$JOB,form=genform1

# Get a list of all checklists in the library.
DO_INFO -t step -e genesislib/checklib

# Allow user to select a cleanup checklist from the list (only offer checklists which contain "clean").
o_tooling
o FONT $NORM_FONT
o BG $NORM_COL
o BW 0
o LABEL Checklist Selection Pop-up
o LABEL Select desired cleanup checklist from the list below.
o BG $LSTBG_COL
o LIST cln_chk 5 S
foreach CHK ($gCHECKS_LIST)
   set TST = `echo "$CHK" | grep -c clean`
   if ($TST != 0) then
      o $CHK
   endif
end
o END
o BG $NORM_COL
o END

do_gui

# Copy selected checklist to job (if it doesn't already exist).
DO_INFO -t step -e $JOB/pcb
set TST = `echo "$gCHECKS_LIST" | grep -c "$cln_chk"`
if ($TST == 0) then
# Open editor on step "pcb".
COM open_entity,job=$JOB,type=step,name=pcb
   set group=$COMANS
   AUX set_group,group=$group

   # Close editor.
   COM editor_page_close

   COM chklist_from_lib,chklist=$cln_chk
endif

# Update info.source file with checklist name.
echo "set CL_CHK = $cln_chk" >> $JOB_PATH/user/info.source

# Open Form
COM show_form,job=$JOB,form=genform1

set_complete genform1 sccl

save_job

exit 0
