#!/bin/csh
# This is a program for the example Genesis Tooling Forms.
# This file will exist in form 2.
# The purpose of this program is to allow the user to select a pre-defined analysis checklist
# that exists in the library.
# It is called by the "Select Analysis Checklist" button.
#
# Written by Ian Ticehurst (Autom8 Ltd.)
# Version 1A. Date: 12.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 genform2 sacl

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

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

# Allow user to select analysis checklist from the list (only offer checklists which contain "ana").
o_tooling
o FONT $NORM_FNT
o BG $NORM_COL
o BW 0
o LABEL Checklist Selection Pop-up
o LABEL Select the required analysis checklist from the list below.
o BG $LSTBG_COL
o LIST an_chk 5 S
foreach CHK ($gCHECKS_LIST)
   if ($CHK =~ *ana*) 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 = 0
foreach i ($gCHECKS_LIST)
   if ("$i" == "$an_chk") then
      set TST = 1
      break
   endif
end
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=$an_chk
endif

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

# Create ref. netlist.
COM netlist_page_open,set=yes,job1=$JOB,step1=pcb,type1=cur,job2=$JOB,step2=pcb,type2=cur
COM netlist_recalc,job=$JOB,step=pcb,type=cur,display=top
COM netlist_ref_update,job=$JOB,step=pcb,source=cur,reduce=yes
COM netlist_page_close

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

set_complete genform2 sacl

save_job

exit 0
