/* _fv_core_pr.idlg

*!  VERSION 1.1.0  23nov2009

*/

LIST term_list
BEGIN
	Main effect
	Interaction (2-way)
	2-way full factorial
	3-way interaction
	3-way full factorial
	4-way interaction
	4-way full factorial
	5-way interaction
	5-way full factorial
	6-way interaction
	6-way full factorial
END
LIST term_values
BEGIN
	/* used for branching output */
	main-effect
	2way-interaction
	2way-fullfactorial
	3way-interaction
	3way-fullfactorial
	4way-interaction
	4way-fullfactorial
	5way-interaction
	5way-fullfactorial
	6way-interaction
	6way-fullfactorial
END

LIST base_list
BEGIN
	Default
	First
	Frequent
	Last
	None
	0
	1
	2
END
LIST base_values
BEGIN
	""
	first
	frequent
	last
	none
	0
	1
	2
END

PROGRAM _fv_core_disable
BEGIN
	call main.ed_ts1.disable
	call main.bu_ts1.disable
	call main.sp_lag1.disable
	call main.tx_lag1.disable
	call main.ed_ts2.disable
	call main.bu_ts2.disable
	call main.sp_lag2.disable
	call main.tx_lag2.disable
	call main.ed_ts3.disable
	call main.bu_ts3.disable
	call main.sp_lag3.disable
	call main.tx_lag3.disable
	call main.ed_ts4.disable
	call main.bu_ts4.disable
	call main.sp_lag4.disable
	call main.tx_lag4.disable
	call main.ed_ts5.disable
	call main.bu_ts5.disable
	call main.sp_lag5.disable
	call main.tx_lag5.disable
	call main.ed_ts6.disable
	call main.bu_ts6.disable
	call main.sp_lag6.disable
	call main.tx_lag6.disable
END

PROGRAM _fv_core_enable
BEGIN
	call main.ed_ts1.enable
	call main.bu_ts1.enable
	call main.sp_lag1.enable
	call main.tx_lag1.enable
	call main.ed_ts2.enable
	call main.bu_ts2.enable
	call main.sp_lag2.enable
	call main.tx_lag2.enable
	call main.ed_ts3.enable
	call main.bu_ts3.enable
	call main.sp_lag3.enable
	call main.tx_lag3.enable
	call main.ed_ts4.enable
	call main.bu_ts4.enable
	call main.sp_lag4.enable
	call main.tx_lag4.enable
	call main.ed_ts5.enable
	call main.bu_ts5.enable
	call main.sp_lag5.enable
	call main.tx_lag5.enable
	call main.ed_ts6.enable
	call main.bu_ts6.enable
	call main.sp_lag6.enable
	call main.tx_lag6.enable
END


PROGRAM hide_terms
BEGIN
	call main.tx_fv1.hide
	call main.vn_fv1.hide
	call main.cb_base1.hide
	call main.ck_cont1.hide
	call main.ed_ts1.hide
	call main.bu_ts1.hide
	call main.sp_lag1.hide
	call main.tx_lag1.hide

	call main.tx_fv2.hide
	call main.vn_fv2.hide
	call main.cb_base2.hide
	call main.ck_cont2.hide
	call main.ed_ts2.hide
	call main.bu_ts2.hide
	call main.sp_lag2.hide
	call main.tx_lag2.hide

	call main.tx_fv3.hide
	call main.vn_fv3.hide
	call main.cb_base3.hide
	call main.ck_cont3.hide
	call main.ed_ts3.hide
	call main.bu_ts3.hide
	call main.sp_lag3.hide
	call main.tx_lag3.hide

	call main.tx_fv4.hide
	call main.vn_fv4.hide
	call main.cb_base4.hide
	call main.ck_cont4.hide
	call main.ed_ts4.hide
	call main.bu_ts4.hide
	call main.sp_lag4.hide
	call main.tx_lag4.hide

	call main.tx_fv5.hide
	call main.vn_fv5.hide
	call main.cb_base5.hide
	call main.ck_cont5.hide
	call main.ed_ts5.hide
	call main.bu_ts5.hide
	call main.sp_lag5.hide
	call main.tx_lag5.hide

	call main.tx_fv6.hide
	call main.vn_fv6.hide
	call main.cb_base6.hide
	call main.ck_cont6.hide
	call main.ed_ts6.hide
	call main.bu_ts6.hide
	call main.sp_lag6.hide
	call main.tx_lag6.hide
