#!/usr/local/bin/wish -f
# Copyright (C) 1997 Tomohiro Tanaka

# Хѿν
set tmpdir "/tmp"
append tmpdir "/"
set helpdir "MGTPWMDIR/help/"
set srcdir "MGTPWMDIR/src/"
set entdata ""
set entdata1 ""
set cntfile ""
set fileid [pid]
set procid ""
set killornot 0
# ץ
set ans1 0; set ans2 0; set ans3 0; set ans4 1; set ans5 0; set ans11 0;
set ans111 "";
set tekilmode 1
set dwmode 1
set nhmornot 1
set conpint 2
set timersamp 1
set timelimit 1
set entdir "~/"
set selectconp 1

##### ԣ ѡ #####

# ᥤΥ٥
label .main -text "MGTP Window Manager" \
	-font -*-*-bold-i-*--*-2??-*-*
label .main1 -text ""
pack .main .main1

# ʬ
frame .enter
label .enter.inputlabel -text "ե̾" \
	-kanjifont -*-fixed-medium-r-*--*-110-*-*-*-*-*-*
entry .enter.inputentry -width 40 -relief sunken -textvariable entdata
button .enter.button -text "եõ" -command exec_filem
pack .enter.inputlabel .enter.inputentry .enter.button \
	-in .enter -side left
pack .enter

# ޥ͡㡼ξɽ
message .msg0 -width 20c -justify left -text ""
pack .msg0
frame .msg
label .msg.label -text "console" \
	-kanjifont -*-fixed-medium-r-*--*-110-*-*-*-*-*-*
message .msg.mess -width 20c -justify left -text "ǽ" -bd 2 -relief ridge
pack .msg.label .msg.mess -side left
pack .msg
message .msg1 -width 20c -justify left -text ""
pack .msg1

# ץ
label .optl -text "ץ" \
	-kanjifont -*-fixed-medium-r-*--*-110-*-*-*-*-*-*
label .optl1 -text ""
label .optl2 -text "Non-Horn Magic Sets Υץ" \
	-kanjifont -*-fixed-medium-r-*--*-110-*-*-*-*-*-*
frame .opt
frame .opt1 -bd 4 -relief groove
frame .opt.opt1 -bd 2 -relief ridge 
frame .opt1.opt2 -bd 2 -relief ridge 
frame .opt1.opt3 -bd 2 -relief ridge 
frame .opt1.opt4 -bd 2 -relief ridge 
frame .opt.opt5 -bd 2 -relief ridge 
frame .opt.opt6 -bd 2 -relief ridge 
frame .opt.opt7 -bd 2 -relief ridge 
frame .opt.opt8 -bd 2 -relief ridge 
frame .opt.opt8.ent
button .opt.opt1.hlp -text "󥿥ץ꥿" -command {exec_hlp "mode"}
button .opt1.opt2.hlp -text "⡼" -command {exec_hlp "loose"}
button .opt1.opt3.hlp -text "Ѵˡ" -command {exec_hlp "haba-fukasa"}
button .opt1.opt4.hlp -text "NHMλ" -command {exec_hlp "nhm"}
button .opt.opt5.hlp -text "󥸥" -command {exec_hlp "int"}
button .opt.opt6.hlp -text "" -command {exec_hlp "timer-samp"}
button .opt.opt7.hlp -text "»" -command {exec_hlp "time-out"}
button .opt.opt8.hlp -text "ѥ" -command {exec_hlp "conp"}
label  .opt.opt8.ent.lab -text "dir"
entry  .opt.opt8.ent.ent -width 8 -relief sunken -textvariable entdir
radiobutton .opt.opt8.nani1 -text "MGTP  "   -value 1 -variable selectconp \
	-command exec_button_conp_NHMoff
radiobutton .opt.opt8.nani2 -text "CMGTP "   -value 2 -variable selectconp \
	-command exec_button_conp_NHMoff
radiobutton .opt.opt8.nani3 -text "D.L.G."   -value 3 -variable selectconp \
	-command exec_button_conp_NHMoff
radiobutton .opt.opt8.nani4 -text "F.U.  "   -value 4 -variable selectconp \
	-command exec_button_conp_NHMoff
radiobutton .opt.opt8.nani5 -text "FU+NHM"   -value 5 -variable selectconp \
	-command exec_button_conp_NHMoff
checkbutton .opt.opt1.nani1 -text "õ򤹤"   -onvalue 1 -offvalue 0 \
	-variable ans1
