/*
  ctset

*!  VERSION 1.1.0  07feb2007

*/

VERSION 8.0

INCLUDE _std_large
INCLUDE _ht310
INCLUDE header
HELP hlp1, view("help ctset")
RESET res1

DIALOG main, label("ctset - Declare data to be count-time data") /*
		*/ tabtitle("Main")
BEGIN
  /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+*/ 
  RADIO    rb_ctdata       _lft      _top      _iwd      .,		/*
  		*/label("Declare data to be count-time (ct) data")	/*
  		*/clickon("program ctdata_on")				/*
		*/clickoff("script ctdata_off") 			/*
		*/first
  RADIO    rb_ctshow       @         _ss       @         .,		/*
*/label("Show/suppress count-time (ct) variable descriptions in ct output")/*
  		*/clickon("script ctshow_on")
  RADIO    rb_ctclear      @         _ss       @         .,		/*
  		*/label("Forget this is count-time (ct) data")		/*
  		*/clickon("script ctclear_on")				/*
		*/option("clear")
  RADIO    rb_ctdisp       @         _ss       @         .,		/*
	*/label("Identify current count-time (ct) variables")/*
		*/clickon("script ctdisp_on")				/*
		*/last
  TEXT     tx_tv           _lft      _ms       _cwd1     .,		/*
		*/label("Time variable:")
  TEXT     tx_fv           _lft2     @         @         .,		/*
  		*/label("Failure variable:")   
  VARNAME  vn_tv           _lft      _ss       _vnwd     .,             /*
  		*/nomemory						/*
  		*/label("Time variable") 
  VARNAME  vn_fv           _lft2     @         @         .,		/*
  		*/nomemory						/*
  		*/label("Failure variable")
  CHECKBOX ck_cens         _lft      _ls       _cwd1     .,		/*
  		*/label("Censor variable:")				/*
  		*/clickon("program cens_on")				/*
		*/clickoff("script cens_off")
  CHECKBOX ck_ent          _lft2     @         @         .,		/*
  		*/label("Enter variable:")				/*
  		*/clickon(gaction main.vn_ent.enable)			/*
		*/clickoff(gaction main.vn_ent.disable)
  VARNAME  vn_cens         _lft      _ss       _vnwd     .,		/*
  		*/nomemory						/*
  		*/label("Censor variable")				/*
  		*/
  VARNAME  vn_ent          _lft2     @         @         .,		/*
  		*/nomemory						/*
  		*/label("Enter variable")
  GROUPBOX gb_opt          _lft      +35       _iwd      _ht7,          /*
  		*/ label("Options")				        /*
		*/							
  CHECKBOX ck_by           _indent   _ss       _ibwd     .,		/*
 		*/label("Group data by:")				/*
  		*/clickon(gaction main.vl_by.enable)			/*
  		*/clickoff(gaction main.vl_by.disable)
DEFINE holdy @y
DEFINE holdx @x
  VARLIST  vl_by           _indent2  _ss       _inwd     .,		/*
  		*/nomemory						/*
		*/label("Group data by") 				/*
  		*/option("by")
  CHECKBOX ck_noshow       holdx     _ls       _ibwd     .,		/*
    		*/option("noshow")					/*
		*/label("Suppress ct variable descriptions in ct output")

  CHECKBOX ck_clear        @         holdy     _ibwd     .,		/*
  		*/label("CONFIRM: forget this is count-time data")	/*
  		*/option("clear") nomem
  RADIO    rb_show         @         @         _cwd2     .,		/*
  		*/label("Show ct variable descriptions")		/*
  		*/option("show")					/*
		*/first
  RADIO    rb_noshow       _lft2     @         @         .,		/*
  		*/label("Suppress ct variable descriptions")		/*
  		*/option("noshow")					/*
		*/last
END

PROGRAM  opt1_on
  BEGIN
	call gaction main.tx_tv.show
	call gaction main.tx_fv.show
	call gaction main.vn_tv.show
	call gaction main.vn_fv.show
	call main.ck_cens.show
	call main.vn_cens.show
	call main.ck_ent.show
	call main.vn_ent.show
	if !main.ck_cens {
		call gaction main.vn_cens.disable
		call gaction main.ck_ent.disable
		call gaction main.vn_ent.disable
	}
    	if main.ck_cens {
    		if  main.ck_ent {
    			call gaction main.vn_ent.enable
		}
		if !main.ck_ent {
			call gaction main.vn_ent.disable
		}
    	}
	call gaction main.gb_opt.show
	call gaction main.ck_by.show
	call gaction main.vl_by.show
	call gaction main.ck_noshow.show
	if !main.ck_by {
    		call gaction main.vl_by.disable
	}
	call gaction main.ck_noshow.enable
 END

SCRIPT opt1_off
  BEGIN
    main.tx_tv.hide
    main.tx_fv.hide
    main.vn_tv.hide
    main.vn_fv.hide
    main.ck_cens.hide
    main.ck_ent.hide
    main.vn_cens.hide
    main.vn_ent.hide
    main.ck_by.hide
    main.vl_by.hide
    main.ck_noshow.hide
  END

SCRIPT opt2_on
  BEGIN
    main.gb_opt.show
    main.rb_show.show
    main.rb_noshow.show
  END

SCRIPT opt2_off
  BEGIN
    main.rb_show.hide
    main.rb_noshow.hide
  END

SCRIPT opt3_on
  BEGIN
    main.gb_opt.show
    main.ck_clear.show
  END

SCRIPT opt3_off
  BEGIN
    main.ck_clear.hide
  END
 
PROGRAM ctdata_on
  BEGIN
    
    call program opt1_on
    call script opt2_off
    call script opt3_off
  END

SCRIPT ctshow_on
  BEGIN
    script opt1_off
    script opt2_on
    script opt3_off
  END
    
SCRIPT ctclear_on
  BEGIN
    script opt1_off
    script opt2_off
    script opt3_on
  END
 
SCRIPT ctdisp_on
  BEGIN
    script opt1_off
    script opt2_off
    script opt3_off
    main.gb_opt.hide
  END
 
 
PROGRAM cens_on
  BEGIN
    call gaction main.vn_cens.enable
    call gaction main.ck_ent.enable
    if main.ck_ent {
    	call gaction main.vn_ent.enable
    }
  END

SCRIPT cens_off
  BEGIN
    main.vn_cens.disable
    main.ck_ent.disable
    main.vn_ent.disable
  END
  
PROGRAM command
BEGIN
	put "ctset "
	if main.rb_ctdata {
		varlist main.vn_tv
		varlist main.vn_fv
		if main.ck_cens{
			varlist main.vn_cens
			if main.ck_ent{
				varlist main.vn_ent
			}
		}
		beginoptions
			if main.ck_by{
				require main.vl_by
				optionarg main.vl_by
			}
			option main.ck_noshow
		endoptions
	}
	if main.rb_ctshow {
	        beginoptions
			option radio(main rb_show rb_noshow)
	        endoptions
	}
	if main.rb_ctclear {
		if !main.ck_clear {
			stopbox stop /*
			    */ `""CONFIRM: forget this is count time data""' /*
			    */ "must be checked"
		}
		beginoptions
			option main.ck_clear
		endoptions
	}
END

