/*
  graph_pie.dlg

*!  VERSION 2.0.1  27jan2008

*/

VERSION 10.0

INCLUDE _std_xlarge
DEFINE _dlght 350
INCLUDE header

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

SCRIPT POSTINIT
BEGIN
	script weights_setLayout_fpa
	script gr_by_setAxesOptionsOff
END

DIALOG main, label("graph pie - Pie charts") tabtitle("Main")
BEGIN
 GROUPBOX gb_type	_lft	_top	400	_ht11h,		///
	label("Pie chart")
  RADIO    rb_over	_ilft	_ss	_inwd	.,		///
	first label("Graph by categories")			///
	onclickon(script pie_graph_by_cat)
  RADIO    rb_varlist	@	_ss	@	.,		///
	last label("Graph by variables")			///
	onclickon(script pie_graph_by_var)

  GROUPBOX gb_vars	@	_ms	@	_ht4,

  TEXT     tx_vars	_indent	_ss	_inwd	.,		///
	label("Variables:")
DEFINE y @y
  VARLIST  vl_var	@	_ss	@	.,		///
	label("Variables")

  TEXT     tx_over	@	y	_vnwd	.,		///
  	label("Category variable:")
  VARNAME  vn_over	@	_ss	@	.,		///
	label("Category variable") option(over)

  TEXT     tx_var	+150	y	@	.,		///
  	label("Variable: (optional)")
  VARNAME  vn_var	@	_ss	@	.,		///
  	label("Variable")
END

SCRIPT pie_graph_by_cat
BEGIN
	main.tx_vars.hide
	main.vl_var.hide
	main.tx_var.show
	main.vn_var.show
	main.tx_over.show
	main.vn_over.show
END

SCRIPT pie_graph_by_var
BEGIN
	main.tx_var.hide
	main.vn_var.hide
	main.tx_over.hide
	main.vn_over.hide
	main.tx_vars.show
	main.vl_var.show
END

INCLUDE ifin
INCLUDE weights

DIALOG options, tabtitle("Options")
BEGIN
  GROUPBOX gb_missing	_lft	_top	_iwd	_ht4h,		///
	label("Missing values")
  CHECKBOX ck_miss	_ilft	_ss	_ibwd	.,		///
	label("Include categories for missing values")		///
	option(missing)
  CHECKBOX ck_cw	@	_ms	@	.,		///
	option(cw)						///
	label("Exclude observations with missing values (casewise deletion)")

  GROUPBOX gb_ord	_lft	+45	_iwd	_ht8h,		///
	label("Slice order and placement")

  RADIO    rb_default	_ilft   _ss	_cwd2	.,		///
	first label("Default order") 				///
	onclickon(gaction options.vn_order.disable)
DEFINE y @y
  RADIO    rb_size	@	_ss	@	.,		///
 	label("Size order") option(sort)			///
	onclickon(options.vn_order.disable)
  RADIO    rb_order	@	_ss	@	.,		///
	last label("Order by this variable:") 			///
	onclickon(options.vn_order.enable)
  VARNAME  vn_order	+20	_ss	_vnwd	.,		///
	label("Order by this variable") option(sort)

  CHECKBOX ck_desc	_lft2	 -55	_cwd2   .,		///
	label("Reverse order") option(descending)
  CHECKBOX ck_nocl	@	_ms	@	.,		///
	label("Order counterclockwise") option(noclockwise)

  SPINNER  sp_angle	@	+30	_spwd	.,		///
	default(90) min(0) max(360) option(angle)
  TEXT     tx_angle	_spsep	@	_spr2b	.,		///
	label("Angle of first slice (degrees)")
END

PROGRAM options_output
BEGIN
	option options.ck_miss
	option options.ck_cw
	option options.rb_size
	optionarg options.vn_order
	option options.ck_desc
	option options.ck_nocl
	optionarg /hidedefault options.sp_angle
END