END

PROGRAM check_term
BEGIN
	call program hide_terms
	
	if (! main.cb_term.isvisible()) {
		exit
	}

	call main.tx_fv1.show
	call main.vn_fv1.show
	call main.cb_base1.show
	call main.ck_cont1.show
	call program check_continuous_1

	if main.cb_term.startswith("2way") 		///
		| main.cb_term.startswith("3way")	///
		| main.cb_term.startswith("4way")	///
		| main.cb_term.startswith("5way")	///
		| main.cb_term.startswith("6way")	///
	{
		call main.tx_fv2.show
		call main.vn_fv2.show
		call main.cb_base2.show
		call main.ck_cont2.show
		call program check_continuous_2
	}
	if main.cb_term.startswith("3way")		///
		| main.cb_term.startswith("4way")	///
		| main.cb_term.startswith("5way")	///
		| main.cb_term.startswith("6way")	///
	{
		call main.tx_fv3.show
		call main.vn_fv3.show
		call main.cb_base3.show
		call main.ck_cont3.show
		call program check_continuous_3
	}
	if main.cb_term.startswith("4way")		///
		| main.cb_term.startswith("5way")	///
		| main.cb_term.startswith("6way")	///
	{
		call main.tx_fv4.show
		call main.vn_fv4.show
		call main.cb_base4.show
		call main.ck_cont4.show
		call program check_continuous_4
	}
	if main.cb_term.startswith("5way")		///
		| main.cb_term.startswith("6way")	///
	{
		call main.tx_fv5.show
		call main.vn_fv5.show
		call main.cb_base5.show
		call main.ck_cont5.show
		call program check_continuous_5
	}
	if main.cb_term.startswith("6way")		///
	{
		call main.tx_fv6.show
		call main.vn_fv6.show
		call main.cb_base6.show
		call main.ck_cont6.show
		call program check_continuous_6
	}
END

PROGRAM var1_output
BEGIN
	call s_local.setvalue ""
	if main.ck_cont1 {
		if b_isAnova | ! b_isMainEffect {
			call s_local.append "c"
		}
		if main.cb_base1 & main.cb_base1.isenabled() {
			call s_local.append "b("
			call s_local.append class main.cb_base1.value
			call s_local.append ")"
		}
		if main.ed_ts1 & main.ed_ts1.isenabled()  {
			call s_local.append class main.ed_ts1.value
		}
	}
	else {
		if ! b_isAnova & b_isMainEffect {
			call s_local.append "i"
		}
		if main.cb_base1 & main.cb_base1.isenabled() {
			call s_local.append "b("
			call s_local.append class main.cb_base1.value
			call s_local.append ")"
		}
		if ! main.sp_lag1.iseq(0) & main.sp_lag1.isenabled() {
			call s_local.append "L"
			if main.sp_lag1.islt(0) {
				call s_local.append "("
			}
			if ! main.sp_lag1.iseq(1) {
				call s_local.append class main.sp_lag1.value
			}
			if main.sp_lag1.islt(0) {
				call s_local.append ")"
			}
		}			
	}
	if s_local {
		call s_local.append "."
	}
	require main.vn_fv1
	call s_output.append class s_local.value
	call s_output.append class main.vn_fv1.value
END

