/*
	notes [list]

*! VERSION 1.1.2  23jun2009

*/

VERSION 11.0

INCLUDE _std_medium
DEFINE _dlght 225
INCLUDE header

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

DEFINE fromwd 50
DEFINE fromsep +55
DEFINE towd 35
DEFINE tosep +40

DIALOG main, label("notes - List or search notes") tabtitle("Main")
BEGIN
  GROUPBOX gb_type	_lft	_top	_iwd	_ht3h,		///
	label("Mode")
  RADIO	   rb_list	_ilft	_ss	_inwd	.,		///
	first							///
	label("List notes")					///
	onclickon(script main_list_on)
  RADIO	   rb_search	@	_ss	@	.,		///
	last							///
	label("Search notes for text")				/// 
	onclickon(script main_search_on)

  TEXT tx_search	_lft	_ls	_iwd	.,		///
	label("Search text:")
DEFINE _y @y
  EDIT ed_search	@	_ss	@	.,		///
	label("Search text")

  CHECKBOX ck_dta	_lft	_y	_iwd	.,		///
	label("List notes for dataset")

  CHECKBOX ck_var 	@	_ms	@	.,		///
	clickon("gaction main.vl_var.enable")			///
	clickoff("gaction main.vl_var.disable")			///
	label("List notes for variables:  (leave empty for all variables)")

  VARLIST  vl_var	_indent2 _ss	_ibwd	.,		///
	label("Variables")

  CHECKBOX ck_ran	_lft	_ls	_iwd	_ht2h,		///
	label("Restrict to range of notes")			///
	clickon("program ran_on")				///
	clickoff("script ran_off")				///	
	groupbox

  TEXT     tx_from	_ilft	_ss	fromwd	.,		///
	right							///
	label("from:")

  SPINNER  sp_from 	fromsep	@	_spwd	.,		///		
	min(1)							///
	max(9999)						///
	default(1)

  CHECKBOX ck_to	_lft2	@	towd	.,		///	
	clickon("gaction main.sp_to.enable")			///
	clickoff("gaction main.sp_to.disable")			///
	label("to:")

  SPINNER  sp_to	tosep	@	_spwd	.,		///
	min(1)							///
	max(9999)						///
	default(1)
END

SCRIPT main_list_on
BEGIN
	main.ck_dta.show
	main.ck_var.show
	main.vl_var.show
	main.ck_ran.show
	main.tx_from.show
	main.sp_from.show
	main.ck_to.show
	main.sp_to.show
	main.tx_search.hide
	main.ed_search.hide
END

SCRIPT main_search_on
BEGIN
	main.ck_dta.hide
	main.ck_var.hide
	main.vl_var.hide
	main.ck_ran.hide
	main.tx_from.hide
	main.sp_from.hide
	main.ck_to.hide
	main.sp_to.hide
	main.tx_search.show
	main.ed_search.show
END


PROGRAM ran_on
BEGIN
	call main.sp_from.enable
	call main.ck_to.enable
	if main.ck_to {
		call main.sp_to.enable
	}
END

SCRIPT ran_off
BEGIN
	main.sp_from.disable
	main.ck_to.disable
	main.sp_to.disable
END


PROGRAM command
BEGIN
	put "notes "
	if main.rb_list {
		put "list "
		if main.ck_dta {
			put "_dta "
		}
		if main.ck_var {
			if (main.vl_var) {
				varlist [main.vl_var]
			}
			if !(main.vl_var) {
				put "* "
			}
		}
		if main.ck_ran {
			require main.sp_from
			put "in " main.sp_from
			if main.ck_to {
				require main.sp_to
				put "/" main.sp_to
			}
		}
	}
	if main.rb_search {
		put "search "
		require main.ed_search
		put main.ed_search
	}
END