SCRIPT slice_PREINIT
BEGIN
	create STRING sliceAllSliceResult
	create STRING slice_result1
	create STRING slice_result2
	create STRING slice_result3
	create STRING slice_result4
	create STRING slice_result5
	create STRING slice_result6
	create STRING slice_result7
	create STRING slice_result8
	create STRING slice_result9
	create STRING slice_result10
	create STRING slice_result11
	create STRING slice_result12
	create STRING slice_result13
	create STRING slice_result14
	create STRING slice_result15
	create STRING slice_result16

	create STRING sliceAllLabelResult
	create STRING slice_labelResult1
	create STRING slice_labelResult2
	create STRING slice_labelResult3
	create STRING slice_labelResult4
	create STRING slice_labelResult5
	create STRING slice_labelResult6
	create STRING slice_labelResult7
	create STRING slice_labelResult8
	create STRING slice_labelResult9
	create STRING slice_labelResult10
	create STRING slice_labelResult11
	create STRING slice_labelResult12
	create STRING slice_labelResult13
	create STRING slice_labelResult14
	create STRING slice_labelResult15
	create STRING slice_labelResult16
END

SCRIPT slice_POSTINIT
BEGIN
	program sliceAllSliceCheckResult
	program sliceAllLabelCheckResult
	program slice_rebuild_list
	program slice_rebuild_labelList
END

DIALOG slice, tabtitle("Slices")
BEGIN
  GROUPBOX gb_slice	_lft	_top	_iwd	_ht13,		///
	label("Slice properties")
  RADIO    rb_allslice	_ilft	_ss	220	.,		///
	first							///
	label("Customize all slice properties")			///
	onclickon(program slice_check_mode)
DEFINE y @y
  RADIO    rb_indslice	_ilft	_ss	220	.,		///
	last							///
	label("Customize individual slice properties")		///
	onclickon(program slice_check_mode)

  BUTTON   bu_allslice	+20	+25	130	.,		///
	label("Slice properties (all) ")			///
	onpush(script slice_show_allslice)

  LISTBOX  lb_slices	@	@	120	80,		///
	contents(slice_sliceList) 				///
	values(slice_sliceList_values)		 		///
	ondblclick(program slice_check_selection)
  BUTTON   bu_slices	+130	@	60	.,		///
	label("Edit")						///
	tooltip("Click to edit the properties of the selected item") ///
	onpush(program slice_check_selection)


  GROUPBOX gb_global	_irj230	y	230	_ht9h,		///
	label("Global properties")

  TEXT     tx_lcol	_irj220	_ms	85	.,		///
	label("Outline color:") right
  COMBOBOX cb_lcol	+90	@	100	.,		///
	contents(colors) option(lcolor)				///
	onselchangelist(slice_lcol_change) dropdownlist
  COLOR    cl_lcol	+105	@	15	.,		///
	option(lcolor)

  TEXT     tx_lwid	_irj220	_ls	85	.,		///
	label("Outline width:") right
  COMBOBOX cb_lwid	+90	@	100	.,		///
	contents(linewidths) option(lwidth) dropdownlist

  TEXT     tx_int	_irj220	_ls	85	.,		///
	label("Fill intensity:") right
  COMBOBOX cb_int	+90	@	100	.,		///
	dropdown contents(intensity)				///
	label("Intensity") option(intensity)


  GROUPBOX gb_label	_lft	180	_iwd	_ht13,		///
	label("Labels")

  RADIO    rb_allLabel	_ilft	_ss	220	.,		///
	first							///
	label("Customize all slice labels"	)		///
	onclickon(program slice_check_labelMode)
DEFINE y @y
  RADIO    rb_indLabel	_ilft	_ss	220	.,		///
	last							///
	label("Customize individual slice labels")		///
	onclickon(program slice_check_labelMode)

  BUTTON   bu_allLabel	+20	+25	130	.,		///
	label("Label properties (all) ")			///
	onpush(script slice_show_allLabel)

  LISTBOX  lb_indLabel	@	@	120	80,		///
	contents(slice_labelList) 				///
	values(slice_labelList_values)				///
	ondblclick(program slice_checkLabel_selection)
  BUTTON   bu_indLabel	+130	@	60	.,		///
	label("Edit")						///
	tooltip("Click to edit the properties of the selected item") ///
	onpush(program slice_checkLabel_selection)
END

SCRIPT  slice_show_allslice
BEGIN
	create CHILD gr_pieslice_edit AS allsliceDLG, allowsubmit
	allsliceDLG.setExitString "sliceAllSliceResult"
	allsliceDLG.setSubmitAction "script sliceAllSliceSubmit"
	allsliceDLG.setOkAction "program sliceAllSliceCheckResult"
	allsliceDLG.settitle "Pie slice properties (all)"
