/*
	shewhart

*!  VERSION 2.0.2  15jun2009

*/

VERSION 11.0

INCLUDE _std_xlarge
DEFINE _dlght 300
INCLUDE header

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

SCRIPT POSTINIT
BEGIN
	script gr_plots_setDefaultScatter
	script gr_ciplots_setDefaultLine
	gr_ciplots_outputCmd.setstring "clopts"
	gr_ciplots.settabtitle "Control limits"
END

DIALOG main, tabtitle("Main")						///
	label("shewhart - Draw vertically aligned X-bar and R charts")
BEGIN
  TEXT     tx_var         _lft       _top       _vlwd	   .,		///
	label("Variables:")
  VARLIST  vl_var         @          _ss        @          .,		///
	label("Variables")

  GROUPBOX gb_std         @          +35        @          _ht6,	///
	label("Standard deviation of the process")

  RADIO    rb_range       _indent    _ss        _inwd      .,		///
	label("Calculate standard deviation based on range")		///
	first onclickon(script std_off)
  RADIO    rb_std         @          _ss        @          .,		///
	label("Use user-specified standard deviation")			///
	last onclickon(script std_on)

  EDIT     en_std         _indent2   _ss        _en7wd     .,		///
	label("User-specified standard deviation") default(0) 		///
	numonly option(std)
  TEXT     tx_std         _en7sep    @          130        .,		///
	label("Standard deviation")

  GROUPBOX gb_mean        _lft      _xls      _vlwd     _ht6, 		///
	label("Mean")

  RADIO    rb_cmean       _indent   _ss       _inwd     .,  		///
	label("Calculate mean") first onclickon(script mean_off)
  RADIO    rb_mean        _ilft     _ss       @         ., 		///
	label("Use user-specified mean") 				///
	onclickon(script mean_on)					///
	last
  EDIT     en_mean        _indent2  _ss       _en7wd    .,		///
	label("User-specified mean") default(0) numonly option(mean)
  TEXT     tx_mean        _en7sep   @         130       .,		///
	label("Mean")

  CHECKBOX ck_nograph     _lft      _xls      _iwd      .,		///
	label("Suppress graph") option(nograph)				///
	onclickon(script graph_off) onclickoff(script graph_on)
END

SCRIPT std_on
BEGIN
	main.en_std.enable
	main.tx_std.enable
END

SCRIPT std_off
BEGIN
        main.en_std.disable
        main.tx_std.disable
END

SCRIPT mean_on
BEGIN
        main.en_mean.enable
        main.tx_mean.enable
END

SCRIPT mean_off
BEGIN
        main.en_mean.disable
        main.tx_mean.disable
END

SCRIPT graph_on
BEGIN
	script gr_plots_enable
	script gr_ciplots_enable
	script gr_yaxis_enable
	script gr_xaxis_enable
	script gr_titles_enable
	script gr_legend_enable
	script gr_overall_enable
END

SCRIPT graph_off
BEGIN
	script gr_plots_disable
	script gr_ciplots_disable
	script gr_yaxis_disable
	script gr_xaxis_disable
	script gr_titles_disable
	script gr_legend_disable
	script gr_overall_disable
END

INCLUDE ifin
INCLUDE gr_plots
INCLUDE gr_ciplots
INCLUDE gr_yaxis
INCLUDE gr_xaxis
INCLUDE gr_titles
INCLUDE gr_legend
INCLUDE gr_overall

PROGRAM command
BEGIN
	put "shewhart "
	varlist main.vl_var
	INCLUDE _ifin_pr
	beginoptions
		if main.rb_std{
			require main.en_std
			optionarg main.en_std
		}
		if main.rb_mean{
			require main.en_mean
			optionarg main.en_mean
		}
		option main.ck_nograph

		put " " /program gr_plots_output
		put " " /program gr_ciplots_output
		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
