/*
    irf_ograph.dlg

*!  VERSION 2.0.2  15feb2007

*/

VERSION 10.0

INCLUDE _std_xlarge // xlarge for title
DEFINE _dlght 250
INCLUDE header

HELP hlp1, view("help irf_ograph")
RESET res1

//***************************************************************************
SCRIPT build_PREINIT
BEGIN
	create BOOLEAN build_plotsRequired
	build_plotsRequired.settrue
	
	create STRING  build_outputCmd
	create BOOLEAN build_isEditOn
	create BOOLEAN build_isDisableOn
	create BOOLEAN build_isEnableOn
	create BOOLEAN build_isFullyDisabled
	
	//** PUBLIC
		create STRING build_CMD
	//**

	create STRING build_CMD1
	create STRING build_CMD2
	create STRING build_CMD3
	create STRING build_CMD4
	create STRING build_CMD5
	create STRING build_CMD6
	create STRING build_CMD7
	create STRING build_CMD8
	create STRING build_CMD9
	create STRING build_CMD10
	create STRING build_CMD11
	create STRING build_CMD12
	create STRING build_CMD13
	create STRING build_CMD14
	create STRING build_CMD15
	create STRING build_CMD16
	
	create STRING build_result1
	create STRING build_result2
	create STRING build_result3
	create STRING build_result4
	create STRING build_result5
	create STRING build_result6
	create STRING build_result7
	create STRING build_result8
	create STRING build_result9
	create STRING build_result10
	create STRING build_result11
	create STRING build_result12
	create STRING build_result13
	create STRING build_result14
	create STRING build_result15
	create STRING build_result16

	create STRING build_status1
	create STRING build_status2
	create STRING build_status3
	create STRING build_status4
	create STRING build_status5
	create STRING build_status6
	create STRING build_status7
	create STRING build_status8
	create STRING build_status9
	create STRING build_status10
	create STRING build_status11
	create STRING build_status12
	create STRING build_status13
	create STRING build_status14
	create STRING build_status15
	create STRING build_status16
	
	create ARRAY  build_plots
	create ARRAY  build_plot_values
	create DOUBLE build_counter
	create BOOLEAN build_hasResult
	
	create BOOLEAN build_newEntry
	create STRING  build_newEntryValue
	
	build.bu_edit.disable
	build.bu_disable.disable
	build.bu_enable.disable
END

SCRIPT build_POSTINIT
BEGIN
	build.bu_new.setfocus
	program build_process_list
END

/***
PROGRAM build_POSTINIT_PROGRAM is defined by gr_addplots wrapper
DO NOT DEFINE HERE
****/

DIALOG build, 							///
	tabtitle("Plots")					///
	title("irf ograph - Overlay plots of IRFS, dynamic-multiplier functions, and FEVDs")