PROGRAM var2_output
BEGIN
	call s_local.setvalue ""
	if main.ck_cont2 {
		if b_isAnova | ! b_isMainEffect {
			call s_local.append "c"
		}
		if main.cb_base2 & main.cb_base2.isenabled() {
			call s_local.append "b("
			call s_local.append class main.cb_base2.value
			call s_local.append ")"
		}
		if main.ed_ts2 & main.ed_ts2.isenabled() {
			call s_local.append class main.ed_ts2.value
		}
	}
	else {
		if ! b_isAnova & b_isMainEffect {
			call s_local.append "i"
		}
		if main.cb_base2 & main.cb_base2.isenabled() {
			call s_local.append "b("
			call s_local.append class main.cb_base2.value
			call s_local.append ")"
		}
		if ! main.sp_lag2.iseq(0) & main.sp_lag2.isenabled() {
			call s_local.append "L"
			if main.sp_lag2.islt(0) {
				call s_local.append "("
			}
			if ! main.sp_lag2.iseq(1) {
				call s_local.append class main.sp_lag2.value
			}
			if main.sp_lag2.islt(0) {
				call s_local.append ")"
			}
		}			
	}
	if s_local {
		call s_local.append "."
	}
	require main.vn_fv2
	call s_output.append class s_local.value
	call s_output.append class main.vn_fv2.value
END

PROGRAM var3_output
BEGIN
	call s_local.setvalue ""
	if main.ck_cont3 {
		if b_isAnova | ! b_isMainEffect {
			call s_local.append "c"
		}
		if main.cb_base3 & main.cb_base3.isenabled() {
			call s_local.append "b("
			call s_local.append class main.cb_base3.value
			call s_local.append ")"
		}
		if main.ed_ts3 & main.ed_ts3.isenabled() {
			call s_local.append class main.ed_ts3.value
		}
	}
	else {
		if ! b_isAnova & b_isMainEffect {
			call s_local.append "i"
		}
		if main.cb_base3 & main.cb_base3.isenabled() {
			call s_local.append "b("
			call s_local.append class main.cb_base3.value
			call s_local.append ")"
		}
		if ! main.sp_lag3.iseq(0) & main.sp_lag3.isenabled() {
			call s_local.append "L"
			if main.sp_lag3.islt(0) {
				call s_local.append "("
			}
			if ! main.sp_lag3.iseq(1) {
				call s_local.append class main.sp_lag3.value
			}
			if main.sp_lag3.islt(0) {
				call s_local.append ")"
			}
		}			
	}
	if s_local {
		call s_local.append "."
	}
	require main.vn_fv3
	call s_output.append class s_local.value
	call s_output.append class main.vn_fv3.value
END

PROGRAM var4_output
BEGIN
	call s_local.setvalue ""
	if main.ck_cont4 {
		if b_isAnova | ! b_isMainEffect {
			call s_local.append "c"
		}
		if main.cb_base4 & main.cb_base4.isenabled() {
			call s_local.append "b("
			call s_local.append class main.cb_base4.value
			call s_local.append ")"
		}
		if main.ed_ts4 & main.ed_ts4.isenabled() {
			call s_local.append class main.ed_ts4.value
		}
	}
	else {
		if ! b_isAnova & b_isMainEffect {
			call s_local.append "i"
		}
		if main.cb_base4 & main.cb_base4.isenabled() {
			call s_local.append "b("
			call s_local.append class main.cb_base4.value
			call s_local.append ")"
		}
		if ! main.sp_lag4.iseq(0) & main.sp_lag4.isenabled() {
			call s_local.append "L"
			if main.sp_lag4.islt(0) {
				call s_local.append "("
			}
			if ! main.sp_lag4.iseq(1) {
				call s_local.append class main.sp_lag4.value
			}
			if main.sp_lag4.islt(0) {
				call s_local.append ")"
			}
		}			
	}
	if s_local {
		call s_local.append "."
	}
	require main.vn_fv4
	call s_output.append class s_local.value
	call s_output.append class main.vn_fv4.value
END

