home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tk8.0 / generic / tkInitScript.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-15  |  2.4 KB  |  74 lines  |  [TEXT/CWIE]

  1. /* 
  2.  * tkInitScript.h --
  3.  *
  4.  *    This file contains Unix & Windows common init script
  5.  *      It is not used on the Mac. (the mac init script is in tkMacInit.c)
  6.  *
  7.  * Copyright (c) 1997 Sun Microsystems, Inc.
  8.  *
  9.  * See the file "license.terms" for information on usage and redistribution
  10.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11.  *
  12.  * SCCS: @(#) tkInitScript.h 1.3 97/08/11 19:12:28
  13.  */
  14.  
  15.  
  16.  
  17. /*
  18.  * The following string is the startup script executed in new
  19.  * interpreters.  It looks in several different directories
  20.  * for a script "tk.tcl" that is compatible with this version
  21.  * of Tk.  The tk.tcl script does all of the real work of
  22.  * initialization.
  23.  * When called from a safe interpreter, it does not use file exists.
  24.  * we don't use pwd either because of safe interpreters.
  25.  */
  26.  
  27. static char initScript[] =
  28. "proc tkInit {} {\n\
  29.     global tk_library tk_version tk_patchLevel env errorInfo\n\
  30.     rename tkInit {}\n\
  31.     set errors \"\"\n\
  32.     if {![info exists tk_library]} {\n\
  33.     set tk_library .\n\
  34.     }\n\
  35.     set dirs {}\n\
  36.     if {[info exists env(TK_LIBRARY)]} {\n\
  37.     lappend dirs $env(TK_LIBRARY)\n\
  38.     }\n\
  39.     lappend dirs $tk_library\n\
  40.     lappend dirs [file join [file dirname [info library]] tk$tk_version]\n\
  41.     set parentDir [file dirname [file dirname [info nameofexecutable]]]\n\
  42.     lappend dirs [file join $parentDir tk$tk_version]\n\
  43.     lappend dirs [file join $parentDir lib tk$tk_version]\n\
  44.     lappend dirs [file join $parentDir library]\n\
  45.     set parentParentDir [file dirname $parentDir]\n\
  46.     if [string match {*[ab]*} $tk_patchLevel] {\n\
  47.         set dirSuffix $tk_patchLevel\n\
  48.     } else {\n\
  49.         set dirSuffix $tk_version\n\
  50.     }\n\
  51.     lappend dirs [file join $parentParentDir tk$dirSuffix library]\n\
  52.     lappend dirs [file join $parentParentDir library]\n\
  53.     lappend dirs [file join [file dirname \
  54.     [file dirname [info library]]] tk$dirSuffix library]\n\
  55.     foreach i $dirs {\n\
  56.     set tk_library $i\n\
  57.     set tkfile [file join $i tk.tcl]\n\
  58.         if {[interp issafe] || [file exists $tkfile]} {\n\
  59.         if {![catch {uplevel #0 [list source $tkfile]} msg]} {\n\
  60.         return\n\
  61.         } else {\n\
  62.         append errors \"$tkfile: $msg\n$errorInfo\n\"\n\
  63.         }\n\
  64.     }\n\
  65.     }\n\
  66.     set msg \"Can't find a usable tk.tcl in the following directories: \n\"\n\
  67.     append msg \"    $dirs\n\n\"\n\
  68.     append msg \"$errors\n\n\"\n\
  69.     append msg \"This probably means that Tk wasn't installed properly.\n\"\n\
  70.     error $msg\n\
  71. }\n\
  72. tkInit";
  73.  
  74.