/*
  xi

*!  VERSION 1.0.1  06may2003

*/

VERSION 8.0

INCLUDE _std_small
INCLUDE _ht210
INCLUDE header

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

DIALOG main, label("xi - Interaction expansion") /*
		*/ tabtitle("Main")
BEGIN
  /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+*/ 
  TEXT     tx_term         _lft      _top       _iwd     .,		/*
  		*/label("Choose form of xi term:")
  LISTBOX  lb_term         @         _ss        _comb3_2  _ht4,		/*
   		*/label("Choose form of xi term")			/*
  		*/contents(xi_forms) onselchangelist(xi_change_main)	/*
		*/value(xi_seps)  
  TEXT     tx_cat          @         _vs4        _cwd1    .,		/*
  		*/label("Categorical variable:")
  DEFINE holdy @y
  VARNAME  vn_cat          @         _ss        _vnwd    .,		/*
  		*/label("Categorical variable")
  TEXT     tx_cat2         _lft2     holdy      _cwd1    .,		/*
  		*/label("Categorical variable:")
  VARNAME  vn_var2         @         _ss        _vnwd    .,		/*
  		*/label("Categorical variable")
  TEXT     tx_cont         _lft2     holdy      _cwd1    .,		/*
  		*/label("Continuous variable:")				
  VARNAME  vn_var3         @         _ss        _vnwd    .,		/*
  		*/label("Continuous variable")
  TEXT     tx_pre          _lft      _ls        _iwd     .,		/*
  		*/label("Prefix:")
  EDIT     ed_pre          @  _ss        _vnwd    .,			/*
  		*/label("Prefix") default(_I) max(10) option(prefix)
END

DIALOG term2, label("") /*
		*/ tabtitle("Term 2")
BEGIN
  /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+*/ 
  TEXT     tx_term         _lft      _top       _iwd     .,		/*
  		*/label("Choose form of xi term:")
  LISTBOX  lb_term         @         _ss        _comb3_2  _ht4,		/*
   		*/label("Choose form of xi term")			/*
  		*/contents(xi_forms) onselchangelist(xi_change_term2)	/*
		*/value(xi_seps)  
  TEXT     tx_cat          @         _vs4        _cwd1    .,		/*
  		*/label("Categorical variable:")
  DEFINE holdy @y
  VARNAME  vn_cat          @         _ss        _vnwd    .,		/*
  		*/label("Categorical variable")
  TEXT     tx_cat2         _lft2     holdy      _cwd1    .,		/*
  		*/label("Categorical variable:")
  VARNAME  vn_var2         @         _ss        _vnwd    .,		/*
  		*/label("Categorical variable")
  TEXT     tx_cont         _lft2     holdy      _cwd1    .,		/*
  		*/label("Continuous variable:")				
  VARNAME  vn_var3         @         _ss        _vnwd    .,		/*
  		*/label("Continuous variable")
END

DIALOG term3, label("") /*
		*/ tabtitle("Term 3")
BEGIN
  /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+*/ 
  TEXT     tx_term         _lft      _top       _iwd     .,		/*
  		*/label("Choose form of xi term:")
  LISTBOX  lb_term         @         _ss        _comb3_2  _ht4,		/*
   		*/label("Choose form of xi term")			/*
  		*/contents(xi_forms) onselchangelist(xi_change_term3)	/*
		*/value(xi_seps)  
  TEXT     tx_cat          @         _vs4        _cwd1    .,		/*
  		*/label("Categorical variable:")
  DEFINE holdy @y
  VARNAME  vn_cat          @         _ss        _vnwd    .,		/*
  		*/label("Categorical variable")
  TEXT     tx_cat2         _lft2     holdy      _cwd1    .,		/*
  		*/label("Categorical variable:")
  VARNAME  vn_var2         @         _ss        _vnwd    .,		/*
  		*/label("Categorical variable")
  TEXT     tx_cont         _lft2     holdy      _cwd1    .,		/*
  		*/label("Continuous variable:")				
  VARNAME  vn_var3         @         _ss        _vnwd    .,		/*
  		*/label("Continuous variable")