PROGRAM var5_output
BEGIN
	call s_local.setvalue ""
	if main.ck_cont5 {
		if b_isAnova | ! b_isMainEffect {
			call s_local.append "c"
		}
		if main.cb_base5 & main.cb_base5.isenabled() {
			call s_local.append "b("
			call s_local.append class main.cb_base5.value
			call s_local.append ")"
		}
		if main.ed_ts5 & main.ed_ts5.isenabled(){
			call s_local.append class main.ed_ts5.value
		}
	}
	else {
		if ! b_isAnova & b_isMainEffect {
			call s_local.append "i"
		}
		if main.cb_base5 & main.cb_base5.isenabled() {
			call s_local.append "b("
			call s_local.append class main.cb_base5.value
			call s_local.append ")"
		}
		if ! main.sp_lag5.iseq(0) & main.sp_lag5.isenabled() {
			call s_local.append "L"
			if main.sp_lag5.islt(0) {
				call s_local.append "("
			}
			if ! main.sp_lag5.iseq(1) {
				call s_local.append class main.sp_lag5.value
			}
			if main.sp_lag5.islt(0) {
				call s_local.append ")"
			}
		}			
	}
	if s_local {
		call s_local.append "."
	}
	require main.vn_fv5
	call s_output.append class s_local.value
	call s_output.append class main.vn_fv5.value
END

PROGRAM var6_output
BEGIN
	call s_local.setvalue ""
	if main.ck_cont6 {
		if b_isAnova | ! b_isMainEffect {
			call s_local.append "c"
		}
		if main.cb_base6 & main.cb_base6.isenabled() {
			call s_local.append "b("
			call s_local.append class main.cb_base6.value
			call s_local.append ")"
		}
		if main.ed_ts6 & main.ed_ts6.isenabled() {
			call s_local.append class main.ed_ts6.value
		}
	}
	else {
		if ! b_isAnova & b_isMainEffect {
			call s_local.append "i"
		}
		if main.cb_base6 & main.cb_base6.isenabled() {
			call s_local.append "b("
			call s_local.append class main.cb_base6.value
			call s_local.append ")"
		}
		if ! main.sp_lag6.iseq(0) & main.sp_lag6.isenabled() {
			call s_local.append "L"
			if main.sp_lag6.islt(0) {
				call s_local.append "("
			}
			if ! main.sp_lag6.iseq(1) {
				call s_local.append class main.sp_lag6.value
			}
			if main.sp_lag6.islt(0) {
				call s_local.append ")"
			}
		}			
	}
	if s_local {
		call s_local.append "."
	}
	require main.vn_fv6
	call s_output.append class s_local.value
	call s_output.append class main.vn_fv6.value
END

PROGRAM _fv_core_add
BEGIN

	if main.cb_term.iseq("main-effect") {
		call b_isMainEffect.settrue
		put /program var1_output
		call b_isMainEffect.setfalse
	}
	if main.cb_term.iseq("2way-interaction") {
		put /program var1_output
		call s_output.append "#"
		put /program var2_output
	}
	if main.cb_term.iseq("2way-fullfactorial") {
		put /program var1_output
		call s_output.append "##"
		put /program var2_output
	}
	if main.cb_term.iseq("3way-interaction") {
		put /program var1_output
		call s_output.append "#"
		put /program var2_output
		call s_output.append "#"
		put /program var3_output
	}
	if main.cb_term.iseq("3way-fullfactorial") {
		put /program var1_output
		call s_output.append "##"
		put /program var2_output
		call s_output.append "##"
		put /program var3_output
	}
	if main.cb_term.iseq("4way-interaction") {
		put /program var1_output
		call s_output.append "#"
		put /program var2_output
		call s_output.append "#"
		put /program var3_output
		call s_output.append "#"
		put /program var4_output
	}
	if main.cb_term.iseq("4way-fullfactorial") {
		put /program var1_output
		call s_output.append "##"
		put /program var2_output
		call s_output.append "##"
		put /program var3_output
		call s_output.append "##"
		put /program var4_output
	}
	if main.cb_term.iseq("5way-interaction") {
		put /program var1_output
		call s_output.append "#"
		put /program var2_output
		call s_output.append "#"
		put /program var3_output
		call s_output.append "#"
		put /program var4_output
		call s_output.append "#"
		put /program var5_output
	}
	if main.cb_term.iseq("5way-fullfactorial") {
		put /program var1_output
		call s_output.append "##"
		put /program var2_output
		call s_output.append "##"
		put /program var3_output
		call s_output.append "##"
		put /program var4_output
		call s_output.append "##"
		put /program var5_output
	}
	if main.cb_term.iseq("6way-interaction") {
		put /program var1_output
		call s_output.append "#"
		put /program var2_output
		call s_output.append "#"
		put /program var3_output
		call s_output.append "#"
		put /program var4_output
		call s_output.append "#"
		put /program var5_output
		call s_output.append "#"
		put /program var6_output
	}
	if main.cb_term.iseq("6way-fullfactorial") {
		put /program var1_output
		call s_output.append "##"
		put /program var2_output
		call s_output.append "##"
		put /program var3_output
		call s_output.append "##"
		put /program var4_output
		call s_output.append "##"
		put /program var5_output
		call s_output.append "##"
		put /program var6_output
	}
