set butadd2 .button_add_output2


proc button_add_output2 {} {

   global butadd2
   if [winfo exists $butadd2] {	destroy $butadd2 }


   global env
   set env(DISPLAY) :0.1

   toplevel $butadd2 -width 10c -height 5c
   wm title $butadd2 "Button Output"




   label $butadd2.title -text "Adding Output"  -relief groove -fg blue
   pack $butadd2.title -side top  -fill x -padx 3 -pady 3


   menubutton $butadd2.gesout -text GESOUT -menu $butadd2.gesout.menu	
   menubutton $butadd2.mpl -text MPL -menu $butadd2.mpl.menu	
		
   #----------------------------------------------------#	
   # Create submenu for "GESOUT"			#
   #----------------------------------------------------#

   menu $butadd2.gesout.menu
   $butadd2.gesout.menu add cascade -label "1-8" \
   	-menu $butadd2.gesout.menu.b1
   $butadd2.gesout.menu add cascade -label "9-16" \
   	-menu $butadd2.gesout.menu.b2
   $butadd2.gesout.menu add cascade -label "17-24" \
   	-menu $butadd2.gesout.menu.b3
   $butadd2.gesout.menu add cascade -label "25-32" \
   	-menu $butadd2.gesout.menu.b4
   $butadd2.gesout.menu add cascade -label "33-40" \
   	-menu $butadd2.gesout.menu.b5
   $butadd2.gesout.menu add cascade -label "41-48" \
   	-menu $butadd2.gesout.menu.b6
   $butadd2.gesout.menu add cascade -label "49-56" \
   	-menu $butadd2.gesout.menu.b7
   $butadd2.gesout.menu add cascade -label "57-64" \
   	-menu $butadd2.gesout.menu.b8

   	
   menu $butadd2.gesout.menu.b1
   $butadd2.gesout.menu.b1 add command -label "1 [get_button_name 0 1]" \
	-command {button_list_output2 "Dig Gesout 1" }
   $butadd2.gesout.menu.b1 add command -label "2 [get_button_name 0 2]" \
	-command {button_list_output2 "Dig Gesout 2" }
   $butadd2.gesout.menu.b1 add command -label "3 [get_button_name 0 3]" \
	-command {button_list_output2 "Dig Gesout 3" }
   $butadd2.gesout.menu.b1 add command -label "4 [get_button_name 0 4]" \
	-command {button_list_output2 "Dig Gesout 4" }
   $butadd2.gesout.menu.b1 add command -label "5 [get_button_name 0 5]" \
	-command {button_list_output2 "Dig Gesout 5" }
   $butadd2.gesout.menu.b1 add command -label "6 [get_button_name 0 6]" \
	-command {button_list_output2 "Dig Gesout 6" }
   $butadd2.gesout.menu.b1 add command -label "7 [get_button_name 0 7]" \
	-command {button_list_output2 "Dig Gesout 7" }
   $butadd2.gesout.menu.b1 add command -label "8 [get_button_name 0 8]" \
	-command {button_list_output2 "Dig Gesout 8" }


   menu $butadd2.gesout.menu.b2
   $butadd2.gesout.menu.b2 add command -label "9 [get_button_name 0 9]" \
	-command {button_list_output2 "Dig Gesout 9"}
   $butadd2.gesout.menu.b2 add command -label "10 [get_button_name 0 10]" \
	-command {button_list_output2 "Dig Gesout 10"}
   $butadd2.gesout.menu.b2 add command -label "11 [get_button_name 0 11]" \
	-command {button_list_output2 "Dig Gesout 11"}
   $butadd2.gesout.menu.b2 add command -label "12 [get_button_name 0 12]" \
	-command {button_list_output2 "Dig Gesout 12"}
   $butadd2.gesout.menu.b2 add command -label "13 [get_button_name 0 13]" \
	-command {button_list_output2 "Dig Gesout 13"}
   $butadd2.gesout.menu.b2 add command -label "14 [get_button_name 0 14]" \
	-command {button_list_output2 "Dig Gesout 14"}
   $butadd2.gesout.menu.b2 add command -label "15 [get_button_name 0 15]" \
	-command {button_list_output2 "Dig Gesout 15"}
   $butadd2.gesout.menu.b2 add command -label "16 [get_button_name 0 16]" \
	-command {button_list_output2 "Dig Gesout 16"}


   menu $butadd2.gesout.menu.b3
   $butadd2.gesout.menu.b3 add command -label "17 [get_button_name 0 17]" \
	-command {button_list_output2 "Dig Gesout 17"}
   $butadd2.gesout.menu.b3 add command -label "18 [get_button_name 0 18]" \
	-command {button_list_output2 "Dig Gesout 18"}
   $butadd2.gesout.menu.b3 add command -label "19 [get_button_name 0 19]" \
	-command {button_list_output2 "Dig Gesout 19"}
   $butadd2.gesout.menu.b3 add command -label "20 [get_button_name 0 20]" \
	-command {button_list_output2 "Dig Gesout 20"}
   $butadd2.gesout.menu.b3 add command -label "21 [get_button_name 0 21]" \
	-command {button_list_output2 "Dig Gesout 21"}
   $butadd2.gesout.menu.b3 add command -label "22 [get_button_name 0 22]" \
	-command {button_list_output2 "Dig Gesout 22"}
   $butadd2.gesout.menu.b3 add command -label "23 [get_button_name 0 23]" \
	-command {button_list_output2 "Dig Gesout 23"}
   $butadd2.gesout.menu.b3 add command -label "24 [get_button_name 0 24]" \
	-command {button_list_output2 "Dig Gesout 24"}


   menu $butadd2.gesout.menu.b4
   $butadd2.gesout.menu.b4 add command -label "25 [get_button_name 0 25]" \
	-command {button_list_output2 "Dig Gesout 25"}
   $butadd2.gesout.menu.b4 add command -label "26 [get_button_name 0 26]" \
	-command {button_list_output2 "Dig Gesout 26"}
   $butadd2.gesout.menu.b4 add command -label "27 [get_button_name 0 27]" \
	-command {button_list_output2 "Dig Gesout 27"}
   $butadd2.gesout.menu.b4 add command -label "28 [get_button_name 0 28]" \
	-command {button_list_output2 "Dig Gesout 28"}
   $butadd2.gesout.menu.b4 add command -label "29 [get_button_name 0 29]" \
	-command {button_list_output2 "Dig Gesout 29"}
   $butadd2.gesout.menu.b4 add command -label "30 [get_button_name 0 30]" \
	-command {button_list_output2 "Dig Gesout 30"}
   $butadd2.gesout.menu.b4 add command -label "31 [get_button_name 0 31]" \
	-command {button_list_output2 "Dig Gesout 31"}
   $butadd2.gesout.menu.b4 add command -label "32 [get_button_name 0 32]" \
	-command {button_list_output2 "Dig Gesout 32"}

   menu $butadd2.gesout.menu.b5
   $butadd2.gesout.menu.b5 add command -label "33 [get_button_name 0 33]" \
	-command {button_list_output2 "Dig Gesout 33"}
   $butadd2.gesout.menu.b5 add command -label "34 [get_button_name 0 34]" \
	-command {button_list_output2 "Dig Gesout 34"}
   $butadd2.gesout.menu.b5 add command -label "35 [get_button_name 0 35]" \
	-command {button_list_output2 "Dig Gesout 35"}
   $butadd2.gesout.menu.b5 add command -label "36 [get_button_name 0 36]" \
	-command {button_list_output2 "Dig Gesout 36"}
   $butadd2.gesout.menu.b5 add command -label "37 [get_button_name 0 37]" \
	-command {button_list_output2 "Dig Gesout 37"}
   $butadd2.gesout.menu.b5 add command -label "38 [get_button_name 0 38]" \
	-command {button_list_output2 "Dig Gesout 38"}
   $butadd2.gesout.menu.b5 add command -label "39 [get_button_name 0 39]" \
	-command {button_list_output2 "Dig Gesout 39"}
   $butadd2.gesout.menu.b5 add command -label "40 [get_button_name 0 40]" \
	-command {button_list_output2 "Dig Gesout 40"}
	
   menu $butadd2.gesout.menu.b6
   $butadd2.gesout.menu.b6 add command -label "41 [get_button_name 0 41]" \
	-command {button_list_output2 "Dig Gesout 41"}
   $butadd2.gesout.menu.b6 add command -label "42 [get_button_name 0 42]" \
	-command {button_list_output2 "Dig Gesout 42"}
   $butadd2.gesout.menu.b6 add command -label "43 [get_button_name 0 43]" \
	-command {button_list_output2 "Dig Gesout 43"}
   $butadd2.gesout.menu.b6 add command -label "44 [get_button_name 0 44]" \
	-command {button_list_output2 "Dig Gesout 44"}
   $butadd2.gesout.menu.b6 add command -label "45 [get_button_name 0 45]" \
	-command {button_list_output2 "Dig Gesout 45"}
   $butadd2.gesout.menu.b6 add command -label "46 [get_button_name 0 46]" \
	-command {button_list_output2 "Dig Gesout 46"}
   $butadd2.gesout.menu.b6 add command -label "47 [get_button_name 0 47]" \
	-command {button_list_output2 "Dig Gesout 47"}
   $butadd2.gesout.menu.b6 add command -label "48 [get_button_name 0 48]" \
	-command {button_list_output2 "Dig Gesout 48"}

   menu $butadd2.gesout.menu.b7
   $butadd2.gesout.menu.b7 add command -label "49 [get_button_name 0 49]" \
	-command {button_list_output2 "Dig Gesout 49"}
   $butadd2.gesout.menu.b7 add command -label "50 [get_button_name 0 50]" \
	-command {button_list_output2 "Dig Gesout 50"}
   $butadd2.gesout.menu.b7 add command -label "51 [get_button_name 0 51]" \
	-command {button_list_output2 "Dig Gesout 51"}
   $butadd2.gesout.menu.b7 add command -label "52 [get_button_name 0 52]" \
	-command {button_list_output2 "Dig Gesout 52"}
   $butadd2.gesout.menu.b7 add command -label "53 [get_button_name 0 53]" \
	-command {button_list_output2 "Dig Gesout 53"}
   $butadd2.gesout.menu.b7 add command -label "54 [get_button_name 0 54]" \
	-command {button_list_output2 "Dig Gesout 54"}
   $butadd2.gesout.menu.b7 add command -label "55 [get_button_name 0 55]" \
	-command {button_list_output2 "Dig Gesout 55"}
   $butadd2.gesout.menu.b7 add command -label "56 [get_button_name 0 56]" \
	-command {button_list_output2 "Dig Gesout 56"}
	
   menu $butadd2.gesout.menu.b8
   $butadd2.gesout.menu.b8 add command -label "57 [get_button_name 0 57]" \
	-command {button_list_output2 "Dig Gesout 57"}
   $butadd2.gesout.menu.b8 add command -label "58 [get_button_name 0 58]" \
	-command {button_list_output2 "Dig Gesout 58"}
   $butadd2.gesout.menu.b8 add command -label "59 [get_button_name 0 59]" \
	-command {button_list_output2 "Dig Gesout 59"}
   $butadd2.gesout.menu.b8 add command -label "60 [get_button_name 0 60]" \
	-command {button_list_output2 "Dig Gesout 60"}
   $butadd2.gesout.menu.b8 add command -label "61 [get_button_name 0 61]" \
	-command {button_list_output2 "Dig Gesout 61"}
   $butadd2.gesout.menu.b8 add command -label "62 [get_button_name 0 62]" \
	-command {button_list_output2 "Dig Gesout 62"}
   $butadd2.gesout.menu.b8 add command -label "63 [get_button_name 0 63]" \
	-command {button_list_output2 "Dig Gesout 63"}
   $butadd2.gesout.menu.b8 add command -label "64 [get_button_name 0 64]" \
	-command {button_list_output2 "Dig Gesout 64"}

  	
	
  	
   #----------------------------------------------------#
   # Create submenu for "MPL"                  		#
   #----------------------------------------------------#
   	
   menu $butadd2.mpl.menu
   $butadd2.mpl.menu add cascade -label "1-8" \
   	-menu $butadd2.mpl.menu.b1
   $butadd2.mpl.menu add cascade -label "9-16" \
   	-menu $butadd2.mpl.menu.b2
   $butadd2.mpl.menu add cascade -label "17-24" \
   	-menu $butadd2.mpl.menu.b3
   $butadd2.mpl.menu add cascade -label "25-32" \
   	-menu $butadd2.mpl.menu.b4
   $butadd2.mpl.menu add cascade -label "33-40" \
   	-menu $butadd2.mpl.menu.b5
   $butadd2.mpl.menu add cascade -label "41-48" \
   	-menu $butadd2.mpl.menu.b6
   	

   	

   menu $butadd2.mpl.menu.b1
   $butadd2.mpl.menu.b1 add command -label "1 [get_button_name 1 1]" \
	-command {button_list_output2 "Dig MPL 1"}
   $butadd2.mpl.menu.b1 add command -label "2 [get_button_name 1 2]" \
	-command {button_list_output2 "Dig MPL 2"}
   $butadd2.mpl.menu.b1 add command -label "3 [get_button_name 1 3]" \
	-command {button_list_output2 "Dig MPL 3"}
   $butadd2.mpl.menu.b1 add command -label "4 [get_button_name 1 4]" \
	-command {button_list_output2 "Dig MPL 4"}
   $butadd2.mpl.menu.b1 add command -label "5 [get_button_name 1 5]" \
	-command {button_list_output2 "Dig MPL 5"}
   $butadd2.mpl.menu.b1 add command -label "6 [get_button_name 1 6]" \
	-command {button_list_output2 "Dig MPL 6"}
   $butadd2.mpl.menu.b1 add command -label "7 [get_button_name 1 7]" \
	-command {button_list_output2 "Dig MPL 7"}
   $butadd2.mpl.menu.b1 add command -label "8 [get_button_name 1 8]" \
	-command {button_list_output2 "Dig MPL 8"}


   menu $butadd2.mpl.menu.b2	
   $butadd2.mpl.menu.b2 add command -label "9 [get_button_name 1 9]" \
	-command {button_list_output2 "Dig MPL 9"}
   $butadd2.mpl.menu.b2 add command -label "10 [get_button_name 1 10]" \
	-command {button_list_output2 "Dig MPL 10"}
   $butadd2.mpl.menu.b2 add command -label "11 [get_button_name 1 11]" \
	-command {button_list_output2 "Dig MPL 11"}
   $butadd2.mpl.menu.b2 add command -label "12 [get_button_name 1 12]" \
	-command {button_list_output2 "Dig MPL 12"}
   $butadd2.mpl.menu.b2 add command -label "13 [get_button_name 1 13]" \
	-command {button_list_output2 "Dig MPL 13"}
   $butadd2.mpl.menu.b2 add command -label "14 [get_button_name 1 14]" \
	-command {button_list_output2 "Dig MPL 14"}
   $butadd2.mpl.menu.b2 add command -label "15 [get_button_name 1 15]" \
	-command {button_list_output2 "Dig MPL 15"}
   $butadd2.mpl.menu.b2 add command -label "16 [get_button_name 1 16]" \
	-command {button_list_output2 "Dig MPL 16"}

   menu $butadd2.mpl.menu.b3	
   $butadd2.mpl.menu.b3 add command -label "17 [get_button_name 1 17]" \
	-command {button_list_output2 "Dig MPL 17"}
   $butadd2.mpl.menu.b3 add command -label "18 [get_button_name 1 18]" \
	-command {button_list_output2 "Dig MPL 18"}
   $butadd2.mpl.menu.b3 add command -label "19 [get_button_name 1 19]" \
	-command {button_list_output2 "Dig MPL 19"}
   $butadd2.mpl.menu.b3 add command -label "20 [get_button_name 1 20]" \
	-command {button_list_output2 "Dig MPL 20"}
   $butadd2.mpl.menu.b3 add command -label "21 [get_button_name 1 21]" \
	-command {button_list_output2 "Dig MPL 21"}
   $butadd2.mpl.menu.b3 add command -label "22 [get_button_name 1 22]" \
	-command {button_list_output2 "Dig MPL 22"}
   $butadd2.mpl.menu.b3 add command -label "23 [get_button_name 1 23]" \
	-command {button_list_output2 "Dig MPL 23"}
   $butadd2.mpl.menu.b3 add command -label "24 [get_button_name 1 24]" \
	-command {button_list_output2 "Dig MPL 24"}

   menu $butadd2.mpl.menu.b4	
   $butadd2.mpl.menu.b4 add command -label "25 [get_button_name 1 25]" \
	-command {button_list_output2 "Dig MPL 25"}
   $butadd2.mpl.menu.b4 add command -label "26 [get_button_name 1 26]" \
	-command {button_list_output2 "Dig MPL 26"}
   $butadd2.mpl.menu.b4 add command -label "27 [get_button_name 1 27]" \
	-command {button_list_output2 "Dig MPL 27"}
   $butadd2.mpl.menu.b4 add command -label "28 [get_button_name 1 28]" \
	-command {button_list_output2 "Dig MPL 28"}
   $butadd2.mpl.menu.b4 add command -label "29 [get_button_name 1 29]" \
	-command {button_list_output2 "Dig MPL 29"}
   $butadd2.mpl.menu.b4 add command -label "30 [get_button_name 1 30]" \
	-command {button_list_output2 "Dig MPL 30"}
   $butadd2.mpl.menu.b4 add command -label "31 [get_button_name 1 31]" \
	-command {button_list_output2 "Dig MPL 31"}
   $butadd2.mpl.menu.b4 add command -label "32 [get_button_name 1 32]" \
	-command {button_list_output2 "Dig MPL 32"}
	
   menu $butadd2.mpl.menu.b5	
   $butadd2.mpl.menu.b5 add command -label "33 [get_button_name 1 33]" \
	-command {button_list_output2 "Dig MPL 33"}
   $butadd2.mpl.menu.b5 add command -label "34 [get_button_name 1 34]" \
	-command {button_list_output2 "Dig MPL 34"}
   $butadd2.mpl.menu.b5 add command -label "35 [get_button_name 1 35]" \
	-command {button_list_output2 "Dig MPL 35"}
   $butadd2.mpl.menu.b5 add command -label "36 [get_button_name 1 36]" \
	-command {button_list_output2 "Dig MPL 36"}
   $butadd2.mpl.menu.b5 add command -label "37 [get_button_name 1 37]" \
	-command {button_list_output2 "Dig MPL 37"}
   $butadd2.mpl.menu.b5 add command -label "38 [get_button_name 1 38]" \
	-command {button_list_output2 "Dig MPL 38"}
   $butadd2.mpl.menu.b5 add command -label "39 [get_button_name 1 39]" \
	-command {button_list_output2 "Dig MPL 39"}
   $butadd2.mpl.menu.b5 add command -label "40 [get_button_name 1 40]" \
	-command {button_list_output2 "Dig MPL 40"}
	
   menu $butadd2.mpl.menu.b6	
   $butadd2.mpl.menu.b6 add command -label "41 [get_button_name 1 41]" \
	-command {button_list_output2 "Dig MPL 41"}
   $butadd2.mpl.menu.b6 add command -label "42 [get_button_name 1 42]" \
	-command {button_list_output2 "Dig MPL 42"}
   $butadd2.mpl.menu.b6 add command -label "43 [get_button_name 1 43]" \
	-command {button_list_output2 "Dig MPL 43"}
   $butadd2.mpl.menu.b6 add command -label "44 [get_button_name 1 44]" \
	-command {button_list_output2 "Dig MPL 44"}
   $butadd2.mpl.menu.b6 add command -label "45 [get_button_name 1 45]" \
	-command {button_list_output2 "Dig MPL 45"}
   $butadd2.mpl.menu.b6 add command -label "46 [get_button_name 1 46]" \
	-command {button_list_output2 "Dig MPL 46"}
   $butadd2.mpl.menu.b6 add command -label "47 [get_button_name 1 47]" \
	-command {button_list_output2 "Dig MPL 47"}
   $butadd2.mpl.menu.b6 add command -label "48 [get_button_name 1 48]" \
	-command {button_list_output2 "Dig MPL 48"}
	
	
	
   # add a Close button
   button $butadd2.close -text Close -command {destroy .button_add_output2}

   #--------------------------------------------#
   # Pack things up                        	#
   #--------------------------------------------#

   pack $butadd2.gesout $butadd2.mpl -side top	
   pack $butadd2.close -side bottom -pady 3m


   #------------------------------------------------------------#
   # Procedure to display the other info when connection	#
   # is selected from the menu                               	#
   #------------------------------------------------------------#

   proc button_list_output2 { out } {

      global butadd2 but_name2 conn_name2 sp_xentry2 sp_yentry2	
      global but_default1 but_default2 but_default3 but_default4        		
      	
      set board -1
      set elem_num -1
      set belnum -1

      set elem_num [lindex $out 2]

      if { [lindex $out 1] == "Gesout" } {
      		set board 0
      		set belnum [expr {$elem_num + 100}]
      } else {
      		set board 1
      		set belnum [expr {$elem_num + 200}]
      }

      # Button Name
      set but_name2 [get_button_name $board $elem_num]

      # Button Connection
      set conn_name2 $out
	
	#------------------------------------------------------------------#
	# Button color and type 
	#------------------------------------------------------------------#
					
	global varname2 but_color2
	set but_color2 [lindex [get_button_color_type $board $elem_num] 0]
	set varname2 [lindex [get_button_color_type $board $elem_num] 1]
		
	
	
      # Button Position on Screen 2
      set pos [get_button_pos $board $elem_num 2]
      set sp_xentry2 [lindex $pos 0]
      set sp_yentry2 [lindex $pos 1]

      # Display Default For Selected Button
      set bdef [lindex [split [ret_all_info 1 1 $belnum 2] |] 4]
      set but_default1 [lindex [split $bdef :] 0]
      set but_default2 [lindex [split $bdef :] 1]
      set but_default3 [lindex [split $bdef :] 2]
      set but_default4 [lindex [split $bdef :] 3]

      destroy $butadd2

   # end proc button_list_output2
   }


# end  of procedure button_add_output2   	
}



