#!/usr/local/tcl/bin/wishx -f
#
# TO CONFIGURE:  CHANGE THIS PATH to the actual home of the tlib.
#
loadlibindex /usr/local/tcl/local/ucosyb.tlib
loadlibindex /u/de/tcl/w/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$
#
#---------------------------------------------------------------------------
# RELEASE
#
# CURRENT REV: 	2.0.21  (see the patchlevel file)
#
#---------------------------------------------------------------------------

global profiling
global resclear

# 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

# 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

# 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 "info.dbo.data_dict"

#
# Directory in which to find icon bitmaps
set bitmapdir /usr/local/X11/include/bitmaps

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

#	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 0
set uname [id user]

#	and we will set ourselves up to use various - flags if we want to
#	at some later time.
#
foreach arg $argv {
	if {[crange $arg 0 0] == "-"} {
		case [crange $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 Sybase rev $release"
wm iconname . "Wisql"

# kick off the entire process

getSignOn

# that's all it takes