END
PROGRAM sliceAllSliceCheckResult
BEGIN
	if sliceAllSliceResult {
		call slice.bu_allslice.setlabel "Slice properties (all) *"
	}
	else {
		call slice.bu_allslice.setlabel "Slice properties (all)  "
	}
END
SCRIPT sliceAllSliceSubmit
BEGIN
	program sliceAllSliceCheckResult
	Submit
END

LIST slice_lcol_change
BEGIN
	slice.cl_lcol.hide
	slice.cl_lcol.show
	slice.cl_lcol.hide
END

PROGRAM slice_check_mode
BEGIN
	if slice.rb_allslice {
		call slice.bu_allslice.show
		call slice.lb_slices.hide
		call slice.bu_slices.hide
	}
	else {
		call slice.bu_allslice.hide
		call slice.lb_slices.show
		call slice.bu_slices.show
	}
END

LIST slice_sliceList
BEGIN
	Slice 1
	Slice 2
	Slice 3
	Slice 4
	Slice 5
	Slice 6
	Slice 7
	Slice 8
	Slice 9
	Slice 10
	Slice 11
	Slice 12
	Slice 13
	Slice 14
	Slice 15
	Slice 16
END

LIST slice_sliceList_values
BEGIN
	"Slice 1"
	"Slice 2"
	"Slice 3"
	"Slice 4"
	"Slice 5"
	"Slice 6"
	"Slice 7"
	"Slice 8"
	"Slice 9"
	"Slice 10"
	"Slice 11"
	"Slice 12"
	"Slice 13"
	"Slice 14"
	"Slice 15"
	"Slice 16"
END

PROGRAM slice_check_selection
BEGIN
	if slice.lb_slices.iseq("Slice 1") {
		call script slice_edit_slice1
	}
	if slice.lb_slices.iseq("Slice 2") {
		call script slice_edit_slice2
	}
	if slice.lb_slices.iseq("Slice 3") {
		call script slice_edit_slice3
	}
	if slice.lb_slices.iseq("Slice 4") {
		call script slice_edit_slice4
	}
	if slice.lb_slices.iseq("Slice 5") {
		call script slice_edit_slice5
	}
	if slice.lb_slices.iseq("Slice 6") {
		call script slice_edit_slice6
	}
	if slice.lb_slices.iseq("Slice 7") {
		call script slice_edit_slice7
	}
	if slice.lb_slices.iseq("Slice 8") {
		call script slice_edit_slice8
	}
	if slice.lb_slices.iseq("Slice 9") {
		call script slice_edit_slice9
	}
	if slice.lb_slices.iseq("Slice 10") {
		call script slice_edit_slice10
	}
	if slice.lb_slices.iseq("Slice 11") {
		call script slice_edit_slice11
	}
	if slice.lb_slices.iseq("Slice 12") {
		call script slice_edit_slice12
	}
	if slice.lb_slices.iseq("Slice 13") {
		call script slice_edit_slice13
	}
	if slice.lb_slices.iseq("Slice 14") {
		call script slice_edit_slice14
	}
	if slice.lb_slices.iseq("Slice 15") {
		call script slice_edit_slice15
	}
	if slice.lb_slices.iseq("Slice 16") {
		call script slice_edit_slice16
	}
END

SCRIPT slice_edit_slice1
BEGIN
	create CHILD gr_pieslice_edit AS slice1, allowsubmit
	slice1.setExitString "slice_result1"
	slice1.setExitAction "program slice_rebuild_list"
	slice1.setSubmitAction "program slice1_submit"
	slice1.settitle "Slice 1 properties"
END
PROGRAM slice1_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice2
BEGIN
	create CHILD gr_pieslice_edit AS slice2, allowsubmit
	slice2.setExitString "slice_result2"
	slice2.setExitAction "program slice_rebuild_list"
	slice2.setSubmitAction "program slice2_submit"
	slice2.settitle "Slice 2 properties"
END
PROGRAM slice2_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice3
BEGIN
	create CHILD gr_pieslice_edit AS slice3, allowsubmit
	slice3.setExitString "slice_result3"
	slice3.setExitAction "program slice_rebuild_list"
	slice3.setSubmitAction "program slice3_submit"
	slice3.settitle "Slice 3 properties"