checkbutton .opt.opt1.nani11 -text "T.M.Ѥ"   -onvalue 1 -offvalue 0 \
	-variable ans11
checkbutton .opt.opt1.nani2 -text ""   -onvalue 1 -offvalue 0 \
	-variable ans2
checkbutton .opt.opt1.nani3 -text "ǥ  "   -onvalue 1 -offvalue 0 \
	-variable ans3
checkbutton .opt.opt1.nani4 -text "׾"   -onvalue 1 -offvalue 0 \
	-variable ans4
checkbutton .opt.opt1.nani5 -text "ʹԾ򸫤"   -onvalue 1 -offvalue 0 \
	-variable ans5 -command exec_button_int_sinkou -relief ridge
radiobutton .opt1.opt2.nani1 -text "ɸ  "   -value 1 -variable tekilmode
radiobutton .opt1.opt2.nani2 -text "«"   -value 2 -variable tekilmode
radiobutton .opt1.opt3.nani1 -text " ͥ "   -value 1 -variable dwmode \
	-command {.opt1.opt2.nani1 configure -state normal; \
		  .opt1.opt2.nani2 configure -state normal }
radiobutton .opt1.opt3.nani2 -text "  ͥ  "   -value 2 -variable dwmode \
	-command {.opt1.opt2.nani1 configure -state normal; \
	          .opt1.opt2.nani2 configure -state normal }
radiobutton .opt1.opt3.nani3 -text "Ĺ"   -value 3 -variable dwmode \
	-command ".opt1.opt2.nani1 configure -state disabled; \
	          .opt1.opt2.nani2 configure -state disabled "
radiobutton .opt1.opt4.nani1 -text "Ȥʤ"   -value 1 -variable nhmornot \
	-command ".opt1.opt2.nani1 configure -state disabled; \
	          .opt1.opt2.nani2 configure -state disabled; \
	          .opt1.opt3.nani1 configure -state disabled; \
	          .opt1.opt3.nani3 configure -state disabled; \
	          .opt1.opt3.nani2 configure -state disabled "
radiobutton .opt1.opt4.nani2 -text "    "   -value 2 -variable nhmornot \
	-command {.opt1.opt2.nani1 configure -state normal; \
	          .opt1.opt2.nani2 configure -state normal; \
	          .opt1.opt3.nani1 configure -state normal; \
	          .opt1.opt3.nani3 configure -state normal; \
	          .opt1.opt3.nani2 configure -state normal }
radiobutton .opt.opt5.nani1 -text " ѥ " -value 1 \
	-variable conpint -command exec_button_conp
radiobutton .opt.opt5.nani2 -text "󥿥ץ꥿" -value 2 \
	-variable conpint -command exec_button_intp
radiobutton .opt.opt6.nani1 -text "  " -value 1 -variable timersamp 
radiobutton .opt.opt6.nani2 -text "  " -value 2 -variable timersamp 
radiobutton .opt.opt6.nani3 -text "  " -value 3 -variable timersamp 
radiobutton .opt.opt6.nani4 -text "  " -value 5 -variable timersamp 
radiobutton .opt.opt6.nani5 -text "" -value 10 -variable timersamp 
radiobutton .opt.opt7.nani1 -text " ʬ " -value 60 -variable timelimit
radiobutton .opt.opt7.nani2 -text " ʬ " -value 300 -variable timelimit
radiobutton .opt.opt7.nani3 -text "ʬ" -value 600 -variable timelimit
radiobutton .opt.opt7.nani4 -text "ʬ" -value 3600 -variable timelimit
radiobutton .opt.opt7.nani5 -text "  " -value 1 -variable timelimit
frame .opt.opt1.ent
label  .opt.opt1.ent.lab -text "¾"
entry  .opt.opt1.ent.ent -width 10 -relief sunken -textvariable ans111
pack .opt.opt1.ent.lab .opt.opt1.ent.ent -side left 
pack .opt.opt1.hlp .opt.opt1.nani1 .opt.opt1.nani11 .opt.opt1.nani2 \
	.opt.opt1.nani3	.opt.opt1.nani4 .opt.opt1.nani5 .opt.opt1.ent \
        -side top -fill x
pack .opt1.opt2.hlp .opt1.opt2.nani1 .opt1.opt2.nani2 \
	-side top -fill x
pack .opt1.opt3.hlp .opt1.opt3.nani1 .opt1.opt3.nani2 .opt1.opt3.nani3 \
        -side top -fill x