END

DIALOG term4, label("") /*
		*/ tabtitle("Term 4")
BEGIN
  /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+*/ 
  TEXT     tx_term         _lft      _top       _iwd     .,		/*
  		*/label("Choose form of xi term:")
  LISTBOX  lb_term         @         _ss        _comb3_2  _ht4,		/*
   		*/label("Choose form of xi term")			/*
  		*/contents(xi_forms) onselchangelist(xi_change_term4)	/*
		*/value(xi_seps)  
  TEXT     tx_cat          @         _vs4        _cwd1    .,		/*
  		*/label("Categorical variable:")
  DEFINE holdy @y
  VARNAME  vn_cat          @         _ss        _vnwd    .,		/*
  		*/label("Categorical variable")
  TEXT     tx_cat2         _lft2     holdy      _cwd1    .,		/*
  		*/label("Categorical variable:")
  VARNAME  vn_var2         @         _ss        _vnwd    .,		/*
  		*/label("Categorical variable")
  TEXT     tx_cont         _lft2     holdy      _cwd1    .,		/*
  		*/label("Continuous variable:")				
  VARNAME  vn_var3         @         _ss        _vnwd    .,		/*
  		*/label("Continuous variable")
END

DIALOG term5, label("") /*
		*/ tabtitle("Term 5")
BEGIN
  /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+*/ 
  TEXT     tx_term         _lft      _top       _iwd     .,		/*
  		*/label("Choose form of xi term:")
  LISTBOX  lb_term         @         _ss        _comb3_2  _ht4,		/*
   		*/label("Choose form of xi term")			/*
  		*/contents(xi_forms) onselchangelist(xi_change_term5)	/*
		*/value(xi_seps)  
  TEXT     tx_cat          @         _vs4        _cwd1    .,		/*
  		*/label("Categorical variable:")
  DEFINE holdy @y
  VARNAME  vn_cat          @         _ss        _vnwd    .,		/*
  		*/label("Categorical variable")
  TEXT     tx_cat2         _lft2     holdy      _cwd1    .,		/*
  		*/label("Categorical variable:")
  VARNAME  vn_var2         @         _ss        _vnwd    .,		/*
  		*/label("Categorical variable")
  TEXT     tx_cont         _lft2     holdy      _cwd1    .,		/*
  		*/label("Continuous variable:")				
  VARNAME  vn_var3         @         _ss        _vnwd    .,		/*
  		*/label("Continuous variable")
  TEXT     tx_term2        _lft      _ms       _iwd     .,		/*
  		*/label("Additional xi terms:")
  EDIT     ed_term2        @         _ss        _iwd     .,		/*
   		*/label("Additional xi terms")
END

LIST xi_forms
BEGIN
  I.varname
  I.varname1*I.varname2
  I.varname1*varname3
  I.varname1|varname3
END

LIST xi_seps
BEGIN
  " "   
  "*"
  "*"
  "|"
END

LIST xi_change_main
BEGIN
  script main_justone
  script main_twocat
  script main_onecont
  script main_onecont
END

LIST xi_change_term2
BEGIN
  script term2_justone
  script term2_twocat
  script term2_onecont
  script term2_onecont
END

LIST xi_change_term3
BEGIN
  script term3_justone
  script term3_twocat
  script term3_onecont
  script term3_onecont
END

LIST xi_change_term4
BEGIN
  script term4_justone
  script term4_twocat
  script term4_onecont
  script term4_onecont
END

LIST xi_change_term5
BEGIN
  script term5_justone
  script term5_twocat
  script term5_onecont
  script term5_onecont
END

SCRIPT main_justone
BEGIN
  main.tx_cat2.hide
  main.tx_cont.hide
  main.vn_var2.hide
  main.vn_var3.hide
END

SCRIPT term2_justone
BEGIN
  term2.tx_cat2.hide
  term2.tx_cont.hide
  term2.vn_var2.hide
  term2.vn_var3.hide
END