END
PROGRAM slice3_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice4
BEGIN
	create CHILD gr_pieslice_edit AS slice4, allowsubmit
	slice4.setExitString "slice_result4"
	slice4.setExitAction "program slice_rebuild_list"
	slice4.setSubmitAction "program slice4_submit"
	slice4.settitle "Slice 4 properties"
END
PROGRAM slice4_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice5
BEGIN
	create CHILD gr_pieslice_edit AS slice5, allowsubmit
	slice5.setExitString "slice_result5"
	slice5.setExitAction "program slice_rebuild_list"
	slice5.setSubmitAction "program slice5_submit"
	slice5.settitle "Slice 5 properties"
END
PROGRAM slice5_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice6
BEGIN
	create CHILD gr_pieslice_edit AS slice6, allowsubmit
	slice6.setExitString "slice_result6"
	slice6.setExitAction "program slice_rebuild_list"
	slice6.setSubmitAction "program slice6_submit"
	slice6.settitle "Slice 6 properties"
END
PROGRAM slice6_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice7
BEGIN
	create CHILD gr_pieslice_edit AS slice7, allowsubmit
	slice7.setExitString "slice_result7"
	slice7.setExitAction "program slice_rebuild_list"
	slice7.setSubmitAction "program slice7_submit"
	slice7.settitle "Slice 7 properties"
END
PROGRAM slice7_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice8
BEGIN
	create CHILD gr_pieslice_edit AS slice8, allowsubmit
	slice8.setExitString "slice_result8"
	slice8.setExitAction "program slice_rebuild_list"
	slice8.setSubmitAction "program slice8_submit"
	slice8.settitle "Slice 8 properties"
END
PROGRAM slice8_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice9
BEGIN
	create CHILD gr_pieslice_edit AS slice9, allowsubmit
	slice9.setExitString "slice_result9"
	slice9.setExitAction "program slice_rebuild_list"
	slice9.setSubmitAction "program slice9_submit"
	slice9.settitle "Slice 9 properties"
END
PROGRAM slice9_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice10
BEGIN
	create CHILD gr_pieslice_edit AS slice10, allowsubmit
	slice10.setExitString "slice_result10"
	slice10.setExitAction "program slice_rebuild_list"
	slice10.setSubmitAction "program slice10_submit"
	slice10.settitle "Slice 10 properties"
END
PROGRAM slice10_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice11
BEGIN
	create CHILD gr_pieslice_edit AS slice11, allowsubmit
	slice11.setExitString "slice_result11"
	slice11.setExitAction "program slice_rebuild_list"
	slice11.setSubmitAction "program slice11_submit"
	slice11.settitle "Slice 11 properties"
END
PROGRAM slice11_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice12
BEGIN
	create CHILD gr_pieslice_edit AS slice12, allowsubmit
	slice12.setExitString "slice_result12"
	slice12.setExitAction "program slice_rebuild_list"
	slice12.setSubmitAction "program slice12_submit"
	slice12.settitle "Slice 12 properties"
END
PROGRAM slice12_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice13
BEGIN
	create CHILD gr_pieslice_edit AS slice13, allowsubmit
	slice13.setExitString "slice_result13"
	slice13.setExitAction "program slice_rebuild_list"
	slice13.setSubmitAction "program slice13_submit"
	slice13.settitle "Slice 13 properties"
END
PROGRAM slice13_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice14
BEGIN
	create CHILD gr_pieslice_edit AS slice14, allowsubmit
	slice14.setExitString "slice_result14"
	slice14.setExitAction "program slice_rebuild_list"
	slice14.setSubmitAction "program slice14_submit"
	slice14.settitle "Slice 14 properties"
END
PROGRAM slice14_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice15
BEGIN
	create CHILD gr_pieslice_edit AS slice15, allowsubmit
	slice15.setExitString "slice_result15"
	slice15.setExitAction "program slice_rebuild_list"
	slice15.setSubmitAction "program slice15_submit"
	slice15.settitle "Slice 15 properties"
END
PROGRAM slice15_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

SCRIPT slice_edit_slice16
BEGIN
	create CHILD gr_pieslice_edit AS slice16, allowsubmit
	slice16.setExitString "slice_result16"
	slice16.setExitAction "program slice_rebuild_list"
	slice16.setSubmitAction "program slice16_submit"
	slice16.settitle "Slice 16 properties"
END
PROGRAM slice16_submit
BEGIN
	call program slice_rebuild_list
	call Submit
END

PROGRAM slice_rebuild_list
BEGIN
	call slice_sliceList.Arrdropall
	
	if slice_result1 {
		call slice_sliceList.Arrpush "Slice 1 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 1  "
	}
	if slice_result2 {
		call slice_sliceList.Arrpush "Slice 2 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 2  "
	}
	if slice_result3 {
		call slice_sliceList.Arrpush "Slice 3 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 3  "
	}
	if slice_result4 {
		call slice_sliceList.Arrpush "Slice 4 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 4  "
	}
	if slice_result5 {
		call slice_sliceList.Arrpush "Slice 5 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 5  "
	}
	if slice_result6 {
		call slice_sliceList.Arrpush "Slice 6 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 6  "
	}
	if slice_result7 {
		call slice_sliceList.Arrpush "Slice 7 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 7  "
	}
	if slice_result8 {
		call slice_sliceList.Arrpush "Slice 8 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 8  "
	}
	if slice_result9 {
		call slice_sliceList.Arrpush "Slice 9 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 9  "
	}
	if slice_result10 {
		call slice_sliceList.Arrpush "Slice 10 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 10  "
	}
	if slice_result11 {
		call slice_sliceList.Arrpush "Slice 11 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 11  "
	}
	if slice_result12 {
		call slice_sliceList.Arrpush "Slice 12 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 12  "
	}
	if slice_result13 {
		call slice_sliceList.Arrpush "Slice 13 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 13  "
	}
	if slice_result14 {
		call slice_sliceList.Arrpush "Slice 14 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 14  "
	}
	if slice_result15 {
		call slice_sliceList.Arrpush "Slice 15 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 15  "
	}
	if slice_result16 {
		call slice_sliceList.Arrpush "Slice 16 *"
	}
	else {
		call slice_sliceList.Arrpush "Slice 16  "
	}
	call slice.lb_slices.repopulate
END

PROGRAM slice_edit_slices_output
BEGIN
	if slice_result1 {
		put "pie(1, " slice_result1 ") "
	}
	if slice_result2 {
		put "pie(2, " slice_result2 ") "
	}
	if slice_result3 {
		put "pie(3, " slice_result3 ") "
	}
	if slice_result4 {
		put "pie(4, " slice_result4 ") "
	}
	if slice_result5 {
		put "pie(5, " slice_result5 ") "
	}
	if slice_result6 {
		put "pie(6, " slice_result6 ") "
	}
	if slice_result7 {
		put "pie(7, " slice_result7 ") "
	}
	if slice_result8 {
		put "pie(8, " slice_result8 ") "
	}
	if slice_result9 {
		put "pie(9, " slice_result9 ") "
	}
	if slice_result10 {
		put "pie(10, " slice_result10 ") "
	}
	if slice_result11 {
		put "pie(11, " slice_result11 ") "
	}
	if slice_result12 {
		put "pie(12, " slice_result12 ") "
	}
	if slice_result13 {
		put "pie(13, " slice_result13 ") "
	}
	if slice_result14 {
		put "pie(14, " slice_result14 ") "
	}
	if slice_result15 {
		put "pie(15, " slice_result15 ") "
	}
	if slice_result16 {
		put "pie(16, " slice_result16 ") "
	}
END

PROGRAM slice_check_labelMode
BEGIN
	if slice.rb_allLabel {
		call slice.bu_allLabel.show
		call slice.lb_indLabel.hide
		call slice.bu_indLabel.hide
	}
	else {
		call slice.bu_allLabel.hide
		call slice.lb_indLabel.show
		call slice.bu_indLabel.show
	}
END

SCRIPT  slice_show_allLabel
BEGIN
	create CHILD gr_pielabel_edit AS allLabelDLG, allowsubmit
	allLabelDLG.setExitString "sliceAllLabelResult"
	allLabelDLG.setSubmitAction "script sliceAllLabelSubmit"
	allLabelDLG.setOkAction "program sliceAllLabelCheckResult"
	allLabelDLG.settitle "Pie label properties (all)"
END
PROGRAM sliceAllLabelCheckResult
BEGIN
	if sliceAllSliceResult {
		call slice.bu_allLabel.setlabel "Label properties (all) *"
	}
	else {
		call slice.bu_allLabel.setlabel "Label properties (all)  "
	}
END
SCRIPT sliceAllLabelSubmit
BEGIN
	program sliceAllLabelCheckResult
	Submit
END

LIST slice_labelList
BEGIN
	Slice 1
	Slice 2
	Slice 3
	Slice 4
	Slice 5
	Slice 6
	Slice 7
	Slice 8
	Slice 9
	Slice 10
	Slice 11
	Slice 12
	Slice 13
	Slice 14
	Slice 15
	Slice 16
END

LIST slice_labelList_values
BEGIN
	"Slice 1"
	"Slice 2"
	"Slice 3"
	"Slice 4"
	"Slice 5"
	"Slice 6"
	"Slice 7"
	"Slice 8"
	"Slice 9"
	"Slice 10"
	"Slice 11"
	"Slice 12"
	"Slice 13"
	"Slice 14"
	"Slice 15"
	"Slice 16"
END

PROGRAM slice_checkLabel_selection
BEGIN
	if slice.lb_indLabel.iseq("Slice 1") {
		call script slice_edit_label1
	}
	if slice.lb_indLabel.iseq("Slice 2") {
		call script slice_edit_label2
	}
	if slice.lb_indLabel.iseq("Slice 3") {
		call script slice_edit_label3
	}
	if slice.lb_indLabel.iseq("Slice 4") {
		call script slice_edit_label4
	}
	if slice.lb_indLabel.iseq("Slice 5") {
		call script slice_edit_label5
	}
	if slice.lb_indLabel.iseq("Slice 6") {
		call script slice_edit_label6
	}
	if slice.lb_indLabel.iseq("Slice 7") {
		call script slice_edit_label7
	}
	if slice.lb_indLabel.iseq("Slice 8") {
		call script slice_edit_label8
	}
	if slice.lb_indLabel.iseq("Slice 9") {
		call script slice_edit_label9
	}
	if slice.lb_indLabel.iseq("Slice 10") {
		call script slice_edit_label10
	}
	if slice.lb_indLabel.iseq("Slice 11") {
		call script slice_edit_label11
	}
	if slice.lb_indLabel.iseq("Slice 12") {
		call script slice_edit_label12
	}
	if slice.lb_indLabel.iseq("Slice 13") {
		call script slice_edit_label13
	}
	if slice.lb_indLabel.iseq("Slice 14") {
		call script slice_edit_label14
	}
	if slice.lb_indLabel.iseq("Slice 15") {
		call script slice_edit_label15
	}
	if slice.lb_indLabel.iseq("Slice 16") {
		call script slice_edit_label16
	}
END

SCRIPT slice_edit_label1
BEGIN
	create CHILD gr_pielabel_edit AS label1, allowsubmit
	label1.setExitString "slice_labelResult1"
	label1.setExitAction "program slice_rebuild_labelList"
	label1.setSubmitAction "program label1_submit"
	label1.settitle "Slice 1 label properties"
END
PROGRAM label1_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label2
BEGIN
	create CHILD gr_pielabel_edit AS label2, allowsubmit
	label2.setExitString "slice_labelResult2"
	label2.setExitAction "program slice_rebuild_labelList"
	label2.setSubmitAction "program label2_submit"
	label2.settitle "Slice 2 label properties"
END
PROGRAM label2_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label3
BEGIN
	create CHILD gr_pielabel_edit AS label3, allowsubmit
	label3.setExitString "slice_labelResult3"
	label3.setExitAction "program slice_rebuild_labelList"
	label3.setSubmitAction "program label3_submit"
	label3.settitle "Slice 3 label properties"
END
PROGRAM label3_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label4
BEGIN
	create CHILD gr_pielabel_edit AS label4, allowsubmit
	label4.setExitString "slice_labelResult4"
	label4.setExitAction "program slice_rebuild_labelList"
	label4.setSubmitAction "program label4_submit"
	label4.settitle "Slice 4 label properties"
END
PROGRAM label4_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label5
BEGIN
	create CHILD gr_pielabel_edit AS label5, allowsubmit
	label5.setExitString "slice_labelResult5"
	label5.setExitAction "program slice_rebuild_labelList"
	label5.setSubmitAction "program label5_submit"
	label5.settitle "Slice 5 label properties"
END
PROGRAM label5_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label6
BEGIN
	create CHILD gr_pielabel_edit AS label6, allowsubmit
	label6.setExitString "slice_labelResult6"
	label6.setExitAction "program slice_rebuild_labelList"
	label6.setSubmitAction "program label6_submit"
	label6.settitle "Slice 6 label properties"
END
PROGRAM label6_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label7
BEGIN
	create CHILD gr_pielabel_edit AS label7, allowsubmit
	label7.setExitString "slice_labelResult7"
	label7.setExitAction "program slice_rebuild_labelList"
	label7.setSubmitAction "program label7_submit"
	label7.settitle "Slice 7 label properties"
END
PROGRAM label7_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label8
BEGIN
	create CHILD gr_pielabel_edit AS label8, allowsubmit
	label8.setExitString "slice_labelResult8"
	label8.setExitAction "program slice_rebuild_labelList"
	label8.setSubmitAction "program label8_submit"
	label8.settitle "Slice 8 label properties"
END
PROGRAM label8_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label9
BEGIN
	create CHILD gr_pielabel_edit AS label9, allowsubmit
	label9.setExitString "slice_labelResult9"
	label9.setExitAction "program slice_rebuild_labelList"
	label9.setSubmitAction "program label9_submit"
	label9.settitle "Slice 9 label properties"
END
PROGRAM label9_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label10
BEGIN
	create CHILD gr_pielabel_edit AS label10, allowsubmit
	label10.setExitString "slice_labelResult10"
	label10.setExitAction "program slice_rebuild_labelList"
	label10.setSubmitAction "program label10_submit"
	label10.settitle "Slice 10 label properties"
END
PROGRAM label10_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label11
BEGIN
	create CHILD gr_pielabel_edit AS label11, allowsubmit
	label11.setExitString "slice_labelResult11"
	label11.setExitAction "program slice_rebuild_labelList"
	label11.setSubmitAction "program label11_submit"
	label11.settitle "Slice 11 label properties"
END
PROGRAM label11_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label12
BEGIN
	create CHILD gr_pielabel_edit AS label12, allowsubmit
	label12.setExitString "slice_labelResult12"
	label12.setExitAction "program slice_rebuild_labelList"
	label12.setSubmitAction "program label12_submit"
	label12.settitle "Slice 12 label properties"
END
PROGRAM label12_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label13
BEGIN
	create CHILD gr_pielabel_edit AS label13, allowsubmit
	label13.setExitString "slice_labelResult13"
	label13.setExitAction "program slice_rebuild_labelList"
	label13.setSubmitAction "program label13_submit"
	label13.settitle "Slice 13 label properties"
END
PROGRAM label13_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label14
BEGIN
	create CHILD gr_pielabel_edit AS label14, allowsubmit
	label14.setExitString "slice_labelResult14"
	label14.setExitAction "program slice_rebuild_labelList"
	label14.setSubmitAction "program label14_submit"
	label14.settitle "Slice 14 label properties"
END
PROGRAM label14_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label15
BEGIN
	create CHILD gr_pielabel_edit AS label15, allowsubmit
	label15.setExitString "slice_labelResult15"
	label15.setExitAction "program slice_rebuild_labelList"
	label15.setSubmitAction "program label15_submit"
	label15.settitle "Slice 15 label properties"
END
PROGRAM label15_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

SCRIPT slice_edit_label16
BEGIN
	create CHILD gr_pielabel_edit AS label16, allowsubmit
	label16.setExitString "slice_labelResult16"
	label16.setExitAction "program slice_rebuild_labelList"
	label16.setSubmitAction "program label16_submit"
	label16.settitle "Slice 16 label properties"
END
PROGRAM label16_submit
BEGIN
	call program slice_rebuild_labelList
	call Submit
END

