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