END

PROGRAM check_continuous_1
BEGIN
	if main.ck_cont1 {
		call main.cb_base1.disable
	}
	else {
		call main.cb_base1.enable
	}

	if ! b_allowTS {
		call main.sp_lag1.hide
		call main.tx_lag1.hide
		call main.ed_ts1.hide
		call main.bu_ts1.hide
		exit
	}
	if main.ck_cont1.isvisible() & !main.ck_cont1 {
		call main.sp_lag1.show
		call main.tx_lag1.show
		call main.ed_ts1.hide
		call main.bu_ts1.hide
	}
	if main.ck_cont1.isvisible() & main.ck_cont1 {
		call main.sp_lag1.hide
		call main.tx_lag1.hide
		call main.ed_ts1.show
		call main.bu_ts1.show
	}
END

PROGRAM check_continuous_2
BEGIN
	if main.ck_cont2 {
		call main.cb_base2.disable
	}
	else {
		call main.cb_base2.enable
	}

	if ! b_allowTS {
		call main.sp_lag2.hide
		call main.tx_lag2.hide
		call main.ed_ts2.hide
		call main.bu_ts2.hide
		exit
	}
	if main.ck_cont2.isvisible() & !main.ck_cont2 {
		call main.sp_lag2.show
		call main.tx_lag2.show
		call main.ed_ts2.hide
		call main.bu_ts2.hide
	}
	if main.ck_cont2.isvisible() & main.ck_cont2 {
		call main.sp_lag2.hide
		call main.tx_lag2.hide
		call main.ed_ts2.show
		call main.bu_ts2.show
	}
END

PROGRAM check_continuous_3
BEGIN
	if main.ck_cont3 {
		call main.cb_base3.disable
	}
	else {
		call main.cb_base3.enable
	}

	if ! b_allowTS {
		call main.sp_lag3.hide
		call main.tx_lag3.hide
		call main.ed_ts3.hide
		call main.bu_ts3.hide
		exit
	}
	if main.ck_cont3.isvisible() & !main.ck_cont3 {
		call main.sp_lag3.show
		call main.tx_lag3.show
		call main.ed_ts3.hide
		call main.bu_ts3.hide
	}
	if main.ck_cont3.isvisible() & main.ck_cont3 {
		call main.sp_lag3.hide
		call main.tx_lag3.hide
		call main.ed_ts3.show
		call main.bu_ts3.show
	}
END

