#!nviz -f
# This file handles script playing events by sourcing
# the selected script file.  Within the script file,
# "send" commands are used to actually send the events
# to nviz.  Note that by changing the variable ProcessName
# the events may be rerouted to a different nviz process.
# Also, this version of nviz is fairly insecure as it uses
# insecure sends.

catch {destroy .wait_ok}

global src_boot

source $src_boot/etc/nviz2.2/scripts/config.tcl

# Globals
# ProcessName now defined in config.tcl
#global ProcessName

# If the script option is used, then use that name for the script file,
# otherwise query the user for a script.
#Take first argument to be filename
if {$argc} {set NvizPlayScript $argv}

if {[catch {set NvizPlayScript}] == 0} then {
    global NvizPlayScript
	if {[file isfile $NvizPlayScript]} {
		set new_file "$NvizPlayScript"
	} else {
		tk_dialog .file_error "File Error" \
		"Script file $NvizPlayScript does not exist" \
		error 0 "Dismiss"
		exit
	}
} else {
    set new_file [create_file_browser .script_file_browser 1 1]
    if {$new_file == -1} then {
	exit
    }
}

wm withdraw .

source $new_file

exit