PROGRAM slice_rebuild_labelList
BEGIN
	call slice_labelList.Arrdropall
	
	if slice_labelResult1 {
		call slice_labelList.Arrpush "Slice 1 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 1  "
	}
	if slice_labelResult2 {
		call slice_labelList.Arrpush "Slice 2 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 2  "
	}
	if slice_labelResult3 {
		call slice_labelList.Arrpush "Slice 3 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 3  "
	}
	if slice_labelResult4 {
		call slice_labelList.Arrpush "Slice 4 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 4  "
	}
	if slice_labelResult5 {
		call slice_labelList.Arrpush "Slice 5 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 5  "
	}
	if slice_labelResult6 {
		call slice_labelList.Arrpush "Slice 6 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 6  "
	}
	if slice_labelResult7 {
		call slice_labelList.Arrpush "Slice 7 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 7  "
	}
	if slice_labelResult8 {
		call slice_labelList.Arrpush "Slice 8 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 8  "
	}
	if slice_labelResult9 {
		call slice_labelList.Arrpush "Slice 9 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 9  "
	}
	if slice_labelResult10 {
		call slice_labelList.Arrpush "Slice 10 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 10  "
	}
	if slice_labelResult11 {
		call slice_labelList.Arrpush "Slice 11 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 11  "
	}
	if slice_labelResult12 {
		call slice_labelList.Arrpush "Slice 12 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 12  "
	}
	if slice_labelResult13 {
		call slice_labelList.Arrpush "Slice 13 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 13  "
	}
	if slice_labelResult14 {
		call slice_labelList.Arrpush "Slice 14 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 14  "
	}
	if slice_labelResult15 {
		call slice_labelList.Arrpush "Slice 15 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 15  "
	}
	if slice_labelResult16 {
		call slice_labelList.Arrpush "Slice 16 *"
	}
	else {
		call slice_labelList.Arrpush "Slice 16  "
	}
	call slice.lb_indLabel.repopulate
END

PROGRAM slice_edit_labels_output
BEGIN
	if slice_labelResult1 {
		put "plabel(1 " slice_labelResult1 ") "
	}
	if slice_labelResult2 {
		put "plabel(2 " slice_labelResult2 ") "
	}
	if slice_labelResult3 {
		put "plabel(3 " slice_labelResult3 ") "
	}
	if slice_labelResult4 {
		put "plabel(4 " slice_labelResult4 ") "
	}
	if slice_labelResult5 {
		put "plabel(5 " slice_labelResult5 ") "
	}
	if slice_labelResult6 {
		put "plabel(6 " slice_labelResult6 ") "
	}
	if slice_labelResult7 {
		put "plabel(7 " slice_labelResult7 ") "
	}
	if slice_labelResult8 {
		put "plabel(8 " slice_labelResult8 ") "
	}
	if slice_labelResult9 {
		put "plabel(9 " slice_labelResult9 ") "
	}
	if slice_labelResult10 {
		put "plabel(10 " slice_labelResult10 ") "
	}
	if slice_labelResult11 {
		put "plabel(11 " slice_labelResult11 ") "
	}
	if slice_labelResult12 {
		put "plabel(12 " slice_labelResult12 ") "
	}
	if slice_labelResult13 {
		put "plabel(13 " slice_labelResult13 ") "
	}
	if slice_labelResult14 {
		put "plabel(14 " slice_labelResult14 ") "
	}
	if slice_labelResult15 {
		put "plabel(15 " slice_labelResult15 ") "
	}
	if slice_labelResult16 {
		put "plabel(16 " slice_labelResult16 ") "
	}
END


PROGRAM slice_line_output
BEGIN
	if slice.cl_lcol.isvisible() {
		optionarg /quoted slice.cl_lcol
	}
	else {
		optionarg /hidedefault slice.cb_lcol
	}
	optionarg slice.cb_lwid
END

PROGRAM slice_output
BEGIN
	if ! H(slice.bu_allslice) & sliceAllSliceResult {
		put " pie(_all, "
		put sliceAllSliceResult
		put ") "
	}
	put " " /program slice_edit_slices_output
	
	if ! H(slice.bu_allLabel) & sliceAllLabelResult {
		put " plabel(_all "
		put sliceAllLabelResult
		put ") "
	}
	put " " /program slice_edit_labels_output

	if slice.cb_lcol | slice.cl_lcol.isvisible() | slice.cb_lwid {
		put "line("
		put /program slice_line_output
		put ") "
	}
	optionarg slice.cb_int
END

INCLUDE gr_titles
INCLUDE gr_legend
INCLUDE gr_overall
INCLUDE gr_by

PROGRAM command
BEGIN
	put "graph pie "
	require main.vl_var
	put " " main.vl_var
	put main.vn_var
	put " " /program weights_output
	put " " /program ifin_output
	beginoptions
		if main.rb_over {
			require main.vn_over
			optionarg main.vn_over
		}
		put " " /program options_output
		put " " /program slice_output
		put " " /program gr_titles_output
		put " " /program gr_legend_output
		put " " /program gr_overall_output
		put " " /program gr_by_output		
	endoptions
END
