⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autorun.tcl

📁 windml3.0.3
💻 TCL
📖 第 1 页 / 共 2 页
字号:
    # display the buttons.

    controlHide tornadoAutoRun@@.setupButton 0
    if {![isUnix]} {
        controlHide tornadoAutoRun@@.addiconButton 0
    }
    controlHide tornadoAutoRun@@.exitButton 0
    if [file exist [CDDriveGet]README.TXT] {
        controlHide tornadoAutoRun@@.readmeButton 0
    }
    if [file exist [CDDriveGet]NEW.TXT] {
        controlHide tornadoAutoRun@@.whatsnewButton 0
    }

    # Automatically run INSTW32.TCL if autorunBypass is set or if
    # the automated test answer file is being used.

    if { $autorunBypass || [info exists env(SETUP_ANS_FILE)]} {

        # add the "-C" option for UITclSh for the debug console.
        if {[info exists env(SETUP_DEBUG)] && $env(SETUP_DEBUG) > 1} {
            set option "-C"
        } else {
            set option ""
        }

        # run UITclSh with INSTW32.TCL and close the Autorun window.

        if {[isUnix]} {
            if {[catch {exec [tempDirGet]/UITclSh \
                [CDDriveGet]RESOURCE/TCL/INSTW32.TCL [CDDriveGet] &} error]} {
                messageBox $error
            } else {
                tornadoAutoRun@@windowClose
            }
        } else {
            # remove trailing slash using "string trimright" since an extra
            # slash is added in INSTW32.TCL.  Two slashes does not work under
            # W95 (e.g. c:\\).

            if {[catch {processCreate "[CDDriveGet]X86/WIN32/UITCLSH.EXE \
                $option [CDDriveGet]RESOURCE/TCL/INSTW32.TCL [string \
                trimright [CDDriveGet] \\] [lrange $argv 1 [expr [llength $argv] - 1]]"} error]} {
                messageBox $error
            } else {
                tornadoAutoRun@@windowClose
            }
        }
    }
}

#############################################################################
#
# tornadoAutoRun@@windowClose - closes the Autorun dialog window.
#
# This procedure closes the Autorun dialog window.
#
# SYNOPSIS:
# tornadoAutoRun@@windowClose
#
# PARAMETERS: N/A
#
# RETURNS: N/A
#
# ERRORS: N/A
#

proc tornadoAutoRun@@windowClose {} {

    autoTimerCallbackSet tornadoAutoRun@@ 0
    windowClose tornadoAutoRun@@
}

#############################################################################
#
# tornadoAutoRunShow - creates the Autorun dialog.
#
# This procedure creates the Autorun dialog.
#
# SYNOPSIS:
# tornadoAutoRunShow
#
# PARAMETERS: N/A
#
# RETURNS: N/A
#
# ERRORS: N/A
#

proc tornadoAutoRunShow {} {
    dialogCreate -name tornadoAutoRun@@ \
        -w 100 -h 100 -init tornadoAutoRun@@Init \
        -nocontexthelp \
        -exit {
            catch {global setup_lib}
            if {$setup_lib != ""} {
                dllUnload $setup_lib
                set setup_lib ""
            }
        } \
        -nocontexthelp
}

#############################################################################
#
# CDDriveGet - returns the root of the Setup tree.
#
# This procedure returns the root of the Setup image tree based on
# the path of UITclSh.
#
# SYNOPSIS:
# tornadoAutoRunShow
#
# PARAMETERS: N/A
#
# RETURNS:
# the root of the Setup tree, terminated with `\` for Windows
# or '/' for Unix.
#
# ERRORS: N/A
#

proc CDDriveGet {} {
    if {[isUnix]} {
        global env

        return "$env(CD_ROOT)/"
    } else {
        set remainder [info nameofexecutable]
        set drive ""

        regsub -all {/} $remainder {\\} remainder

        # Check for UNC

        set index [string first "\\" $remainder]

        if {$index != -1} {
            # Parse out UNC segment with '\\' intact
            set uncSeg $remainder
            set remainder [string range $remainder 2 end]
            set index [string first "\\" $remainder]

            set drive [string range $uncSeg 0 [expr $index + 2]]
            set remainder [string range $remainder [expr $index + 1] end]
        }

        # Set remainder to a list describing the image root

        set remainder [file split $remainder]
        set remainder [lrange $remainder 0 [expr [llength $remainder] - 4]]

        # String remainder back into a '\' separated path, ending in '\'
        foreach elem $remainder {
            set drive "$drive$elem\\"
        }
        return $drive
    }
}

#############################################################################
#
# tempDirGet - returns the temporary directory to which files
#              have been extracted.
#
# This procedure returns the path location for, or to which, files
# have been extracted.  If TMP or TEMP are not found, C:/TMP is
# created.
#
# SYNOPSIS:
# tempDirGet
#
# PARAMETERS: N/A
#
# RETURNS:
# the temporary directory.
#
# ERRORS: N/A
#

