# $Header: /home/cvsroot/tcldb/wisql/Tlib/chkEZRsel,v 1.2 1997/08/25 03:14:37 de Exp $
# tcl procs saved on Tue Sep 05 09:32:20 PDT 1995

proc chkEZRsel {w colu} {



	upvar #0 EZRcol col
	upvar #0 EZRcols cols
	upvar #0 EZRtypes types
	upvar #0 EZRwhere where



#	Horrid hack to enable us to use chkEZRsel in two contexts
#	is just the current col, whereas when we are called by exiting
#	an RSE entry widget in the canvas, we know which column we are
#	and colu has a real value.  If col is blank then must be current.

	set curcol 0
	if {$colu == $col} {
		set curcol 1
	}

	if {$colu == ""} {
		set colu $col
	}

	set ci [lsearch $cols $colu]

	set err [catch {set where($colu,op)}]
	if {$err} {
	} else {
	}

	set newse [$w.data.pic.win.winR.$colu.st get]

	if {$newse == ""} {
		set where($colu,op) ""
		set where($colu,c1) ""
		set where($colu,c2) ""
		set where($colu,sql) ""
		if {$colu == $col} {
#			clear the panel as well
			clearEZRspec 
		}
		return
	}

	set results [chkSel EZR $colu $newse]

	set yesno [lindex $results 0]
	set sql [lindex $results 1]
	set args [lindex $results 2]

	set buts {eq ne gt lt ge le bt st en ct in}
	if {$yesno == "NO"} {
#		if this is the current col then clear the panel
		if {$curcol} {
			clearEZRspec 
		}
		set where($colu,sql) ""
		set where($colu,op) ""
	        set where($colu,c1) ""
        	set where($colu,c2) ""
#	
		$w.data.pic.win.winR.$colu.st delete 0 end
		$w.messages configure -text "$sql"
		return
	}

	set where($colu,sql) $sql
	set where($colu,op) [lindex $args 2]
	set where($colu,c1) [lindex $args 0]
	set where($colu,c2) [lindex $args 1]

	$w.data.pic.win.winR.$colu.st delete 0 end
	$w.data.pic.win.winR.$colu.st insert 0 "$where($colu,sql)"

	
	$w.messages configure  -text "Successful entry of RSE text."


}