PROGRAM check_continuous_4
BEGIN
	if main.ck_cont4 {
		call main.cb_base4.disable
	}
	else {
		call main.cb_base4.enable
	}

	if ! b_allowTS {
		call main.sp_lag4.hide
		call main.tx_lag4.hide
		call main.ed_ts4.hide
		call main.bu_ts4.hide
		exit
	}
	if main.ck_cont4.isvisible() & !main.ck_cont4 {
		call main.sp_lag4.show
		call main.tx_lag4.show
		call main.ed_ts4.hide
		call main.bu_ts4.hide
	}
	if main.ck_cont4.isvisible() & main.ck_cont4 {
		call main.sp_lag4.hide
		call main.tx_lag4.hide
		call main.ed_ts4.show
		call main.bu_ts4.show
	}
END

PROGRAM check_continuous_5
BEGIN
	if main.ck_cont5 {
		call main.cb_base5.disable
	}
	else {
		call main.cb_base5.enable
	}

	if ! b_allowTS {
		call main.sp_lag5.hide
		call main.tx_lag5.hide
		call main.ed_ts5.hide
		call main.bu_ts5.hide
		exit
	}
	if main.ck_cont5.isvisible() & !main.ck_cont5 {
		call main.sp_lag5.show
		call main.tx_lag5.show
		call main.ed_ts5.hide
		call main.bu_ts5.hide
	}
	if main.ck_cont5.isvisible() & main.ck_cont5 {
		call main.sp_lag5.hide
		call main.tx_lag5.hide
		call main.ed_ts5.show
		call main.bu_ts5.show
	}
END

PROGRAM check_continuous_6
BEGIN
	if main.ck_cont6 {
		call main.cb_base6.disable
	}
	else {
		call main.cb_base6.enable
	}

	if ! b_allowTS {
		call main.sp_lag6.hide
		call main.tx_lag6.hide
		call main.ed_ts6.hide
		call main.bu_ts6.hide
		exit
	}
	if main.ck_cont6.isvisible() & !main.ck_cont6 {
		call main.sp_lag6.show
		call main.tx_lag6.show
		call main.ed_ts6.hide
		call main.bu_ts6.hide
	}
	if main.ck_cont6.isvisible() & main.ck_cont6 {
		call main.sp_lag6.hide
		call main.tx_lag6.hide
		call main.ed_ts6.show
		call main.bu_ts6.show
	}
END

PROGRAM show_child_ts1
BEGIN
	call create STRING s_tsResult1
	call create CHILD _ts_operators AS ts_child_1
	call ts_child_1.setExitString "s_tsResult1"
	call ts_child_1.setExitAction "main.ed_ts1.setvalue class s_tsResult1.value"
END

PROGRAM show_child_ts2
BEGIN
	call create STRING s_tsResult2
	call create CHILD _ts_operators AS ts_child_2
	call ts_child_2.setExitString "s_tsResult2"
	call ts_child_2.setExitAction "main.ed_ts2.setvalue class s_tsResult2.value"
END

PROGRAM show_child_ts3
BEGIN
	call create STRING s_tsResult3
	call create CHILD _ts_operators AS ts_child_3
	call ts_child_3.setExitString "s_tsResult3"
	call ts_child_3.setExitAction "main.ed_ts3.setvalue class s_tsResult3.value"
END

PROGRAM show_child_ts4
BEGIN
	call create STRING s_tsResult4
	call create CHILD _ts_operators AS ts_child_4
	call ts_child_4.setExitString "s_tsResult4"
	call ts_child_4.setExitAction "main.ed_ts4.setvalue class s_tsResult4.value"
END

PROGRAM show_child_ts5
BEGIN
	call create STRING s_tsResult5
	call create CHILD _ts_operators AS ts_child_5
	call ts_child_5.setExitString "s_tsResult5"
	call ts_child_5.setExitAction "main.ed_ts5.setvalue class s_tsResult5.value"
END

PROGRAM show_child_ts6
BEGIN
	call create STRING s_tsResult6
	call create CHILD _ts_operators AS ts_child_6
	call ts_child_6.setExitString "s_tsResult6"
	call ts_child_6.setExitAction "main.ed_ts6.setvalue class s_tsResult6.value"
END

/* end _fv_core_pr.idlg */