BEGIN
  // set IRF active file
  DEFINE _x _xsetbu
  DEFINE _y _top
  INCLUDE _bu_irfset

  TEXT     tx_plots	10	10	130	.,		///
	label("IRF plot definitions:")
  
  LISTBOX  lb_plots	@	+20	@	175,		///
  	contents(build_plots) 					///
  	values(build_plot_values) 				///
  	ondblclick(program build_check_plot)			///
  	onselchangelist(build_plot_changed)			///
  	nomemory
  BUTTON   bu_new	+140	@	100	.,		///
  	label("Create...")					///
  	onpush(program build_create_new)			///
  	tooltip("Click to create a new plot")
  BUTTON   bu_edit	@	+23	@	.,		///
  	label("Edit")						///
  	onpush(program build_check_plot)  			///
  	tooltip("Click to edit an existing plot")
  BUTTON   bu_disable	@	+28	@	.,		///
  	label("Disable")					///
  	onpush(program build_disable_sel)			///
  	tooltip("Click to disable a plot")
  BUTTON   bu_enable	@	+23	@	.,		///
  	label("Enable")						///
  	onpush(program build_enable_sel)			///
  	tooltip("Click to enable a previously disabled plot")

  TEXTBOX  tb_note	_lft	+110	_iwd	_tb2,		///
  	label(`"Press "Create" to define an IRF plot."')
END

PROGRAM build_create_new
BEGIN
	if build_counter.iseq(0) {
		call script build_make_plot1
	}
	if build_counter.iseq(1) {
		call script build_make_plot2
	}
	if build_counter.iseq(2) {
		call script build_make_plot3
	}
	if build_counter.iseq(3) {
		call script build_make_plot4
	}
	if build_counter.iseq(4) {
		call script build_make_plot5
	}
	if build_counter.iseq(5) {
		call script build_make_plot6
	}
	if build_counter.iseq(6) {
		call script build_make_plot7
	}
	if build_counter.iseq(7) {
		call script build_make_plot8
	}
	if build_counter.iseq(8) {
		call script build_make_plot9
	}
	if build_counter.iseq(9) {
		call script build_make_plot10
	}
	if build_counter.iseq(10) {
		call script build_make_plot11
	}
	if build_counter.iseq(11) {
		call script build_make_plot12
	}
	if build_counter.iseq(12) {
		call script build_make_plot13
	}
	if build_counter.iseq(13) {
		call script build_make_plot14
	}
	if build_counter.iseq(14) {
		call script build_make_plot15
	}
	if build_counter.iseq(15) {
		call script build_make_plot16
	}
	if build_counter.iseq(16) {
		stopbox stop "Plot limit exceeded."	///
			"Only 16 plots may be defined."
	}
END

SCRIPT build_make_plot1
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot1, allowsubmit
	build_plot1.setExitString "build_result1"
	build_plot1.setExitAction "program build_plot1_done"
	build_plot1.setSubmitAction "program build_plot1_submit_done"
	build_plot1.settitle "Plot 1"
	build_plot1.callthru "script y2SetHidden_true"
END
PROGRAM build_plot1_done
BEGIN
	if build_counter.iseq(0) {
		call build_status1.setstring "active"
		call build_counter.setvalue 1
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD1.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot1_submit_done
BEGIN
	call program build_plot1_done
	call Submit
END

SCRIPT build_make_plot2
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot2, allowsubmit
	build_plot2.setExitString "build_result2"
	build_plot2.setExitAction "program build_plot2_done"
	build_plot2.setSubmitAction "program build_plot2_submit_done"
	build_plot2.settitle "Plot 2"
END
PROGRAM build_plot2_done
BEGIN
	if build_counter.iseq(1) {
		call build_status2.setstring "active"
		call build_counter.setvalue 2           
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD2.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot2_submit_done
BEGIN
	call program build_plot2_done
	call Submit
END

SCRIPT build_make_plot3
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot3, allowsubmit
	build_plot3.setExitString "build_result3"
	build_plot3.setExitAction "program build_plot3_done"
	build_plot3.setSubmitAction "program build_plot3_submit_done"
	build_plot3.settitle "Plot 3"
END
PROGRAM build_plot3_done
BEGIN
	if build_counter.iseq(2) {
		call build_status3.setstring "active"
		call build_counter.setvalue 3           
		call program build_process_list_new		
	}
	call build_CMD.withvalue build_CMD3.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot3_submit_done
BEGIN
	call program build_plot3_done
	call Submit
END

SCRIPT build_make_plot4
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot4, allowsubmit
	build_plot4.setExitString "build_result4"
	build_plot4.setExitAction "program build_plot4_done"
	build_plot4.setSubmitAction "program build_plot4_submit_done"
	build_plot4.settitle "Plot 4"
END
PROGRAM build_plot4_done
BEGIN
	if build_counter.iseq(3) {
		call build_status4.setstring "active"
		call build_counter.setvalue 4           
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD4.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot4_submit_done
BEGIN
	call program build_plot4_done
	call Submit
END

SCRIPT build_make_plot5
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot5, allowsubmit
	build_plot5.setExitString "build_result5"
	build_plot5.setExitAction "program build_plot5_done"
	build_plot5.setSubmitAction "program build_plot5_submit_done"
	build_plot5.settitle "Plot 5"
END
PROGRAM build_plot5_done
BEGIN
	if build_counter.iseq(4) {
		call build_status5.setstring "active"
		call build_counter.setvalue 5           
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD5.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot5_submit_done
BEGIN
	call program build_plot5_done
	call Submit
END

SCRIPT build_make_plot6
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot6, allowsubmit
	build_plot6.setExitString "build_result6"
	build_plot6.setExitAction "program build_plot6_done"
	build_plot6.setSubmitAction "program build_plot6_submit_done"
	build_plot6.settitle "Plot 6"
END
PROGRAM build_plot6_done
BEGIN
	if build_counter.iseq(5) {
		call build_status6.setstring "active"
		call build_counter.setvalue 6           
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD6.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot6_submit_done
BEGIN
	call program build_plot6_done
	call Submit
END

SCRIPT build_make_plot7
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot7, allowsubmit
	build_plot7.setExitString "build_result7"
	build_plot7.setExitAction "program build_plot7_done"
	build_plot7.setSubmitAction "program build_plot7_submit_done"
	build_plot7.settitle "Plot 7"
END
PROGRAM build_plot7_done
BEGIN
	if build_counter.iseq(6) {
		call build_status7.setstring "active"
		call build_counter.setvalue 7           
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD7.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot7_submit_done
BEGIN
	call program build_plot7_done
	call Submit
END

SCRIPT build_make_plot8
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot8, allowsubmit
	build_plot8.setExitString "build_result8"
	build_plot8.setExitAction "program build_plot8_done"
	build_plot8.setSubmitAction "program build_plot8_submit_done"
	build_plot8.settitle "Plot 8"
END
PROGRAM build_plot8_done
BEGIN
	if build_counter.iseq(7) {
		call build_status8.setstring "active"
		call build_counter.setvalue 8           
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD8.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot8_submit_done
BEGIN
	call program build_plot8_done
	call Submit
END

SCRIPT build_make_plot9
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot9, allowsubmit
	build_plot9.setExitString "build_result9"
	build_plot9.setExitAction "program build_plot9_done"
	build_plot9.setSubmitAction "program build_plot9_submit_done"
	build_plot9.settitle "Plot 9"
END
PROGRAM build_plot9_done
BEGIN
	if build_counter.iseq(8) {
		call build_status9.setstring "active"
		call build_counter.setvalue 9           
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD9.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot9_submit_done
BEGIN
	call program build_plot9_done
	call Submit
END

SCRIPT build_make_plot10
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot10, allowsubmit
	build_plot10.setExitString "build_result10"
	build_plot10.setExitAction "program build_plot10_done"
	build_plot10.setSubmitAction "program build_plot10_submit_done"
	build_plot10.settitle "Plot 10"
END
PROGRAM build_plot10_done
BEGIN
	if build_counter.iseq(9) {
		call build_status10.setstring "active"
		call build_counter.setvalue 10           
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD10.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot10_submit_done
BEGIN
	call program build_plot10_done
	call Submit
END

SCRIPT build_make_plot11
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot11, allowsubmit
	build_plot11.setExitString "build_result11"
	build_plot11.setExitAction "program build_plot11_done"
	build_plot11.setSubmitAction "program build_plot11_submit_done"
	build_plot11.settitle "Plot 11"
END
PROGRAM build_plot11_done
BEGIN
	if build_counter.iseq(10) {
		call build_status11.setstring "active"
		call build_counter.setvalue 11           
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD11.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot11_submit_done
BEGIN
	call program build_plot11_done
	call Submit
END

SCRIPT build_make_plot12
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot12, allowsubmit
	build_plot12.setExitString "build_result12"
	build_plot12.setExitAction "program build_plot12_done"
	build_plot12.setSubmitAction "program build_plot12_submit_done"
	build_plot12.settitle "Plot 12"
END
PROGRAM build_plot12_done
BEGIN
	if build_counter.iseq(11) {
		call build_status12.setstring "active"
		call build_counter.setvalue 12           
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD12.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot12_submit_done
BEGIN
	call program build_plot12_done
	call Submit
END

SCRIPT build_make_plot13
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot13, allowsubmit
	build_plot13.setExitString "build_result13"
	build_plot13.setExitAction "program build_plot13_done"
	build_plot13.setSubmitAction "program build_plot13_submit_done"
	build_plot13.settitle "Plot 13"
END
PROGRAM build_plot13_done
BEGIN
	if build_counter.iseq(12) {
		call build_status13.setstring "active"
		call build_counter.setvalue 13           
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD13.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot13_submit_done
BEGIN
	call program build_plot13_done
	call Submit
END

SCRIPT build_make_plot14
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot14, allowsubmit
	build_plot14.setExitString "build_result14"
	build_plot14.setExitAction "program build_plot14_done"
	build_plot14.setSubmitAction "program build_plot14_submit_done"
	build_plot14.settitle "Plot 14"
END
PROGRAM build_plot14_done
BEGIN
	if build_counter.iseq(13) {
		call build_status14.setstring "active"
		call build_counter.setvalue 14           
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD14.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot14_submit_done
BEGIN
	call program build_plot14_done
	call Submit
END

SCRIPT build_make_plot15
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot15, allowsubmit
	build_plot15.setExitString "build_result15"
	build_plot15.setExitAction "program build_plot15_done"
	build_plot15.setSubmitAction "program build_plot15_submit_done"
	build_plot15.settitle "Plot 15"
END
PROGRAM build_plot15_done
BEGIN
	if build_counter.iseq(14) {
		call build_status15.setstring "active"
		call build_counter.setvalue 15           
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD15.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot15_submit_done
BEGIN
	call program build_plot15_done
	call Submit
END

SCRIPT build_make_plot16
BEGIN
	create CHILD gr_irf_ograph_plot AS build_plot16, allowsubmit
	build_plot16.setExitString "build_result16"
	build_plot16.setExitAction "program build_plot16_done"
	build_plot16.setSubmitAction "program build_plot16_submit_done"
	build_plot16.settitle "Plot 16"
END
PROGRAM build_plot16_done
BEGIN
	if build_counter.iseq(15) {
		call build_status16.setstring "active"
		call build_counter.setvalue 16           
		call program build_process_list_new
	}
	call build_CMD.withvalue build_CMD16.setstring `"@"'
	call build.lb_plots.forceselchange
END
PROGRAM build_plot16_submit_done
BEGIN
	call program build_plot16_done
	call Submit
END

SCRIPT build_clear_list
BEGIN
	build_plots.Arrdropall
	build_plot_values.Arrdropall
END

PROGRAM build_process_list_new
BEGIN
	call build_newEntry.settrue
	call program build_process_list
	call build_newEntry.setfalse
END

PROGRAM build_process_list
BEGIN	
	call script build_clear_list
	if build_counter.isge(1) {
		call build_plot_values.Arrpush "Plot 1"
		call build_newEntryValue.setstring "Plot 1"
		if build_status1.iseq("active") {
			call build_plots.Arrpush "Plot 1"
		}
		if build_status1.iseq("disabled") {
			call build_plots.Arrpush "Plot 1 (disabled)"
		}
		call build.bu_edit.enable
	}
	if build_counter.isge(2) {
		call build_plot_values.Arrpush "Plot 2"
		call build_newEntryValue.setstring "Plot 2"
		if build_status2.iseq("active") {
			call build_plots.Arrpush "Plot 2"		
		}
		if build_status2.iseq("disabled") {
			call build_plots.Arrpush "Plot 2 (disabled)"
		}
	}
	if build_counter.isge(3) {
		call build_plot_values.Arrpush "Plot 3"
		call build_newEntryValue.setstring "Plot 3"
		if build_status3.iseq("active") {
			call build_plots.Arrpush "Plot 3"			
		}
		if build_status3.iseq("disabled") {
			call build_plots.Arrpush "Plot 3 (disabled)"
		}
	}
	if build_counter.isge(4) {
		call build_plot_values.Arrpush "Plot 4"
		call build_newEntryValue.setstring "Plot 4"
		if build_status4.iseq("active") {
			call build_plots.Arrpush "Plot 4"			
		}
		if build_status4.iseq("disabled") {
			call build_plots.Arrpush "Plot 4 (disabled)"
		}
	}
	if build_counter.isge(5) {
		call build_plot_values.Arrpush "Plot 5"
		call build_newEntryValue.setstring "Plot 5"
		if build_status5.iseq("active") {
			call build_plots.Arrpush "Plot 5"		
		}
		if build_status5.iseq("disabled") {
			call build_plots.Arrpush "Plot 5 (disabled)"
		}
	}
	if build_counter.isge(6) {
		call build_plot_values.Arrpush "Plot 6"
		call build_newEntryValue.setstring "Plot 6"
		if build_status6.iseq("active") {
			call build_plots.Arrpush "Plot 6"			
		}
		if build_status6.iseq("disabled") {
			call build_plots.Arrpush "Plot 6 (disabled)"
		}
	}
	if build_counter.isge(7) {
		call build_plot_values.Arrpush "Plot 7"
		call build_newEntryValue.setstring "Plot 7"
		if build_status7.iseq("active") {
			call build_plots.Arrpush "Plot 7"			
		}
		if build_status7.iseq("disabled") {
			call build_plots.Arrpush "Plot 7 (disabled)"
		}
	}
	if build_counter.isge(8) {
		call build_plot_values.Arrpush "Plot 8"
		call build_newEntryValue.setstring "Plot 8"
		if build_status8.iseq("active") {
			call build_plots.Arrpush "Plot 8"			
		}
		if build_status8.iseq("disabled") {
			call build_plots.Arrpush "Plot 8 (disabled)"
		}
	}	
	if build_counter.isge(9) {
		call build_plot_values.Arrpush "Plot 9"
		call build_newEntryValue.setstring "Plot 9"
		if build_status9.iseq("active") {
			call build_plots.Arrpush "Plot 9"		
		}
		if build_status9.iseq("disabled") {
			call build_plots.Arrpush "Plot 9 (disabled)"
		}
	}
	if build_counter.isge(10) {
		call build_plot_values.Arrpush "Plot 10"
		call build_newEntryValue.setstring "Plot 10"
		if build_status10.iseq("active") {
			call build_plots.Arrpush "Plot 10"			
		}
		if build_status10.iseq("disabled") {
			call build_plots.Arrpush "Plot 10 (disabled)"
		}
	}
	if build_counter.isge(11) {
		call build_plot_values.Arrpush "Plot 11"
		call build_newEntryValue.setstring "Plot 11"
		if build_status11.iseq("active") {
			call build_plots.Arrpush "Plot 11"		
		}
		if build_status11.iseq("disabled") {
			call build_plots.Arrpush "Plot 11 (disabled)"
		}
	}
	if build_counter.isge(12) {
		call build_plot_values.Arrpush "Plot 12"
		call build_newEntryValue.setstring "Plot 12"
		if build_status12.iseq("active") {
			call build_plots.Arrpush "Plot 12"			
		}
		if build_status12.iseq("disabled") {
			call build_plots.Arrpush "Plot 12 (disabled)"
		}
	}
	if build_counter.isge(13) {
		call build_plot_values.Arrpush "Plot 13"
		call build_newEntryValue.setstring "Plot 13"
		if build_status13.iseq("active") {
			call build_plots.Arrpush "Plot 13"			
		}
		if build_status13.iseq("disabled") {
			call build_plots.Arrpush "Plot 13 (disabled)"
		}
	}
	if build_counter.isge(14) {
		call build_plot_values.Arrpush "Plot 14"
		call build_newEntryValue.setstring "Plot 14"
		if build_status14.iseq("active") {
			call build_plots.Arrpush "Plot 14"		
		}
		if build_status14.iseq("disabled") {
			call build_plots.Arrpush "Plot 14 (disabled)"
		}
	}
	if build_counter.isge(15) {
		call build_plot_values.Arrpush "Plot 15"
		call build_newEntryValue.setstring "Plot 15"
		if build_status15.iseq("active") {
			call build_plots.Arrpush "Plot 15"
			
		}
		if build_status15.iseq("disabled") {
			call build_plots.Arrpush "Plot 15 (disabled)"
		}
	}
	if build_counter.isge(16) {
		call build_plot_values.Arrpush "Plot 16"
		call build_newEntryValue.setstring "Plot 16"
		if build_status16.iseq("active") {
			call build_plots.Arrpush "Plot 16"			
		}
		if build_status16.iseq("disabled") {
			call build_plots.Arrpush "Plot 16 (disabled)"
		}
	}
	call build.lb_plots.repopulate
	if build_newEntry {
		call build_newEntryValue.withvalue build.lb_plots.setvalue "@"
	}
END

LIST build_plot_changed
BEGIN
	script build_plot1_sel
	script build_plot2_sel
	script build_plot3_sel
	script build_plot4_sel
	script build_plot5_sel
	script build_plot6_sel
	script build_plot7_sel
	script build_plot8_sel	
	script build_plot9_sel
	script build_plot10_sel
	script build_plot11_sel
	script build_plot12_sel
	script build_plot13_sel
	script build_plot14_sel
	script build_plot15_sel
	script build_plot16_sel	
END

SCRIPT build_plot0_sel
BEGIN
	build.tb_note.setlabel 	///
		`"Press "Create" to define an IRF plot."'
	build.bu_enable.disable
	build.bu_disable.disable
END

SCRIPT build_plot1_sel
BEGIN
	build_CMD1.withvalue build.tb_note.setlabel `"@"'
	program build_plot1_check_status
END
PROGRAM build_plot1_check_status
BEGIN
	if build_status1.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status1.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot2_sel
BEGIN
	build_CMD2.withvalue build.tb_note.setlabel `"@"'
	program build_plot2_check_status
END
PROGRAM build_plot2_check_status
BEGIN
	if build_status2.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status2.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot3_sel
BEGIN
	build_CMD3.withvalue build.tb_note.setlabel `"@"'
	program build_plot3_check_status
END
PROGRAM build_plot3_check_status
BEGIN
	if build_status3.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status3.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot4_sel
BEGIN
	build_CMD4.withvalue build.tb_note.setlabel `"@"'
	program build_plot4_check_status
END
PROGRAM build_plot4_check_status
BEGIN
	if build_status4.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status4.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot5_sel
BEGIN
	build_CMD5.withvalue build.tb_note.setlabel `"@"'
	program build_plot5_check_status
END
PROGRAM build_plot5_check_status
BEGIN
	if build_status5.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status5.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot6_sel
BEGIN
	build_CMD6.withvalue build.tb_note.setlabel `"@"'
	program build_plot6_check_status
END
PROGRAM build_plot6_check_status
BEGIN
	if build_status6.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status6.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot7_sel
BEGIN
	build_CMD7.withvalue build.tb_note.setlabel `"@"'
	program build_plot7_check_status
END
PROGRAM build_plot7_check_status
BEGIN
	if build_status7.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status7.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot8_sel
BEGIN
	build_CMD8.withvalue build.tb_note.setlabel `"@"'
	program build_plot8_check_status
END
PROGRAM build_plot8_check_status
BEGIN
	if build_status8.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status8.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot9_sel
BEGIN
	build_CMD9.withvalue build.tb_note.setlabel `"@"'
	program build_plot9_check_status
END
PROGRAM build_plot9_check_status
BEGIN
	if build_status9.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status9.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot10_sel
BEGIN
	build_CMD10.withvalue build.tb_note.setlabel `"@"'
	program build_plot10_check_status
END
PROGRAM build_plot10_check_status
BEGIN
	if build_status10.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status10.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot11_sel
BEGIN
	build_CMD11.withvalue build.tb_note.setlabel `"@"'
	program build_plot11_check_status
END
PROGRAM build_plot11_check_status
BEGIN
	if build_status11.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status11.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot12_sel
BEGIN
	build_CMD12.withvalue build.tb_note.setlabel `"@"'
	program build_plot12_check_status
END
PROGRAM build_plot12_check_status
BEGIN
	if build_status12.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status12.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot13_sel
BEGIN
	build_CMD13.withvalue build.tb_note.setlabel `"@"'
	program build_plot13_check_status
END
PROGRAM build_plot13_check_status
BEGIN
	if build_status13.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status13.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot14_sel
BEGIN
	build_CMD14.withvalue build.tb_note.setlabel `"@"'
	program build_plot14_check_status
END
PROGRAM build_plot14_check_status
BEGIN
	if build_status14.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status14.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot15_sel
BEGIN
	build_CMD15.withvalue build.tb_note.setlabel `"@"'
	program build_plot15_check_status
END
PROGRAM build_plot15_check_status
BEGIN
	if build_status15.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status15.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

SCRIPT build_plot16_sel
BEGIN
	build_CMD16.withvalue build.tb_note.setlabel `"@"'
	program build_plot16_check_status
END
PROGRAM build_plot16_check_status
BEGIN
	if build_status16.iseq("active") {
		call build.bu_enable.disable
		call build.bu_disable.enable
	}
	if build_status16.iseq("disabled") {
		call build.bu_enable.enable
		call build.bu_disable.disable
	}
END

PROGRAM build_disable_sel
BEGIN
	if build.lb_plots.iseq("Plot 1") {
		call build_status1.setstring "disabled"
	}
	if build.lb_plots.iseq("Plot 2") {
		call build_status2.setstring "disabled"
	}
	if build.lb_plots.iseq("Plot 3") {
		call build_status3.setstring "disabled"
	}
	if build.lb_plots.iseq("Plot 4") {
		call build_status4.setstring "disabled"
	}
	if build.lb_plots.iseq("Plot 5") {
		call build_status5.setstring "disabled"
	}
	if build.lb_plots.iseq("Plot 6") {
		call build_status6.setstring "disabled"
	}
	if build.lb_plots.iseq("Plot 7") {
		call build_status7.setstring "disabled"
	}
	if build.lb_plots.iseq("Plot 8") {
		call build_status8.setstring "disabled"
	}	
	if build.lb_plots.iseq("Plot 9") {
		call build_status9.setstring "disabled"
	}
	if build.lb_plots.iseq("Plot 10") {
		call build_status10.setstring "disabled"
	}
	if build.lb_plots.iseq("Plot 11") {
		call build_status11.setstring "disabled"
	}
	if build.lb_plots.iseq("Plot 12") {
		call build_status12.setstring "disabled"
	}
	if build.lb_plots.iseq("Plot 13") {
		call build_status13.setstring "disabled"
	}
	if build.lb_plots.iseq("Plot 14") {
		call build_status14.setstring "disabled"
	}
	if build.lb_plots.iseq("Plot 15") {
		call build_status15.setstring "disabled"
	}
	if build.lb_plots.iseq("Plot 16") {
		call build_status16.setstring "disabled"
	}	
	call program build_process_list
END

PROGRAM build_enable_sel
BEGIN
	if build.lb_plots.iseq("Plot 1") {
		call build_status1.setstring "active"
	}
	if build.lb_plots.iseq("Plot 2") {
		call build_status2.setstring "active"
	}
	if build.lb_plots.iseq("Plot 3") {
		call build_status3.setstring "active"
	}
	if build.lb_plots.iseq("Plot 4") {
		call build_status4.setstring "active"
	}
	if build.lb_plots.iseq("Plot 5") {
		call build_status5.setstring "active"
	}
	if build.lb_plots.iseq("Plot 6") {
		call build_status6.setstring "active"
	}
	if build.lb_plots.iseq("Plot 7") {
		call build_status7.setstring "active"
	}
	if build.lb_plots.iseq("Plot 8") {
		call build_status8.setstring "active"
	}	
	if build.lb_plots.iseq("Plot 19") {
		call build_status9.setstring "active"
	}
	if build.lb_plots.iseq("Plot 10") {
		call build_status10.setstring "active"
	}
	if build.lb_plots.iseq("Plot 11") {
		call build_status11.setstring "active"
	}
	if build.lb_plots.iseq("Plot 12") {
		call build_status12.setstring "active"
	}
	if build.lb_plots.iseq("Plot 13") {
		call build_status13.setstring "active"
	}
	if build.lb_plots.iseq("Plot 14") {
		call build_status14.setstring "active"
	}
	if build.lb_plots.iseq("Plot 15") {
		call build_status15.setstring "active"
	}
	if build.lb_plots.iseq("Plot 16") {
		call build_status16.setstring "active"
	}
	call program build_process_list
END

PROGRAM build_check_plot
BEGIN
	if build.lb_plots.iseq("Plot 1") {
		call script build_make_plot1		
	}
	if build.lb_plots.iseq("Plot 2") {
		call script build_make_plot2
	}
	if build.lb_plots.iseq("Plot 3") {
		call script build_make_plot3
	}
	if build.lb_plots.iseq("Plot 4") {
		call script build_make_plot4
	}
	if build.lb_plots.iseq("Plot 5") {
		call script build_make_plot5
	}
	if build.lb_plots.iseq("Plot 6") {
		call script build_make_plot6
	}
	if build.lb_plots.iseq("Plot 7") {
		call script build_make_plot7
	}
	if build.lb_plots.iseq("Plot 8") {
		call script build_make_plot8
	}
	if build.lb_plots.iseq("Plot 9") {
		call script build_make_plot9		
	}
	if build.lb_plots.iseq("Plot 10") {
		call script build_make_plot10
	}
	if build.lb_plots.iseq("Plot 11") {
		call script build_make_plot11
	}
	if build.lb_plots.iseq("Plot 12") {
		call script build_make_plot12
	}
	if build.lb_plots.iseq("Plot 13") {
		call script build_make_plot13
	}
	if build.lb_plots.iseq("Plot 14") {
		call script build_make_plot14
	}
	if build.lb_plots.iseq("Plot 15") {
		call script build_make_plot15
	}
	if build.lb_plots.iseq("Plot 16") {
		call script build_make_plot16
	}	
END

PROGRAM build_make_first_pass
BEGIN
	if build_status1.iseq("active") & build_result1 {
		call build_hasResult.settrue
	}
	if build_status2.iseq("active") & build_result2 {
		call build_hasResult.settrue
	}
	if build_status3.iseq("active") & build_result3 {
		call build_hasResult.settrue
	}
	if build_status4.iseq("active") & build_result4 {
		call build_hasResult.settrue
	}
	if build_status5.iseq("active") & build_result5 {
		call build_hasResult.settrue
	}
	if build_status6.iseq("active") & build_result6 {
		call build_hasResult.settrue
	}
	if build_status7.iseq("active") & build_result7 {
		call build_hasResult.settrue
	}
	if build_status8.iseq("active") & build_result8 {
		call build_hasResult.settrue
	}
	if build_status9.iseq("active") & build_result9 {
		call build_hasResult.settrue
	}
	if build_status10.iseq("active") & build_result10 {
		call build_hasResult.settrue
	}
	if build_status11.iseq("active") & build_result11 {
		call build_hasResult.settrue
	}
	if build_status12.iseq("active") & build_result12 {
		call build_hasResult.settrue
	}
	if build_status13.iseq("active") & build_result13 {
		call build_hasResult.settrue
	}
	if build_status14.iseq("active") & build_result14 {
		call build_hasResult.settrue
	}
	if build_status15.iseq("active") & build_result15 {
		call build_hasResult.settrue
	}
	if build_status16.iseq("active") & build_result16 {
		call build_hasResult.settrue
	}
END

PROGRAM build_output
BEGIN
	if build_counter.iseq(0) & build_plotsRequired {
		stopbox stop "Plots not defined. " ///
			"Please create a plot before proceeding."
	}
	call build_hasResult.setfalse
	call program build_make_first_pass
	if ! build_hasResult  &  build_plotsRequired {
		stopbox stop "All plots are disabled. " ///
			"Either define a new plot or enable an existing plot before proceeding."
	}

	if build_hasResult {
		put build_outputCmd
		if build_outputCmd {
			put "("
		}

		if build_status1.iseq("active") & build_result1 {
			put build_result1
			call build_hasResult.settrue
		}
		if build_status2.iseq("active") & build_result2 {
			put " " build_result2
			call build_hasResult.settrue
		}
		if build_status3.iseq("active") & build_result3 {
			put " " build_result3
			call build_hasResult.settrue
		}
		if build_status4.iseq("active") & build_result4 {
			put " " build_result4
			call build_hasResult.settrue
		}
		if build_status5.iseq("active") & build_result5 {
			put " " build_result5
			call build_hasResult.settrue
		}
		if build_status6.iseq("active") & build_result6 {
			put " " build_result6
			call build_hasResult.settrue
		}
		if build_status7.iseq("active") & build_result7 {
			put " " build_result7
			call build_hasResult.settrue
		}
		if build_status8.iseq("active") & build_result8 {
			put " " build_result8
			call build_hasResult.settrue
		}
		if build_status9.iseq("active") & build_result9 {
			put " " build_result9
			call build_hasResult.settrue
		}
		if build_status10.iseq("active") & build_result10 {
			put " " build_result10
			call build_hasResult.settrue
		}
		if build_status11.iseq("active") & build_result11 {
			put " " build_result11
			call build_hasResult.settrue
		}
		if build_status12.iseq("active") & build_result12 {
			put " " build_result12
			call build_hasResult.settrue
		}
		if build_status13.iseq("active") & build_result13 {
			put " " build_result13
			call build_hasResult.settrue
		}
		if build_status14.iseq("active") & build_result14 {
			put " " build_result14
			call build_hasResult.settrue
		}
		if build_status15.iseq("active") & build_result15 {
			put " " build_result15
			call build_hasResult.settrue
		}
		if build_status16.iseq("active") & build_result16 {
			put " " build_result16
			call build_hasResult.settrue
		}
	}
END
//***************************************************************************

DIALOG main, tabtitle("Options")
BEGIN
  GROUPBOX gb_opts		_lft	_top	_iwd	_ht8,	///
  		label("Common options")

  TEXT     tx_fill		_ilft	_ss	0	0,
  DEFINE   _x  _cksep
  DEFINE   _cx _cksprb
  DEFINE   _y  @
  INCLUDE  _sp_level

  CHECKBOX ck_lstep		_ilft	_mls	_ckwd	.,	///
	onclickon(program lstep_check)				///
	onclickoff(program lstep_check)
  DEFINE x @x
  SPINNER  sp_lstep		_cksep	@	_spwd	.,	///
	min(1)							///
	max(500)						///
	default(0)						///
	option(lstep)						///
	label("Common first step")
  TEXT     tx_lstep		_spsep	@	_cksprb	.,	///
	label("Common first step")
  CHECKBOX ck_ustep		_ilft	_mls	_ckwd	.,	///
	onclickon(program ustep_check)				///
	onclickoff(program ustep_check)
  DEFINE x @x
  SPINNER  sp_ustep		_cksep	@	_spwd	.,	///
	min(1)							///
	max(500)						///
	default(10)						///
	option(ustep)						///
	label("Common maximum step")
  TEXT     tx_ustep		_spsep	@	_cksprb	.,	///
	label("Common maximum step")
/*
  	-cilines- was not included because it is a command line utility.
  	and because the individual cioptions can perform the same function.
*/
END

PROGRAM lstep_check
BEGIN
	if main.ck_lstep {
		call gaction main.sp_lstep.enable
	}
	if !main.ck_lstep {
		call gaction main.sp_lstep.disable
	}
END

PROGRAM ustep_check
BEGIN
	if main.ck_ustep {
		call gaction main.sp_ustep.enable
	}
	if !main.ck_ustep {
		call gaction main.sp_ustep.disable
	}
END

INCLUDE gr_yaxis
INCLUDE gr_xaxis
INCLUDE gr_titles
INCLUDE gr_legend
INCLUDE gr_overall

PROGRAM command
BEGIN
	put "irf ograph "
	put " " /program build_output
	beginoptions
		INCLUDE _level_main_pr
		if main.ck_lstep {
			optionarg main.sp_lstep
		}
		if main.ck_ustep {
			optionarg main.sp_ustep
		}
		put " " /program gr_yaxis_output
		put " " /program gr_xaxis_output
		put " " /program gr_titles_output
		put " " /program gr_legend_output
		put " " /program gr_overall_output
	endoptions
END