pack .opt1.opt4.hlp .opt1.opt4.nani1 .opt1.opt4.nani2 -side top -fill x
pack .opt.opt5.hlp .opt.opt5.nani1 .opt.opt5.nani2 -side top -fill x
pack .opt.opt6.hlp .opt.opt6.nani1 .opt.opt6.nani2 .opt.opt6.nani3 \
	.opt.opt6.nani4 .opt.opt6.nani5 -side top -fill x
pack .opt.opt7.hlp .opt.opt7.nani1 .opt.opt7.nani2 .opt.opt7.nani3 \
	.opt.opt7.nani4 .opt.opt7.nani5 -side top -fill x
pack .opt.opt8.ent.lab .opt.opt8.ent.ent -side left
pack .opt.opt8.hlp .opt.opt8.ent .opt.opt8.nani1 .opt.opt8.nani2 \
	.opt.opt8.nani3 .opt.opt8.nani4 .opt.opt8.nani5 -side top -fill x
pack .opt.opt6 .opt.opt7 .opt.opt5 .opt.opt1 .opt.opt8 -side left -fill y 
pack .opt1.opt4 .opt1.opt3 .opt1.opt2 -side left -fill y 
pack .optl .opt .optl1 .optl2 .opt1 -side top

# ¹ԤǤȥ󥻥ܥ
label .bb1 -text ""
pack .bb1
frame .bb
button .bb.button1 -text "¹" \
	-command {exec_mgtp $conpint $nhmornot $dwmode $tekilmode}
button .bb.button2 -text "" -command {set killornot 1}
button .bb.button3 -text "λ" -command exit
pack .bb.button1 .bb.button2 .bb.button3 -side left
pack .bb
.bb.button2 configure -state disabled


##### ԣ ѡ #####

.opt1.opt2.nani1 configure -state disabled
.opt1.opt2.nani2 configure -state disabled
.opt1.opt3.nani1 configure -state disabled
.opt1.opt3.nani2 configure -state disabled 
.opt1.opt3.nani3 configure -state disabled 
.opt.opt8.nani1 configure -state disabled
.opt.opt8.nani2 configure -state disabled
.opt.opt8.nani3 configure -state disabled
.opt.opt8.nani4 configure -state disabled
.opt.opt8.nani5 configure -state disabled
.opt.opt8.ent.ent configure -state disabled
#.opt.opt8.ent.lab configure -fg darkgray

# ץβʬ(ѥ)
proc exec_mgtp {int nhm dw tekil} {
    global entdata; global killornot; global selectconp; global procid;
    global entdir; global entdata1;
    if {$entdata == ""} {.msg.mess configure -text "ե̾ϤƲ"
    } else {
	if {$int == 1} {
	    catch {exec rm syuuryoushimashita}
	    set killornot 0
	    if {[file writable $entdir] == 1} {
		if {[file isdirectory $entdir] == 0} {
		    .msg.mess configure -text "ѥǥ쥯ȥλ꤬ǥ쥯ȥǤϤޤ"
		} else {
		    cd $entdir
		    set zikkou "zikkoukeisikida"
		    catch {exec rm $zikkou}
		    exec cp $entdata .
		    set frontname [file rootname $entdata1]
		    set kl1f $frontname
		    append kl1f "dom"
		    set domf $kl1f
		    append domf ".mg"
		    append kl1f "_merc.kl1"
		    .msg.mess configure -text "ѥ"
		    update
		    exec_mgtp_conp_MGTP $selectconp $domf $kl1f $zikkou
		    .bb.button2 configure -state normal
		    .bb.button1 configure -state disabled
		    update
		    exec_proc_look $zikkou
		    if {$killornot == 0} {
			.msg.mess configure -text ""
			update
			exec sleep 3
			set procid [exec ./$zikkou | mgtp-disp-stdin &]
			.bb.button2 configure -state normal
			.bb.button1 configure -state disabled
			update
			exec_proc_look "syuuryoushimashita"
			catch {exec rm syuuryoushimashita}
		    }
		    catch {exec rm zikkoukeisikida}
		}
	    } else {
		.msg.mess configure -text "ѥǥ쥯ȥؤν񤭹ߤĤƤʤ¸ߤޤ"
	    }
	} else {
	    exec_mgtpint $nhm $dw $tekil
	}
    }
}

