#!/usr/local/bin/wish -f
proc getenv {var} {
	global env
	if {[catch {set env($var)} result] == 0} {
		return $result
	} else {
		return ""
	}
}
set base [getenv DATABASE]
sql database $base
#
# TO CONFIGURE:  CHANGE THIS PATH to the actual home of the tlib.
#
source ./ucosyb.tlib
source ./wisql.tlib
#
#  wisql
# 	
#  Copyright 1992 Tom Poindexter.
#
#  a windowing version of the sybase isql command  
#  uses extended tcl, tk, and sybtcl interface
#
#  usage: wisql
#
#---------------------------------------------------------------------------
# RCS
#
# $Header: /ni/rcsfiles/smart/guif/perfex/wisql,v 1.4 1995/07/12 15:12:11 mkb Exp $
#
#---------------------------------------------------------------------------
# RELEASE
#
# CURRENT REV: 	VERSION  (see the patchlevel file)
#
#---------------------------------------------------------------------------
proc wisql_main {argv} {
global profiling
global resclear
global base
set base [lindex $argv 0]
puts "base == $base"

# For debugging -- COMMENT THIS OUT if you do not want to run trace
# cmdtrace on [open cmd.log w]
# for profiling -- comment this out unless you want to profile code 
# profile on
# set this to 1 if you are profiling.
set profiling 0

# for autodocumenting:  0 is off, 1 is on
global documentit
set documentit 0

# for connecting to xess spreadsheet  (in early devel, incomplete!)
#
global xess_connection
set xess_connection 0
#
global look_for_xess
set look_for_xess 0

# this is used to switch the results window mode between clear and append.
# clear is 1, append is 0 -- we start out in Clear Mode.
set resclear 1

# define global names in use
global server
global sybmsg
global uname
global table
global release

# rel 1.5 changes to the standard ucosyb library for more flexibility
# global syb
global dbpipe1

global currentFile
global fontSize
global execCmd
global start

global cmdRing
global cmdIdx
global cmdLast

global mode

global bitmapdir
global exedir
global maven

global debugs
global dictionary
global derived

# set this to the list of subroutines you want debugging chit chat from 
set debugs {}

#
# set this to NONE if you do not implement the data dictionary.
#set dictionary NONE
set dictionary "none"

#
# Directory in which to find icon bitmaps
set bitmapdir ./bitmaps

# Directory in which to find extra executables like 'detached' and
# 'anyprint'
set exedir /usr/local/bin
 
# Informix app supporter to send mail to in case of error
set maven de
#set release VERSION
set release ""

#	normal mode is User or NonExpert
#	expert mode permits user to see text of objects
#	the cmdXXX stuff lets us keep a ring buffer of SQL commands
#
set cmdIdx  0
set cmdLast 0
for {set i 0} {$i < 10} {incr i} {
  set cmdRing($i) ""
}
#
set mode 1
set uname informix

#	and we will set ourselves up to use various - flags if we want to
#	at some later time.
#
foreach arg $argv {
	if {[string range $arg 0 0] == "-"} {
		case [string range $arg 1 end] in {
		{x} {
			set mode 1
		}
		}
	} else {
		set uname $arg
		if {$uname == "sa"} {set mode 1}
	}
}
	

# set startT [getclock]
# echo "starting wisql at 0 seconds"

set execCmd doSql
set fontSize 14

set syb {}
set currentFile {}
set table ""

wm title    . "Wisql:  X11 GUI for Informix rev $release"
wm iconname . "Wisql"
}
# kick off the entire process
wisql_main argv
createMain

# that's all it takes

