#!/usr/local/tcl/bin/wishxsyb
#------------------------ Global Variables ---------------------------
#
# Feb 9th generalized setOrder and the loop in changeElem
#
# PUBLIC VARIANT
#
#---------------------------------------------------------------------------
# REV LEVEL:  2.0.3
#---------------------------------------------------------------------------
#
loadlibindex /usr/local/tcl/local/ucosyb.tlib
# loadlibindex /usr/local/tcl/local/ucosql.tlib
loadlibindex /usr/local/tcl/local/fosql.tlib
#
global bitmapdir
set bitmapdir /usr/local/X11/include/bitmaps
#
#---------------------------------------------------------------------------
# SHARED CODE  PUBLIC/PRIVATE
#---------------------------------------------------------------------------
############################### Global vars start here ########################
#
# if you don't do this then expr results get weirdly rounded
#
global tcl_precision
set tcl_precision 9
#
# 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 profiling 1
#
global profiling
set profiling 0
#
global launch
set launch forms
#
# startw, starth
# these are the x/y dimensions of the startup window
global startw
global starth
set startw 800
set starth 300
#
# findstay
# if this is set to 1, then the Generic Find record pickList will stay
# up despite a dbl-click, whereas if it is 0, the default behaviour will
# take place (it will go away on a dbl-click).  data will be transferred
# in both cases.  Users may have a preference one way or 'tother.
global findstay
set findstay 0
#
# oltp
# if this is set to 0, then the Generic Find function will look for
# boolean operators in user input and will user userComp function to
# create SQL and append to sqlcmd3, instead of doing simple value =
# comparisons.  Setting this to 1 will suppress this and keep it
# simple, favouring data entry over data browse.  In other words,
# with oltp set 0, genericFind can deal with entries like "< 10"
# as boolean expressions, whereas with it set 1, "< 10" will be
# interpreted as a literal value for data entry.
global oltp
set oltp 1
#
# updlim
# this integer limit defines the max number of records that pseuSQL will
# update in one go.  Set this to 0 if you want infinity.    Hack around
# in pseuSQL if you want to disable the limit for specific forms or form
# types.  I suppose this should really (sigh) be an attribute of the
# form, but it's also kind of site-specific, so I dunno if it's worth
# implementing intelligently.  Could be an attributed of the ftype also...
global updlim
set updlim 50
#
# sybsave
# this var is for saving the sybmsg(msgtext) value from a doSQL in
# genericTins so that it does not get clobbered between pass 1 (table 0)
# and subsequent (tables 1, 2..) passes on a trigger-keyed insert.
# genericTins will set it, and genericComm will grab it and then 
# reset it to ""  (Dec 12 1994)
# Dec 15 1995:  better fix is to fix mainMsg to update idletasks (source
# of bogus event processed):  remove this hack
# set sybsave {}
#
# distFlag
# This flag is meant to be used as a state variable in the science (browse)
# forms, not in oltp mode.  Setting this to "distinct" causes genericFind
# to select distinct instead of just selecting all records.  Don't set this
# for any OLTP application.  Your users will hate you.
global distFlag
set distFlag ""
#
# for auto-documenting of code:  0 turns it off, 1 turns it on
# this is actually obsolete.  tkinspect is a much better debugging
# tool than all my autodoc stuff, so forget about this.
global documentit
set documentit 0

# for improved file-driven help facility
# set this to the directory where you put the fosql help files.
global helpdir
set helpdir /usr/local/sybase/help

# for sneaking into the SQR reports
# this is only relevant if you have "paper form" buttons which want to
# execute SQR code and present users with formatted reports.  rptdir
# would be the dir where the reports (sqr and sqt) are kept.
global rptdir
set rptdir /usr/local/sybase/reports

# for interacting with Xess
# if you have the xess spreadsheet, fosql can transfer data directly
# from the forms or from users' sql queries into an Xess sheet.
global look_for_xess
global xess_connection
#
set look_for_xess 1
set xess_connection 0
#
# printcmd
# this is the command used to print out requested user data.  you will
# want to set this to the "safe" print command at your site.
global printcmd
set printcmd anyprint
#
# these are all sybtcl variables, don't mess with them!
#
global dbpipe1 dbpipe2 dbpipe3 dbpipe4 dbpipe5
global sybmsg
global server
global uname

# Customization options:
#
# set this to 1 and the user will be "are you sure"d before deleting records
global areyousure
global ayscheck
#
# this is the place where fosql looks for local executables
global exedir
# this is the loc of your X11 local tree and pbm util dir (for snapshots)
global xlocaldir
global pbmdir
# dictionary is the data dictionary tablename (FQ)
global dictionary
# fassists is the fassist table name (FQ)
global fassists
# forms is the forms table name (FQ)
global forms
# fwidgets is the fwidgets table name (FQ)
global fwidgets
# warnlog is the warning log table name (FQ)
global warnlog
# not yet used
global site
# ftypes is the ftypes table name (FQ)
global ftypes
# maven is the person to send mail to in certain circs
global maven
#
# this is the current releast
global release
#
# set this {} unless you want a lot of chitchat
global debugs
#
# this is the list of user error conditions detected this session
global Uerrors
#

# debugs
# set this to the list of subroutines you want debugging chit chat from 
# but remember you have to be using DEBUG.fosql.tlib for this to do you
# any good
set debugs {}

# Uerrors
# set this to {} to start with.  each user error will prepend a message to
# the list.  the logError routine will add the error and show the user the
# current list.  NB:  we rely a lot on triggers to return error messages,
# but we can also detect Sybase server errors.
set Uerrors {}

# maven
# set maven to the email address of the person to mail bug reports to
# AT YOUR SITE.  (don't send them to me unless you are at Lick!)
set maven de

# release
# This string 2.0.3 gets sed'd to the current version at install time
# (see the Makefile) by the util "touchrev"
set release 2.0.3

# ayscheck
# If you want Are You Sure in generic delete, set this to 1
set ayscheck 1

# exedir
# Directory in which to find extra executables like 'detached' and
# 'anyprint'
set exedir /usr/local/bin

# xlocaldir
# Directory in which to find X11 executables like 'ghostview' and
# 'xpr'
set xlocaldir /usr/local/bin/X11

# pbmdir
# directory in which to find pbm utilities because for some braindead
# reason they are not in xlocaldir
set pbmdir /usr/local/new/pbm/xwdtopnm
#
# global defs -- change these according to
#	your site
#	your app
#	your mood and the time of day :-)
#

# site
#	This is sort of an ifdef for various lick-specific thingies that
#	you do not care about unless you are us.  It will be used to
# 	suppress certain lickifications in the code.
set site "UCOLick"

# fassists
#	This is the name of the fassists table (a component of the forms)
#	read only to all users -- for info, substitute the name of your
#	metabase, whatever it may be  (also seriatim)
set fassists "metabase.dbo.fassists"

# forms
#	This is the name of the forms master table
#	read only to all users
set forms "metabase.dbo.forms"

# fwidgets
#	this is the name of the fwidgets table (a component of the forms)
#	read only to all users
set fwidgets "metabase.dbo.fwidgets"

# ftypes
#	This is a list of form types (Lick specific, sorry)
#	we use this to divvy up the forms into menus of like forms
#	you can modify this however, to your own requirements.
#	read only to all users.
set ftypes "metabase.dbo.formtypes"

# warnlog
#	This is the name of the warning log table, into which entries are
#	made when a WARN999 type message comes back from a trigger or
#	procedure -- all users must have insert, but no delete or update.
#	if your triggers do not return WARN999 strings, you don't care.
#
set warnlog "metabase.dbo.warning_log"
#
#	you need also the table "ucowarnings" (our name for it here) to
#	translate the warning ID codes into text messages and comments.

# dictionary
#	This is the name of the data dictionary table -- if any!
#	You want to swap commenting on the next 2 lines if you don't 
#	implement it  -- read only to all users
# set dictionary "NONE"
set dictionary "metabase.dbo.data_dict"

set uname ""

# mode
# this is the old expert vs user mode flag as in wisql
global mode

set mode 0

# base
# no longer needed, since all table names are FQ now and all systables refs
# are made to match!  but leave it set until we have verified this 1/12/94
# OBSOLETE

set base info

# This one is not really standard, so we'll declare it and set it last

#---------------------------- UCO LICK ----------------------------------
# fdb fys and fymagic
# global var used at UCOLick Only, to determine which fiscal year
# the fiscal forms are looking at -- we will use this to construct
# FQ table names in fiscal forms, from the magic string in fymagic 
# to the string in fdb (F90, F91 etc.)  A simple regsub.
# fys is used only in startForm to build the stack of fy buttons.

# fdb gets set to the default fiscal year here.

global fdb 
global fys
global fymagic
set fdb f96

# set this string to "" to suppress the "f" buttons on main form
set fys "f96 f95 f94 f93 f92 f91 f90"

set fymagic ucofyx

#	No, do this dynamically in makeForm (always return 0)
#	and genericFind (if oltp ret 0 else NULL)
#
# if {$oltp} {
# 	set sybmsg(nullvalue) 0
# } else {
# 	set sybmsg(nullvalue) "NULL"
# }

#---------------------------- UCO LICK ----------------------------------

############################### Code starts here ############################

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}
        }
}

#	If in expert mode, disable areyousure on delete.

if {$mode} {
	set ayscheck 0
}

wm title    . "Fosql:  X11 Forms GUI for Sybase 2.0.3"
wm iconname . "Fosql"

# use the tkmail bindings, with whatever hacks we add locally
# if the enhanced bindxtnd.tcl is not the default, source it
        if {[info proc tkBindDefVar]==""} {
          foreach key [bind Text] { bind Text $key {} }
          foreach key [bind Entry] { bind Entry $key {} }
          source /usr/local/tcl74/lib/tkbind/bindxtnd.tcl
          source /usr/local/tcl74/lib/tkbind/text.tcl
          source /usr/local/tcl74/lib/tkbind/entry.tcl
          # source additional packages here
        }

#	launch  -- here we go...  banzai!  banzai!  banzai!

	getSignOn