proc tempDirGet {} {
    global env
    global tempDir

    if {$tempDir == ""} {
        set envList [array names env]
        foreach var $envList {
            if {![string compare [string tolower $var] tmp]} {
                set tempDir $env($var)
                break
            } elseif {![string compare [string tolower $var] temp]} {
                set tempDir $env($var)
                break
            }
        }

        # If we can't find TMP, then create it
        if {$tempDir == ""} {
            if [file mkdir c:/TMP] {
                set env(TMP) c:/TMP
                set tempDir c:/TMP
            }
        }
    }

    # Must end in '/'

    regsub -all {\\} $tempDir / tempDir
    if {[string index $tempDir [expr [string length $tempDir] - 1]] != "/"} {
        set tempDir "$tempDir/"
    }
    return $tempDir
}

#############################################################################
#
# isUnix - returns whether the host machine is a Unix machine.
#
# This procedure returns whether the host machine is a Unix machine.
# This is determined by either the environment setting for WIND_HOST_TYPE,
# or by the existence of MWHOME if WIND_HOST_TYPE has not been set.
#
# SYNOPSIS:
# isUnix
#
# PARAMETERS: N/A
#
# RETURNS:
# 1 if a Unix host.
# 0 if not a Unix host.
#
# ERRORS: N/A
#

proc isUnix {} {
    global env

    if {[info exists env(WIND_HOST_TYPE)]} {
        if {[string match sun4* $env(WIND_HOST_TYPE)]} {
            return 1;
        } elseif {[string match "x86-linux2" $env(WIND_HOST_TYPE)]} {
            return 1;
        } elseif {[string match parisc* $env(WIND_HOST_TYPE)]} {
            return 1;
        } else {
            return 0;
        }
    } else {
        return [info exists env(MWHOME)]
    }
}

#############################################################################
#
# editorCommand - returns the command to execute an editor on Unix.
#
# This procedure returns the tcl command the execute an editor with
# the specified filename on a Unix host.  The editor used is the value
# set for the environment variable EDITOR.  If the variable is not set,
# or if EDITOR is set to an unsupported editor, an xterm using the
# "more" command is used to display the file.  Supported editors are
# vi, emacs, and xemacs.
#
# SYNOPSIS:
# editorCommand filename
#
# PARAMETERS:
# <filename>
# the file to edit.
#
# RETURNS:
# the tcl command to open the editor with the specified file.
#
# ERRORS: N/A
#

proc editorCommand {filename} {
    global env

    if {[info exists env(EDITOR)]} {
        switch $env(EDITOR) {
            vi { return [exec xterm -title [file tail $filename] -e vi\
                 $filename &] }
            emacs { return [exec emacs $filename &] }
            xemacs { return [exec xemacs $filename &] }
            default {
                if { $env(WIND_HOST_TYPE) == "sun4-solaris2" ||
                     $env(WIND_HOST_TYPE) == "x86-linux2" } {                  
                    return [exec xterm -title [file tail $filename] -e \
                            /bin/more -w $filename &]
                } elseif {$env(WIND_HOST_TYPE) == "parisc-hpux10"} {
                    return [exec xterm -title [file tail $filename] -e \
                            /bin/more $filename &] 
                }               
            }
        }
    } else {
        # EDITOR environment variable not set

        if {$env(WIND_HOST_TYPE) == "sun4-solaris2" ||
            $env(WIND_HOST_TYPE) == "x86-linux2" } {
            return [exec xterm -title [file tail $filename] -e /bin/more \
                    -w $filename &]
        } elseif {$env(WIND_HOST_TYPE) == "parisc-hpux10"} {
            return [exec xterm -title [file tail $filename] -e /bin/more \
                    $filename &] 
        }  
    }
}

#############################################################################
# AUTORUN.TCL - Initialization code
#
# This code is executed when the file is sourced.  It sources GLOBAL.TCL,
# loads UITclControls.dll, and executes the entry routine tornadoAutoRunShow.
#

source [CDDriveGet]/RESOURCE/TCL/GLOBAL.TCL
source [CDDriveGet]/RESOURCE/TCL/INCLUDE.TCL
source [CDDriveGet]/RESOURCE/TCL/CONFIG.TCL

# load the UITclControls dll.

if {[isUnix]} {
    if { $env(WIND_HOST_TYPE) == "sun4-solaris2" ||
         $env(WIND_HOST_TYPE) == "x86-linux2" } {
        dllLoad [tempDirGet]/libuitclcontrols.so _UITclControls_Init
    } elseif {$env(WIND_HOST_TYPE) == "parisc-hpux10"} {
        dllLoad [tempDirGet]/libuitclcontrols.sl _UITclControls_Init
    }

} else {
    dllLoad [CDDriveGet]X86/WIN32/UITCLCONTROLS.DLL _UITclControls_Init
}

catch {tornadoAutoRunShow}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -