#
# scrib/app/main.tcl
#
# author: jason aftosmis (jason@icemcfd.com)
# date:   april 2002  
#
# start this file with wish and the name of the application directory, e.g.:
#
#   >wish main.tcl app_example [-batch] [-script file.tcl] [-debug]
#
set il 0
set mode "interactive"
set application [lindex $argv $il]
set argc [llength $argv]

incr il
set args [lrange $argv $il end]

while {$il < $argc}  {
    set a [lindex $argv $il]
    switch -- $a {
	"-batch" {
	    set mode batch
	}
	"-debug" {
	    set debug 1
	}
    }
    incr il
}

global env
if ![info exists env(ICEM_ACN)] {
    puts "environment variable ICEM_ACN is not set!"
    return
}
if ![info exists env(ICEM_SCRIB)] {
    set scribpath [file join $env(ICEM_ACN) lib scrib]
    if [file isdirectory $scribpath] {
	set env(ICEM_SCRIB) "$scribpath"
    } else {
	puts "environment variable ICEM_SCRIB not set \
		& application is not in ICEM_ACN!"
	return
    }
}
#
# for notebooks BWidgets, if interactive
#
if {"batch" != $mode} {
    if [info exists env(ICEM_ACN)] {
	lappend auto_path [file join $env(ICEM_ACN) lib bwidget]
    } else {
	lappend auto_path [file join $env(ICEM_SCRIB) bwidget]
    }
    package require BWidget
} else {
    if {[info tclversion] < 8.0} {
	puts "Tcl version greater than 8.0 is required. You have [info tclversion]\n"
    }
}
#
# variables set for using guibase
#
if 0 { if [info exists blt_version] { set has_blt 1 } else { set has_blt 0 } }
set has_blt 0
set small_screen_hack 0
set batch_mode 0
#
# load the ScribApp source
#
set file [file join $env(ICEM_SCRIB) app scribapp.tcl]
source $file
#
# start the application
#
set app [file join $env(ICEM_SCRIB) $application]
::ScribApp "$app" "$args"