SCRIPT term3_justone
BEGIN
  term3.tx_cat2.hide
  term3.tx_cont.hide
  term3.vn_var2.hide
  term3.vn_var3.hide
END

SCRIPT term4_justone
BEGIN
  term4.tx_cat2.hide
  term4.tx_cont.hide
  term4.vn_var2.hide
  term4.vn_var3.hide
END

SCRIPT term5_justone
BEGIN
  term5.tx_cat2.hide
  term5.tx_cont.hide
  term5.vn_var2.hide
  term5.vn_var3.hide
END

SCRIPT main_twocat
BEGIN
  main.tx_cat2.show
  main.tx_cont.hide
  main.vn_var2.show
  main.vn_var3.hide
END

SCRIPT term2_twocat
BEGIN
  term2.tx_cat2.show
  term2.tx_cont.hide
  term2.vn_var2.show
  term2.vn_var3.hide
END

SCRIPT term3_twocat
BEGIN
  term3.tx_cat2.show
  term3.tx_cont.hide
  term3.vn_var2.show
  term3.vn_var3.hide
END

SCRIPT term4_twocat
BEGIN
  term4.tx_cat2.show
  term4.tx_cont.hide
  term4.vn_var2.show
  term4.vn_var3.hide
END

SCRIPT term5_twocat
BEGIN
  term5.tx_cat2.show
  term5.tx_cont.hide
  term5.vn_var2.show
  term5.vn_var3.hide
END

SCRIPT main_onecont
BEGIN
  main.tx_cat2.hide
  main.tx_cont.show
  main.vn_var2.hide
  main.vn_var3.show
END

SCRIPT term2_onecont
BEGIN
  term2.tx_cat2.hide
  term2.tx_cont.show
  term2.vn_var2.hide
  term2.vn_var3.show
END

SCRIPT term3_onecont
BEGIN
  term3.tx_cat2.hide
  term3.tx_cont.show
  term3.vn_var2.hide
  term3.vn_var3.show
END

SCRIPT term4_onecont
BEGIN
  term4.tx_cat2.hide
  term4.tx_cont.show
  term4.vn_var2.hide
  term4.vn_var3.show
END

SCRIPT term5_onecont
BEGIN
  term5.tx_cat2.hide
  term5.tx_cont.show
  term5.vn_var2.hide
  term5.vn_var3.show
END

PROGRAM command
BEGIN
	put "xi "
	beginoptions
		optionarg main.ed_pre
	endoptions
	require main.vn_cat
	put "I." main.vn_cat
	put main.lb_term
	if !H(main.vn_var2) {
		require main.vn_var2
		put "I." main.vn_var2 " "
	}
	if !H(main.vn_var3) {
		require main.vn_var3
		put main.vn_var3 " "
	}
	if term2.vn_cat {
		put "I." term2.vn_cat
		put term2.lb_term
		if !H(term2.vn_var2) {
			require term2.vn_var2
			put "I." term2.vn_var2 " "
		}
		if !H(term2.vn_var3) {
			require term2.vn_var3
			put term2.vn_var3 " "
		}
	}
	if term3.vn_cat{
		put "I." term3.vn_cat
		put term3.lb_term
		if !H(term3.vn_var2) {
			require term3.vn_var2
			put "I." term3.vn_var2 " "
		}
		if !H(term3.vn_var3) {
			require term3.vn_var3
			put term3.vn_var3 " "
		}
	}
	if term4.vn_cat{
		put "I." term4.vn_cat
		put term4.lb_term
		if !H(term4.vn_var2) {
			require term4.vn_var2
			put "I." term4.vn_var2 " "
		}
		if !H(term4.vn_var3) {
			require term4.vn_var3
			put term4.vn_var3 " "
		}
	}
	if term5.vn_cat {
		put "I." term5.vn_cat
		put term5.lb_term
		if !H(term5.vn_var2) {
			require term5.vn_var2
			put "I." term5.vn_var2 " "
		}
		if !H(term5.vn_var3) {
			require term5.vn_var3
			put term5.vn_var3 " "
		}
	}
	if term5.ed_term2 {
		put " " term5.ed_term2
	}
END

