window:
	res:
		windowType	wstandard
	endres:
endwindow:
close:
	res:
		bitmapPath	$(bitmaps)
		bitmapFile	CLOSE::CBM
	endres:
endclose:
title:
	res:
		leftLabel	O|vVKo^
		leftKanjiFont	$(kanjiFont)
		leftFont	$(kanaFont)
		switch $(COLOR)
			case MONO:
				bitmapPath	$(bitmaps)
				backgroundFile	GRAY3
				transparent	false
				break
		endswitch
	endres:
endtitle:
dialog: dialogs
	res:
		defaultDistance		#(fWidth)
		dialogType		modeless
		defaultButton		next
	endres:
	ditem: list_label
		res:
			itemType	bitmap
			label		'@O|v@@@@ hc'
			kanjiFont	$(kanjiFont)
			font		$(kanaFont)
			vertDistance	#(fWidth)
			horizDistance	#(fWidth)+4
		endres:
	endditem:
	ditem: newname
		res:
			itemType	text
			fromVert	list_label
			vertDistance	2
			horizDistance	#(fWidth)*3
			length		16
			height		#(fHeight)
			width		#(fWidth)*16+4
			kanjiFont	$(kanjiFont)
			font		$(kanaFont)
			shadowWidth	0
			borderWidth	2
			focus
		endres:
		act:
			put $(NEW_NAME)
			put $(NEW_NAME)@1 $(NEW_NAME1)
			put $(NEW_NAME)@0 $(NEW_NAME)
		endact:
	endditem:
	ditem: newid
		res:
			itemType	numtext
			fromVert	list_label
			fromHoriz	newname
			vertDistance	2
			horizDistance	#(fWidth)*2
			length		5
			height		#(fHeight)
			width		#(fWidth)*5+4
			kanjiFont	$(kanjiFont)
			font		$(kanaFont)
			shadowWidth	0
			borderWidth	2
			focus
		endres:
		act:
			put $(NEW_ID)
		endact:
	endditem:
	ditem: list
		res:
			itemType	scrtext
			fromVert	newname
			vertDistance	4
			horizDistance	#(fWidth)
			width		#(fWidth)+1*28
			height		#(lHeight)*7+8
			kanjiFont	$(kanjiFont)
			font		$(kanaFont)
			bind1		select
			file		/dev/null
		endres:
		act:
			put $(line)
			put $(line)@0 $(BUF_NAME)
			put $(line)@1 $(BUF_ID)
		endact:
	endditem:
	ditem: next
		res:
			itemType	button
			fromVert	newname
			fromHoriz	list
			label		mdws
			kanjiFont	$(kanjiFont)
			font		$(kanaFont)
			vertDistance	4
			horizDistance	#(fWidth)*2
		endres:
		act:
			switch $(NEW_NAME)
				case '':
					put 1 $(err_no)
					job err
					quit
			endswitch
			switch $(NEW_NAME1)
				case '':
					break
				default:
					put 2 $(err_no)
					job err
					quit
			endswitch
			$(bin)/Sname_check group $(NEW_NAME)
			switch #(status)
				case 0x100:
					put 2 $(err_no)
					job err
					quit
			endswitch
			$(bin)/Sgrp_check -g $(NEW_NAME)
			switch #(status)
				case 0:
					put 4 $(err_no)
					job err
					quit
			endswitch
			put '$(NEW_NAME)   $(NEW_ID)' > $(TMP_LIST)
			$(bin)/Sfile_op -e -f 0 -i $(TMP_LIST) -o $(LIST)
			switch #(status)
				case 0:
					put 6 $(err_no)
					job err
					quit
			endswitch
			test $(NEW_ID) -gt 32767
			switch #(status)
				case 0:
					put 3 $(err_no)
					job err
					quit
			endswitch
			$(bin)/Sgrp_check -i $(NEW_ID)
			switch #(status)
				case 0:
					put 5 $(err_no)
					job err
					quit
			endswitch
			$(bin)/Sfile_op -e -f 1 -i $(TMP_LIST) -o $(LIST)
			switch #(status)
				case 0:
					put 7 $(err_no)
					job err
					quit
			endswitch
			job addlist
		endact:
	endditem:
	ditem: exec
		res:
			itemType	button
			fromVert	next
			fromHoriz	list
			label		' o@^ '
			kanjiFont	$(kanjiFont)
			font		$(kanaFont)
			vertDistance	#(fWidth)
			horizDistance	#(fWidth)*2
		endres:
		act:
			put on $(ONRUN)
			put 101 $(menu_no)
			$(onrun) = sub $(commonPath)/onrun ++48++48
			$(pid) = bg $(etc)/Group/Sgroup.sh add $(LIST)
			$(bgstat) = trap $(pid) exec_end
		endact:
	endditem:
	ditem: del
		res:
			itemType	button
			fromVert	exec
			fromHoriz	list
			label		' @ '
			kanjiFont	$(kanjiFont)
			font		$(kanaFont)
			vertDistance	#(fWidth)
			horizDistance	#(fWidth)*2
		endres:
		act:
			echo '$(BUF_NAME)' > $(TMP_LIST)
			$(bin)/Sfile_op -d -f 0 -i $(TMP_LIST) -o $(LIST)
			setval list file $(LIST)
			setval del sensitive false
			job chklist
		endact:
	endditem:
enddialog:
proc: pre
	global $(NEW_NAME)
	$(TMP) = mktemp
	put /tmp/$(TMP) $(LIST)
	$(TMP) = mktemp
	put /tmp/$(TMP) $(TMP_LIST)
	$(TMP) = mktemp
	put /tmp/$(TMP) $(ERR_LIST)
	echo -n > $(LIST)
	put 0 $(menu_no)
	put on $(mapped)
	put off $(opened)
	$(bin)/Sgrp_check -M
	put #(stdout)+1 $(maxgid)
	test $(maxgid) -gt 32767
	switch #(status)
		case 0:
			put 32767 $(maxgid)
			break
	endswitch
endproc:
proc: close
	switch $(ONRUN)
		case on:
			quit
	endswitch
	job off
	close
endproc:
proc: off
	switch #(menu_no)
		case 10:
			close $(err)
			break
	endswitch
	local $(NEW_NAME)
	rm -f $(LIST) $(TMP_LIST) $(ERR_LIST)
endproc:
proc: open
	setval newid string $(maxgid)
	job init
endproc:
proc: init
	setval newname string ''
	setval list file $(LIST)
	setval del sensitive false
	job chklist
endproc:
proc: chklist
	test -s $(LIST)
	switch #(status)
		case 0:
			setval exec sensitive true
			break
		default:
			setval exec sensitive false
	endswitch
endproc:
proc: select
	switch $(line)
		case '':
			quit
	endswitch
	setval del sensitive true
endproc:
proc: addlist
	put '  $(NEW_NAME)\L17  $(NEW_ID)\R5' $(newline)
	put $(newline) >> $(LIST)
	job init
	put #(NEW_ID)+1 $(NEW_ID)
	test $(NEW_ID) -gt 32767
	switch #(status)
		case 0:
			put 32767 $(NEW_ID)
			break
	endswitch
	setval newid string $(NEW_ID)
	job chklist
endproc:
proc: exec_end
	buzzer $(main)
	close $(onrun)
	switch $(mapped)
		case on:
			job bgdone
			break
		case off:
			put on $(opened)
			break
	endswitch
	put 102 $(menu_no)
endproc:
proc: unmap
	switch #(menu_no)
		case 10:
			unmap $(err)
			break
		case 101:
			unmap $(onrun)
			break
		case 102:
			unmap $(n_end)
			break
	endswitch
	put off $(mapped)
endproc:
proc: map
	switch #(menu_no)
		case 10:
			raise $(err)
			map $(err)
			break
		case 101:
			move $(onrun)
			raise $(onrun)
			map $(onrun)
			break
		case 102:
			switch $(opened)
				case on:
					job bgdone
					break
				case off:
					move $(n_end)
					raise $(n_end)
					map $(n_end)
					break
			endswitch
	endswitch
	put on $(mapped)
	put off $(opened)
endproc:
proc: title
	job move
	job up
endproc:
proc: raise
	job up
endproc:
proc: move
	switch #(menu_no)
		case 10:
			move $(err)
			break
		case 101:
			move $(onrun)
			break
		case 102:
			move $(n_end)
			break
	endswitch
endproc:
proc: up
	switch #(menu_no)
		case 10:
			raise $(err)
			break
		case 101:
			raise $(onrun)
			break
		case 102:
			raise $(n_end)
			break
	endswitch
endproc:
proc: bgdone
	switch #(bgstat)
		case 0:
			$(n_end) = sub $(commonPath)/normalEnd ++48++48
			break
	endswitch
	trap $(n_end) n_end
endproc:
proc: n_end
	put off $(ONRUN)
	put on $(CHANGE_GROUP)
	put 0 $(menu_no)
	job close
endproc:
proc: err
	put 10 $(menu_no)
	switch #(err_no)
		case 1:
			put 'O|vw肵ĉB' $(confirm_msg1)
			$(err) = sub $(commonPath)/error1 ++48++48
			break
		case 2:
			put 'O|vɂ͉pi-_. ܂ށjA' $(confirm_msg1)
			put 'ѐŎw肵ĉB' $(confirm_msg2)
			$(err) = sub $(commonPath)/error2 ++48++48
			break
		case 3:
			put 'O|vhcɂ 0-32767 ̒lw肵ĉB' $(confirm_msg1)
			$(err) = sub $(commonPath)/error1 ++48++48
			break
		case 4:
			put 'O|vu$(NEW_NAME)v͊ɎgpĂ܂B' $(confirm_msg1)
			put 'ʂ̃O|vw肵ĂB' $(confirm_msg2)
			$(err) = sub $(commonPath)/error2 ++48++48
			break
		case 5:
			put 'O|vhcu$(NEW_ID)v͊ɎgpĂ܂B' $(confirm_msg1)
			put 'ʂ̃O|vhcw肵ĉB' $(confirm_msg2)
			
			$(err) = sub $(commonPath)/error2 ++48++48
			break
		case 6:
			put 'O|vu$(NEW_NAME)v͊ɗ\񂳂Ă܂B' $(confirm_msg1)
			put 'ʂ̃O|vw肵ĂB' $(confirm_msg2)
			$(err) = sub $(commonPath)/error2 ++48++48
			break
		case 7:
			put 'O|vhcu$(NEW_ID)v͊ɗ\񂳂Ă܂B' $(confirm_msg1)
			put 'ʂ̃O|vhcw肵ĉB' $(confirm_msg2)
			
			$(err) = sub $(commonPath)/error2 ++48++48
	endswitch
	buzzer
	trap $(err) err_end
endproc:
proc: err_end
	put 0 $(menu_no)
endproc:
