proc edit_instance { field_num selection } {
global PGB
	foreach i $selection {
			clear_it
			# lose the monitor spacer lines
				set g [ split $i | ]
			if { ([llength $g] > 1) } { 
				for { set j [expr {[llength $g]-3}]} {$j >=1} {incr j -1} {
					set name [lindex  $PGB(gui_Names) [expr $j-1]]
                    set fill [string trim [lindex $g $j ] ]
                    if {( $fill!="(null)")} {
                        .$name.ent insert 0 [string trim $fill]
                    }

				}
			}
			ask_for_command $g
		#	after 3000
			#grab .
			#tkwait window  .

		}
}
proc ask_for_command { g } {
	global gui_oid
	catch {destroy .ft_note}
	toplevel .ft_note
	wm title .ft_note "Edit instances"
	wm geom .ft_note +0+0

	label .ft_note.instruct -text "Make changes in the entry windows, and choose replace or delete, or cancel from this file menu"
	set name oid
	set mix "Oid of the instance. Each instance has a specific oid attached"
	set type int
	frame .ft_note.oid
	label .ft_note.oid.lab -text "$mix ($type)"
	scrollbar .ft_note.xscr -orient horizontal -command \
		{ .ft_note.oid.ent view }

	entry .ft_note.oid.ent -width 20 -relief sunken -scroll {.xscr set}
	pack append .ft_note.oid .ft_note.oid.lab  {left fill} \
		.ft_note.oid.ent {right fill}

	set gui_oid [lindex $g [expr {[llength $g]-2}]]
    mkMenuBar .ft_note.menu {} {
    File {
        {"Delete this instance only, no hour time limit" {destroy .ft_note; delete_it $gui_oid} "Deletes a specific instance in class" }
        {"Replace" {destroy .ft_note; replace_it} "Replaces a specific instance in class" }
        {"Cancel" {destroy .ft_note; return} "Cancels current editing, and returns"}
    }}
    pack append .ft_note .ft_note.menu {top fillx} \
	.ft_note.instruct {top fillx} 
#	.ft_note.oid {top fillx} \
#	.ft_note.xscr {top fillx} 
	.ft_note.oid.ent insert 0 [string trim $gui_oid ]
	tkwait window  .ft_note
	set gui_oid -1


} 