# ץβʬ(󥿡ץ꥿)
proc exec_mgtpint {nhm dw tekil} {
        global entdata; global killornot
	global ans1; global ans2; global ans3; global ans4; global ans5;
        global ans11; global ans111;
	set s1 ""; set s2 ""; set s3 ""; set s4 ""; set s5 $ans5; set s11 ""; 
        set s111 $ans111
        if {$ans1 == 1} {set s1 "a"}
        if {$ans11 == 1} {set s11 "tmu"}
        if {$ans2 == 1} {set s2 "t"}
        if {$ans3 == 1} {set s3 "m"}
        if {$ans4 == 1} {set s4 "s"}
	catch {exec rm syuuryoushimashita}
	set killornot 0
        .msg.mess configure -text "׻"
	update
	if {$nhm == 1} {exec_mgtp_int $s1 $s2 $s3 $s4 $s5 $s11 $s111}
	if {$nhm == 2} {
	    if {$dw == 1} {
		if {$tekil == 1} {exec_mgtp_int_nhm_d $s1 $s2 $s3 $s4 $s5 $s11 $s111}
		if {$tekil == 2} {
		    exec_mgtp_int_nhm_d_loose $s1 $s2 $s3 $s4 $s5 $s11 $s111}
	    }
	    if {$dw == 2} {
		if {$tekil == 1} {exec_mgtp_int_nhm_w $s1 $s2 $s3 $s4 $s5 $s11 $s111}
		if {$tekil == 2} {
		    exec_mgtp_int_nhm_w_loose $s1 $s2 $s3 $s4 $s5 $s11 $s111}
	    }
	    if {$dw == 3} {
		exec_mgtp_int_nhm_del $s1 $s2 $s3 $s4 $s5 $s11 $s111
	    }
	}
        .bb.button2 configure -state normal
        .bb.button1 configure -state disabled
	update
	exec_proc_look "syuuryoushimashita"
	catch {exec rm syuuryoushimashita}
}

# ͣǣԣФλƻ뤹
proc exec_proc_look {chechfile} {
        global killornot; global timersamp; global timelimit
        if {$timelimit == 1} {set limit 4000
	} else {set limit [expr $timelimit/$timersamp]}
        for {set i 0} {$i < $limit} {incr i} {
	    if {[file exists $chechfile] == 0} {
		exec sleep $timersamp
		update
		if {$killornot == 1} {break}
		if {$i == 3900} {set i 0}
	    } else {break}
	}
	exec_kill
        if {$i == $limit} {
	    .msg.mess configure -text "Time Out ˤǤޤ"
	} else {.msg.mess configure -text "ǽ"}
        .bb.button2 configure -state disabled
        .bb.button1 configure -state normal
	update
}

# ץǤ
proc exec_kill {} {
        global procid;
        set i 0
	while {[lindex $procid $i] != ""} {
	    catch {exec kill [lindex $procid $i]}
	    set i [expr $i+1]
	}
}

# ѥ
proc exec_mgtp_conp_MGTP {nani domfile kl1file outputfile} {
    global entdata1; global procid; global srcdir; 
    set src $srcdir
    if {$nani == 1} {
	append src "mgtp.kl1"
    } elseif {$nani == 2} {
	append src "cmgtp.kl1"
    } elseif {$nani == 3} {
	append src "lmgtp.kl1"
    } elseif {$nani == 4} {
	append src "fu.kl1"
    } elseif {$nani == 5} {
	append src "fu-with-nhm.kl1"
    }
    exec cp $src .
    exec dom < $entdata1 > $domfile
    exec mg2klic $domfile
    if {$nani == 1} {
	set procid [exec klic -o $outputfile mgtp.kl1 $kl1file &]
    } elseif {$nani == 2} {
	set procid [exec klic -o $outputfile cmgtp.kl1 $kl1file &]
    } elseif {$nani == 3} {
	set procid [exec klic -o $outputfile lmgtp.kl1 $kl1file &]
    } elseif {$nani == 4} {
	set procid [exec klic -o $outputfile fu.kl1 $kl1file &]
    } elseif {$nani == 5} {
	set procid [exec klic -o $outputfile fu-with-nhm.kl1 $kl1file &]
    }
}

# 󥿡ץ꥿
proc exec_mgtp_int {s1 s2 s3 s4 s5 s11 s111} {
        global entdata; global procid;
        if {$s5 == 0} {
	    set procid [exec dom < $entdata | mercpat \
		    | intMercNW $s1 $s2 $s3 $s4 $s11 $s111 | mgtp-disp-stdin &]
	} else {
	    set procid [exec dom < $entdata | mercpat \
		    | intMercNW $s1 b n $s11 $s111 | mgtp-disp-br &]}
}

# 󥿡ץ꥿Ĺά
proc exec_mgtp_int_nhm_del {s1 s2 s3 s4 s5 s11 s111} {
        global entdata; global procid;
        if {$s5 == 0} {
	  set procid [exec nhmmode b < $entdata | mercpat | intMercNW tmu m n \
		    | cat - $entdata | nhmdel | dom | mercpat \
		    | intMercNW $s1 $s2 $s3 $s4 $s11 $s111 | mgtp-disp-stdin &]
	} else {
	  set procid [exec nhmmode b < $entdata | mercpat | intMercNW tmu m n \
		    | cat - $entdata | nhmdel | dom | mercpat \
		    | intMercNW $s1 b n $s11 $s111 | mgtp-disp-br &]}
}

# 󥿡ץ꥿Σȣͥ͡
proc exec_mgtp_int_nhm_w {s1 s2 s3 s4 s5 s11 s111} {
        global entdata; global procid;
        if {$s5 == 0} {
	  set procid [exec nhmmode b < $entdata | mercpat | intMercNW tmu m n \
		    | cat - $entdata | nhmtrans b p | dom | mercpat \
		    | intMercNW $s1 $s2 $s3 $s4 $s11 $s111 | mgtp-disp-stdin &]
	} else {
	  set procid [exec nhmmode b < $entdata | mercpat | intMercNW tmu m n \
		    | cat - $entdata | nhmtrans b p | dom | mercpat \
		    | intMercNW $s1 b n $s11 $s111 | mgtp-disp-br &]}
}
proc exec_mgtp_int_nhm_w_loose {s1 s2 s3 s4 s5 s11 s111} {
        global entdata; global procid;
        if {$s5 == 0} {
	  set procid [exec nhmmode b < $entdata | mercpat | intMercNW tmu m n \
	   | nhmfilter | cat - $entdata | nhmtrans b p m | nhmteisei | dom \
	  | mercpat | intMercNW $s1 $s2 $s3 $s4 $s11 $s111 | mgtp-disp-stdin &]
	} else {
	  set procid [exec nhmmode b < $entdata | mercpat | intMercNW tmu m n \
	   | nhmfilter | cat - $entdata | nhmtrans b p m | nhmteisei | dom \
	   | mercpat | intMercNW $s1 b n $s11 $s111 | mgtp-disp-br &]}
}

# 󥿡ץ꥿Σȣͥ͡
proc exec_mgtp_int_nhm_d {s1 s2 s3 s4 s5 s11 s111} {
        global entdata; global procid;
        if {$s5 == 0} {
	  set procid [exec nhmmode d < $entdata | mercpat | intMercNW tmu m n \
		    | cat - $entdata | nhmtrans d p | dom | mercpat \
		    | intMercNW $s1 $s2 $s3 $s4 $s11 $s111 | mgtp-disp-stdin &]
	} else {
	  set procid [exec nhmmode d < $entdata | mercpat | intMercNW tmu m n \
		    | cat - $entdata | nhmtrans d p | dom | mercpat \
		    | intMercNW $s1 b n $s11 $s111 | mgtp-disp-br &]}
}
proc exec_mgtp_int_nhm_d_loose {s1 s2 s3 s4 s5 s11 s111} {
        global entdata; global procid;
        if {$s5 == 0} {
	  set procid [exec nhmmode d < $entdata | mercpat | intMercNW tmu m n \
	      | nhmfilter | cat - $entdata | nhmtrans d p m | nhmteisei | dom \
          | mercpat | intMercNW $s1 $s2 $s3 $s4 $s11 $s111 | mgtp-disp-stdin &]
	} else {
	  set procid [exec nhmmode d < $entdata | mercpat | intMercNW tmu m n \
	      | nhmfilter | cat - $entdata | nhmtrans d p m | nhmteisei | dom \
	        | mercpat | intMercNW $s1 b n $s11 $s111 | mgtp-disp-br &]}
}

# եޥ͡εư
proc exec_filem {} {
        global entdata; global tmpdir; global fileid; global entdata1
        set namefile $tmpdir
        append namefile "fnamefile."
        append namefile $fileid
        .msg.mess configure -text "ե븡"
	update
        exec mgtp-filem $namefile
        set f [open $namefile r]
        gets $f entdata
        gets $f entdata1
        close $f
        .msg.mess configure -text "ϲǽ"
	update
        exec rm $namefile
}

# إפ򳫤
proc exec_hlp {file} {
        global cntfile; global helpdir
        set cntfile $helpdir
        append cntfile $file
        .msg.mess configure -text "إץեɽ"
	update
        exec_display
}

# ǥץ쥤ɽεư
proc exec_display {} {
        global cntfile
	exec mgtp-disp-file $cntfile
        .msg.mess configure -text "ǽ"
}

# ץΥܥѹ
# ʹԾ򸫤
proc exec_button_int_sinkou {} {
        global ans5;
        if {$ans5 == 1} {
	    .opt.opt1.nani2 configure -state disabled 
	    .opt.opt1.nani3 configure -state disabled 
	    .opt.opt1.nani4 configure -state disabled 
	    .opt.opt1.nani2 deselect
	    .opt.opt1.nani3 deselect
	    .opt.opt1.nani4 deselect
        } else {
	    .opt.opt1.nani2 configure -state normal
	    .opt.opt1.nani3 configure -state normal
	    .opt.opt1.nani4 configure -state normal
	}
}

# ѥ
proc exec_button_conp {} {
    .opt.opt1.nani1 configure -state disabled
    .opt.opt1.nani11 configure -state disabled
    .opt.opt1.ent.ent configure -state disabled
#    .opt.opt1.ent.lab configure -fg darkgray
    .opt.opt1.nani2 configure -state disabled
    .opt.opt1.nani3 configure -state disabled
    .opt.opt1.nani4 configure -state disabled
    .opt.opt1.nani5 configure -state disabled
    .opt.opt8.nani1 configure -state normal
    .opt.opt8.nani2 configure -state normal
    .opt.opt8.nani3 configure -state normal
    .opt.opt8.nani4 configure -state normal
    .opt.opt8.nani5 configure -state normal
    .opt.opt8.ent.ent configure -state normal
    .opt.opt8.ent.lab configure -fg black
# ѥǤǤΣȣͤ򥵥ݡȤϤʤΤˤ (;)ĤƤ
    .opt1.opt4.nani1 configure -state disabled ;
    .opt1.opt4.nani2 configure -state disabled ;
    .opt1.opt2.nani1 configure -state disabled ;
    .opt1.opt2.nani2 configure -state disabled ;
    .opt1.opt3.nani1 configure -state disabled ;
    .opt1.opt3.nani2 configure -state disabled ;
}

# 󥿥ץ꥿
proc exec_button_intp {} {
    global nhmornot
    .opt1.opt4.nani1 configure -state normal ;
    .opt1.opt4.nani2 configure -state normal ;
    if {$nhmornot == 2} {
	.opt1.opt2.nani1 configure -state normal ;
	.opt1.opt2.nani2 configure -state normal ;
	.opt1.opt3.nani1 configure -state normal ;
	.opt1.opt3.nani2 configure -state normal }
    .opt.opt1.nani1 configure -state normal
    .opt.opt1.nani11 configure -state normal
    .opt.opt1.ent.ent configure -state normal
    .opt.opt1.ent.lab configure -fg black
    .opt.opt1.nani2 configure -state normal
    .opt.opt1.nani3 configure -state normal
    .opt.opt1.nani4 configure -state normal
    .opt.opt1.nani5 configure -state normal
    .opt.opt8.nani1 configure -state disabled
    .opt.opt8.nani2 configure -state disabled
    .opt.opt8.nani3 configure -state disabled
    .opt.opt8.nani4 configure -state disabled
    .opt.opt8.nani5 configure -state disabled
    .opt.opt8.ent.ent configure -state disabled
#    .opt.opt8.ent.lab configure -fg darkgray
}

# ѥMGTPCMGTP
proc exec_button_conp_NHMon {} {
    global nhmornot
    .opt1.opt4.nani1 configure -state normal
    .opt1.opt4.nani2 configure -state normal
    if {$nhmornot == 2} {
	.opt1.opt2.nani1 configure -state normal
	.opt1.opt2.nani2 configure -state normal
	.opt1.opt3.nani1 configure -state normal
	.opt1.opt3.nani2 configure -state normal
    }
}

# ѥDLGFU
proc exec_button_conp_NHMoff {} {
    .opt1.opt4.nani1 configure -state disabled
    .opt1.opt4.nani2 configure -state disabled
    .opt1.opt2.nani1 configure -state disabled
    .opt1.opt2.nani2 configure -state disabled
    .opt1.opt3.nani1 configure -state disabled
    .opt1.opt3.nani2 configure -state disabled
}









