home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 November / CDVD1105.ISO / Software / Freeware / multimedia / pgcedit / pgcedit.exe / freewrapCmds.tcl < prev   
Text File  |  2004-03-06  |  21KB  |  617 lines

  1. # freeWrap is Copyright (c) 1998-2001 by Dennis R. LaBelle (labelled@nycap.rr.com)
  2. # All Rights Reserved.
  3. #
  4. # This software is provided 'as-is', without any express or implied warranty. In no
  5. # event will the authors be held liable for any damages arising from the use of 
  6. # this software. 
  7. #
  8. # Permission is granted to anyone to use this software for any purpose, including
  9. # commercial applications, and to alter it and redistribute it freely, subject to
  10. # the following restrictions:
  11. #
  12. # 1. The origin of this software must not be misrepresented; you must not claim 
  13. #    that you wrote the original software. If you use this software in a product, an
  14. #    acknowledgment in the product documentation would be appreciated but is not
  15. #    required.
  16. #
  17. # 2. Altered source versions must be plainly marked as such, and must not be
  18. #    misrepresented as being the original software. 
  19. #
  20. # 3. This notice may not be removed or altered from any source distribution.
  21. #
  22. # This TCL/TK script provides the freeWrap namespace commands.
  23. #
  24. # Revision history:
  25. #
  26. # Revison  Date           Author             Description
  27. # -------  -------------  -----------------  --------------------------------------------
  28. #   5.0    Dec. 31, 2001  Dennis R. LaBelle  1) Extracted freeWrap namespace items to
  29. #                                               this separate file.
  30. #                                            2) Added ::freewrap::reconnect procedure to
  31. #                                               reattach archives to the freeWrap stub
  32. #                                            3) Replaced the TCL "source" command in order
  33. #                                               to handle freeWrap encrypted scripts.
  34. #                                            4) Original "source" command renamed to
  35. #                                               ::freewrap::source
  36. #                                            5) Added ::freewrap::getStubSize procedure.
  37. #                                            6) Added ::freewrap::encrypted variable.
  38. #                                            7) Added replacement for glob command using
  39. #                                               some source code from Dave Bodenstab
  40.  
  41. #   5.1    Jan. 26, 2002 Dennis R. LaBelle   1) Adjusted setting of auto_path variable.
  42. #                                            2) Fixed error in ::freewrap::getStubSize
  43. #                                               that occurred since file names are no
  44. #                                               longer converted to lower case.
  45. #                                            3) Replaced the TCL "info" command in order
  46. #                                               to handle the "info script" command for
  47. #                                               wrapped files.
  48.  
  49. #   5.2    June  2, 2002 Dennis R. LaBelle   1) Removed replacement glob command.
  50. #                                            2) Fixed unpack procedure to prevent addition
  51. #                                               of newline character at end of unpacked file.
  52. #                                            3) Removed reroot procedure. Correct root directory
  53. #                                               is now established in main.c file.
  54. #                                            4) Adjusted setting of auto_path variable to include
  55. #                                               /blt directory when running BLT version.
  56.  
  57. #   5.3    Aug. 17, 2002 Dennis R. LaBelle   1) Added errormsg variable to ::freewrap namespace. Modified
  58. #                                               ::freewrap::unpack proc to set this variable if file cannot
  59. #                                               be written to the destination.
  60. #
  61. #   5.4    Nov. 23, 2002 Dennis R. LaBelle   1) ::freewrap::unpack proc now sets the timestamp of the copied
  62. #                                               file to that of the wrapped copy.
  63. #
  64. #   5.6    Dec.  2, 2003 Dennis R. LaBelle   1) Removed freeWrap version of "source" command as a result of
  65. #                                               removing source code encryption feature.
  66.  
  67. # create ::freeWrap namespace
  68. #
  69. namespace eval ::freewrap:: {
  70. variable patchLevel {5.61}     ;# Current freeWrap revision level
  71. variable progname {}          ;# Official freeWrap program name
  72. variable scriptFile {}        ;# Name of executing script file when freeWrap's SOURCE replacement procedure is used.
  73. variable errormsg {}          ;# Last freeWrap error message.
  74.  
  75. proc normalizePath { filename} {
  76. # Return absolute path with . and .. resolved
  77. global tcl_platform
  78.  
  79. if {$tcl_platform(platform) == "windows"} {
  80.     if {[string index $filename 1] == {:}} {
  81.       set newpath [string range $filename 2 end]
  82.      } { set newpath $filename }
  83.    } { set newpath $filename }
  84.  
  85. return $newpath
  86. }
  87.  
  88.  
  89. proc isSameRev { filename} {
  90. # Checks whether the specified file contains a copy of the same freeWrap
  91. # revision as the currently executing program.
  92. #
  93. # Returns: 0, if file is not a copy
  94. #      1, if file is a copy
  95. #
  96. set rtnval 0
  97.  
  98. if {$filename != ""} {
  99.    if {![catch {::zvfs::mount $filename /fwtestsameas}]} {
  100.       # retrieve the information for the specified file.
  101.       set fwRev unknown
  102.       set stubsize 0
  103.       if {[::zvfs::exists /fwtestsameas/_freewrap_init.txt]} {
  104.     set fin [open /fwtestsameas/_freewrap_init.txt r]
  105.     gets $fin line
  106.     gets $fin fwRev
  107.     gets $fin stubsize
  108.     close $fin
  109.     unset fin
  110.         }
  111.       ::zvfs::unmount $filename
  112.  
  113.       # retrieve the information for the currently running program
  114.       set fwRevCur current
  115.       set stubsizeCur 0
  116.       if {[::zvfs::exists /_freewrap_init.txt]} {
  117.     set fin [open /_freewrap_init.txt r]
  118.     gets $fin line
  119.     gets $fin fwRevCur
  120.     gets $fin stubsizeCur
  121.     close $fin
  122.     unset fin
  123.         }
  124.        if { ($fwRev == $fwRevCur) && ($stubsize == $stubsizeCur) } { set rtnval 1 }
  125.       }
  126.    }
  127. return $rtnval
  128. }
  129.  
  130.  
  131. proc unpack {path {destdir {}}} {
  132. # Unpack a file from ZVFS into a native location.
  133. #
  134. # path    = ZVFS path of file to unpack
  135. # destdir = optional destination directory for unpacked file.
  136. #
  137. # Returns: on success, the name of the native file
  138. #          on failure, an empty string
  139. #
  140. global env
  141. global tcl_platform
  142. variable errormsg
  143.  
  144. set filename {}
  145. if {[file exists $path]} {
  146.     if {$destdir == {}} {
  147.       if {$tcl_platform(platform) == "windows"} {
  148.         set destdir [file attributes $env(TEMP) -longname]
  149.          } { set destdir /usr/tmp }
  150.      }
  151.     if {![file isdirectory $destdir]} { return {}}
  152.     set dest [file join $destdir [file tail $path]]
  153.     if {[file exists $dest]} {
  154.         # The file has already been copied once.
  155.         set filename $dest
  156.      } {
  157.         # copy the file to its temporary location
  158.         set fin [open $path r]
  159.         if {[catch {open $dest w} fout]} {
  160.             set errormsg $fout
  161.             close $fin
  162.            } {
  163.              fconfigure $fin -translation binary -buffersize 500000 -encoding binary
  164.              fconfigure $fout -translation binary -buffersize 500000 -encoding binary
  165.              set ext [file extension $path]
  166.              puts -nonewline $fout [read $fin]
  167.              close $fin
  168.              close $fout
  169.              set filename $dest
  170.              catch {file mtime $dest [file mtime $path]}
  171.              }
  172.        }
  173.    }
  174. return $filename
  175. }
  176.  
  177.  
  178. proc iswrapped {filename} {
  179. # Determine whether a file is a freeWrap application
  180. #
  181. # Returns:    1, if file is a freeWrap application
  182. #           0, if file is NOT a freeWrap application
  183.  
  184. set rtnval 0
  185.  
  186. # get name of the running application
  187. set execname [info nameofexecutable]
  188. if {[file type $execname] == "link"} {
  189.     set execname [file readlink $execname]
  190.    }
  191.  
  192. # Is the user asking about the current application?
  193. if {$filename == $execname} {
  194.     set rtnval 1
  195.    } {
  196.     # mount the file
  197.     if {![catch {::zvfs::mount $filename /fwtemp_mount} result]} {
  198.         if {[::zvfs::exists /fwtemp_mount/_freewrap_init.txt]} { set rtnval 1 }
  199.         ::zvfs::unmount $filename
  200.        }
  201.      }
  202. return $rtnval
  203. }
  204.  
  205.  
  206. proc getStubSize {{stubname {}}} {
  207. # Retrieve the size of the freeWrap stub associated with file stubname.
  208. #
  209. # Returns: the size of the stub in bytes or 0, if the stub size cannot be determined or the file does not exist.
  210. global tcl_platform
  211.           
  212. set rtnval 0
  213.  
  214. # get name of currently executing program
  215. set execname [info nameofexecutable]
  216. if {[file type $execname] == "link"} {
  217.     set execname [file readlink $execname]
  218.    }
  219. set execExt [string tolower [file extension $execname]]
  220.  
  221. if {$stubname == {}} {
  222.     # return the stub size for the currently executing program.
  223.     if {[::zvfs::exists /_freewrap_init.txt]} {
  224.       set fin [open /_freewrap_init.txt r]
  225.       gets $fin line
  226.       gets $fin line
  227.       gets $fin line
  228.       close $fin
  229.       unset fin
  230.       if {$line != {}} {
  231.         # simply return the currently stored value
  232.         return $line
  233.          }
  234.      }
  235.     set stubname $execname
  236.  
  237.    } elseif {![file exists $stubname]} { return 0 }
  238.  
  239. # Open file an try to find the start of the ZIP archive.
  240. if {![catch {open $stubname r} fin]} {
  241.     fconfigure $fin -translation binary
  242.     set data [read $fin 5000000]
  243.     close $fin
  244.  
  245.     # Create signature string in a form that will not be read as another signature.
  246.     set signature "PK"
  247.     append signature "\03\04"
  248.     set tailchar "\00"
  249.  
  250.     # Search for signature.
  251.     # Find correct instance of the signature.
  252.     set slen [string length $data]
  253.     set pos 0
  254.     set passno 0
  255.     while {$pos < $slen} {
  256.              set pos [string first $signature $data $pos]
  257.              if {$pos == -1} {
  258.                  set pos $slen
  259.                } {
  260.                    set nextpos $pos
  261.                    incr nextpos 5
  262.                    set nextchar [string index $data $nextpos]
  263.                    if {$nextchar == $tailchar} {
  264.                        set rtnval $pos
  265.                        set pos $slen
  266.                       } { incr pos 4 }
  267.                  }
  268.            }
  269.    }
  270. return $rtnval
  271. }
  272.  
  273.  
  274. proc reconnect {src dest} {
  275. # Copy the specified mounted source file to the specified destination file name.
  276. # Reattach the freeWrap stub to the beginning of the destination file.
  277. #
  278. # Returns: 0, on success
  279. #          1, on failure
  280.  
  281. global tcl_platform
  282.  
  283. set rtnval 1
  284. set stubsize 0
  285. # get name of currently executing program
  286. set execname [info nameofexecutable]
  287. if {[file type $execname] == "link"} {
  288.     set execname [file readlink $execname]
  289.    }
  290.  
  291. # Extract ZIP executable so we can run it.
  292. if {$tcl_platform(platform) == "unix"} {
  293.     # under UNIX, our file must have an extension of .zip in order to readjust
  294.     # the preamble (i.e use the zip -A option)
  295.     set wdest ${dest}.zip
  296.     set zipProgram [unpack /zip] 
  297.     file attributes $zipProgram -permissions 0700 
  298.    } {
  299.     set wdest $dest
  300.     set zipProgram [unpack /zip.exe]
  301.       }
  302.  
  303. set stubsize [getStubSize]
  304. if {$stubsize > 0} {
  305.     if {![catch {open $wdest w} fout]} {
  306.       # get name of currently executing program
  307.       set execname [info nameofexecutable]
  308.       if {[file type $execname] == "link"} {
  309.         set execname [file readlink $execname]
  310.          }
  311.  
  312.       # copy the freeWrap stub
  313.       if {![catch {open $execname r} fin]} {
  314.         fconfigure $fin -translation binary -buffersize 500000 -encoding binary
  315.         fconfigure $fout -translation binary -buffersize 500000 -encoding binary
  316.         fcopy $fin $fout -size $stubsize
  317.         close $fin
  318.         if {[catch {open $src r} fin]} {
  319.             puts $fin
  320.             close $fout
  321.             file delete -force $dest
  322.            } {
  323.             fconfigure $fin -translation binary -buffersize 500000 -encoding binary
  324.             puts -nonewline $fout [read $fin]
  325.             close $fout
  326.             catch {exec $zipProgram -A $wdest} result
  327.             if {$wdest != $dest} {
  328.                 # under UNIX, rename file to final name and mark it
  329.                 # as executable
  330.                 file rename -force $wdest $dest
  331.                 file attributes $dest -permissions 0700
  332.                }
  333.             set rtnval 0
  334.              }
  335.          } { puts $fin }
  336.      } { puts $fout }
  337.    }
  338.  
  339. return $rtnval
  340. }
  341.  
  342.  
  343. # File extension association procedures for Windows.
  344. # These procedures are based upon (with minor modifications) the ms_shell_setup package by 
  345. # Earl Johnson whose Copyright notice follows.
  346.  
  347.   # This is a simple wrapper arround the registry commands provided by the standard TCL
  348.   # installation on Windows.
  349.  
  350.   # By using this library you advoid some details of the registry use, but not all.  Remember
  351.   # to treat your registry with caution!
  352.  
  353.   #
  354.   # Copyright (c) 1999
  355.   # Earl Johhnson
  356.   # earl-johnson@juno.com
  357.   # http://www.erols.com/earl-johnson
  358.   #
  359.   # Permission to use, copy, modify, distribute and sell this software
  360.   # and its documentation for any purpose is hereby granted without fee,
  361.   # provided that the above copyright notice appear in all copies and
  362.   # that both that copyright notice and this permission notice appear
  363.   # in supporting documentation.  Earl Johnson makes no
  364.   # representations about the suitability of this software for any
  365.   # purpose.  It is provided "as is" without express or implied warranty.
  366.   #
  367.  
  368. if {$tcl_platform(platform) == "windows"} { package require registry }
  369.  
  370. # Check whether a key exists for an extension
  371. # Example: shell_assoc_exist .txt => 1
  372. # Example: shell_assoc_exist .NEVER => 0
  373. proc shell_assoc_exist {extension} {
  374.     if {[catch {registry get "HKEY_CLASSES_ROOT\\$extension" ""}]} {set ret 0} {set ret 1}
  375.     return $ret
  376. }
  377.  
  378. # Show whether a file type exists
  379. # Example: shell_fileType_exist txtfile => 1
  380. # Example: shell_fileType_exist NEVER => 0
  381. proc shell_fileType_exist {fileType} {
  382.     if {[catch {registry get "HKEY_CLASSES_ROOT\\$fileType" ""}]} {set ret 0} {set ret 1}
  383.     return $ret
  384. }
  385.  
  386. # Creates a file extension and associates it with fileType.
  387. # Example: shell_fileExtension_setup .txt txtfile
  388. # Remove connection between extension and fileType
  389. # Example: shell_fileExtension_setup .txt ""
  390. proc shell_fileExtension_setup {extension fileType} {
  391.   registry set "HKEY_CLASSES_ROOT\\$extension" "" $fileType
  392. }
  393.  
  394. # Creates a fileType
  395. # Example: shell_fileType_setup txtfile "Text Document"
  396. proc shell_fileType_setup {fileType title} {
  397.   registry set "HKEY_CLASSES_ROOT\\$fileType" "" $title
  398. }
  399.  
  400. # Creates a open command on left click.
  401. # Allows sets action for double click.
  402. # Example: shell_fileType_open txtfile "C:\WINDOWS\NOTEPAD.EXE %1"
  403. # Please note the %1 for passing in file name
  404. proc shell_fileType_open {fileType openCommand} {
  405.    registry set "HKEY_CLASSES_ROOT\\$fileType\\Shell\\open\\command" "" $openCommand"
  406. }
  407.  
  408. # Creates a print command on left click.
  409. # Example: shell_fileType_print txtfile "C:\WINDOWS\NOTEPAD.EXE /p %1"
  410. # Please note the %1 for passing in file name
  411. proc shell_fileType_print {fileType printCommand} {
  412.    registry set "HKEY_CLASSES_ROOT\\$fileType\\Shell\\print\\command" "" $printCommand
  413. }
  414.  
  415. # Sets an icon for a fileType
  416. # Example: shell_fileType_icon txtfile "C:\WINDOWS\SYSTEM\shell32.dll,-152"
  417. # Please note the C:\WINDOWS\SYSTEM\shell32.dll,-152
  418. # We can give a name.ico file or a dll or exe file here.
  419. # If a dll or exe file is used the index for resource
  420. # inside it that gives the icon must be given.
  421. proc shell_fileType_icon {fileType icon} {
  422.    registry set "HKEY_CLASSES_ROOT\\$fileType\\DefaultIcon" "" $icon
  423. }
  424.  
  425. # Sets the quick view for a fileType
  426. proc shell_fileType_quickView {fileType quickViewCmd} {
  427.    registry set "HKEY_CLASSES_ROOT\\$fileType\\QuickView" "" $quickViewCmd
  428. }
  429.  
  430. # This adds any command you like to a fileType
  431. # Example: shell_fileType_addAny_cmd scrfile config "%1"
  432. proc shell_fileType_addAny_cmd {fileType cmdName cmd} {
  433.    registry set "HKEY_CLASSES_ROOT\\[set fileType]\\Shell\\$cmdName\\command" "" $cmd
  434. }
  435.  
  436. # Uses some string instead of actual command on right mouse menu.
  437. proc shell_fileType_setMenuName {fileType cmdName str} {
  438.    registry set "HKEY_CLASSES_ROOT\\$fileType\\Shell\\$cmdName" "" $str
  439. }
  440.  
  441. # Show or not show the extension on the fileType
  442. # Example: shell_fileType_showExt txtfile
  443. proc shell_fileType_showExt {fileType {yesOrNo t}} {
  444.    if {$yesOrNo} {
  445.       registry set "HKEY_CLASSES_ROOT\\$fileType" "AlwaysShowExt" ""
  446.    } {
  447.       registry delete "HKEY_CLASSES_ROOT\\$fileType" "AlwaysShowExt"
  448.      }
  449. }
  450.  
  451. # Over-ride the windows ordering of commands on right click
  452. # Example: shell_fileType_setCmdOrder txtfile {print open}
  453. proc shell_fileType_setCmdOrder {fileType cmds} {
  454.    set str ""
  455.    foreach cmd $cmds {
  456.         append str "$cmd, "
  457.        }
  458.    set slen [string length $str]
  459.    if {$slen > 0} {
  460.      incr slen -3
  461.      set str [string range $str 0 $slen]
  462.      registry set "HKEY_CLASSES_ROOT\\$fileType\\Shell" "" $str
  463.     }
  464. }
  465.  
  466. # Never show extension on fileType
  467. # Example: shell_fileType_neverShowExt txtfile
  468. proc shell_fileType_neverShowExt {fileType {yesOrNo t}} {
  469.    registry set "HKEY_CLASSES_ROOT\\[set fileType]" "NeverShowExt" ""
  470.    if {$yesOrNo} {
  471.       registry set "HKEY_CLASSES_ROOT\\[set fileType]" "NeverShowExt" ""
  472.    } {
  473.       registry delete "HKEY_CLASSES_ROOT\\[set fileType]" "NeverShowExt"
  474.      }
  475. }
  476.  
  477. # Gets all the commands assocated with a extension
  478. # Example: shell_getCmds file.txt => {open print}
  479. proc shell_getCmds {file} {
  480.   set extension [file extension $file]
  481.   if {[catch {set fileType [registry get "HKEY_CLASSES_ROOT\\$extension" ""]} err_str]} {
  482.     puts $err_str; return; # No assocation or fileType
  483.      }
  484.   if {[catch {set cmds [registry keys "HKEY_CLASSES_ROOT\\$fileType\\shell"]} err_str]} {
  485.     puts $err_str return ; # No commands assocated with file Type
  486.      }
  487.   return $cmds
  488. }
  489.  
  490. # Gets the implimentation of command given a file extension
  491. # Example: shell_getCmd_imp test.txt open => C:\WINDOWS\NOTEPAD.EXE %1
  492. proc shell_getCmd_imp {file cmd} {
  493.   set extension [file extension $file]
  494.   if {[catch {set fileType [registry get "HKEY_CLASSES_ROOT\\$extension" ""]} err_str]} {
  495.     puts $err_str; return; # No assocation or fileType
  496.      }
  497.   if {[catch {set imp [registry get "HKEY_CLASSES_ROOT\\$fileType\\shell\\$cmd\\command" ""]} err_str]} {
  498.     puts $err_str return ; # No commands assocated with file Type
  499.      }
  500.   set ret $imp
  501.   return $ret
  502. }
  503.  
  504. # End of file extension association procedures for Windows.
  505.  
  506. # Export ::freewrap procedures
  507. set name {}
  508. set shortname {}
  509. foreach name [info commands ::freewrap::*] {
  510.       set shortname [string range $name 12 end]
  511.       if {[string equal -length 6 $shortname "shell_"]} {
  512.         # shell_ commands can only be used on Windows platforms
  513.         if {$tcl_platform(platform) == "windows"} {
  514.             namespace export $shortname
  515.            } { rename $name {} }
  516.          } { namespace export $shortname }
  517.     }
  518. unset name
  519. unset shortname
  520. }
  521.  
  522. #
  523. # end of ::freeWrap namespace definitions
  524.  
  525. proc newInfo {args} {
  526.     if {$args == {script} && $args != {}} {
  527.         return [lindex $::freewrap::scriptFile end]
  528.        } {
  529.         set cmd "::freewrap::infocmd $args"
  530.             set rc [catch {uplevel 1 $cmd} err]
  531.             if {$rc == 1} {
  532.               set ei [split ${::errorInfo} \n]
  533.               set eilen [llength $ei]
  534.               incr eilen -3
  535.               set line [lindex $ei $eilen]
  536.               incr eilen -1
  537.               set ::errorInfo [join [lrange $ei 0 $eilen] \n]
  538.               #regsub {.*body line ([0-9]*).*} $line {\1} line
  539.               #append ::errorInfo "\n    (file \"$filename\" line $line)"
  540.             } elseif {$rc == 2} { set rc 0 }
  541.             return -code $rc -errorinfo ${::errorInfo} -errorcode ${::errorCode} $err
  542.          }
  543. }
  544.  
  545.  
  546. # Establish proper freeWrap program name for the operating system
  547. # The extname variable is set from the main.c or tclAppInit.c code.
  548. switch $tcl_platform(platform) {
  549.       "unix"    { set ::freewrap::progname "freewrap$extname" }
  550.       "windows"    { set ::freewrap::progname "freewrap[string toupper $extname].exe" }
  551.        default    {
  552.               if {[info exists tk_patchLevel]} {
  553.                         tk_messageBox -parent . -icon warning -type ok -title "freeWrap$extname" -message "Sorry. freeWrap$extname is only supported on Unix and Windows."
  554.                        } { puts "freeWrap$extname: Sorry. freeWrap$extname is only supported on Unix and Windows." }
  555.                     exit 4
  556.             }
  557.      }
  558.  
  559.  
  560. # re-define the INFO command
  561. rename info ::freewrap::infocmd;rename newInfo info
  562.  
  563. # Adjust auto_path variable. Strip out unwanted default paths.
  564. global auto_path
  565. global blt_library
  566.  
  567. set newpath {}
  568. foreach path $auto_path {
  569.     set prefix [string range $path 0 3]
  570.     if {$prefix == {/tcl} || $prefix == {/tk}} {
  571.         lappend newpath $path
  572.        }
  573.       }
  574. set auto_path $newpath
  575. if {$extname == {blt}} {
  576.     lappend auto_path {/blt}
  577.     set blt_library {/blt}
  578.    }
  579.  
  580. # remove variables that are no longer necessary
  581. unset newpath
  582. unset path
  583. unset prefix
  584. unset extname
  585.  
  586. # Load the main application script.
  587. if {[::zvfs::exists /_freewrap_init.txt]} {
  588.     set fin [open /_freewrap_init.txt r]
  589.     gets $fin mainfile
  590.     close $fin
  591.     unset fin
  592.         set mainfile [string trim $mainfile]
  593.       if {[string index $mainfile 1] == {:}} { set mainfile [string range $mainfile 2 end] }
  594.         if {[string index $mainfile 0] != {/}} { set mainfile /$mainfile }
  595.         if {$mainfile != {freewrap.tcl}} { set tcl_interactive 0 }
  596.         if {[catch {source $mainfile} rtnval]} {
  597.             catch {console show}
  598.             puts "Error sourcing $mainfile: $rtnval"
  599.            } {
  600.               if {[info exists mainfile]} {
  601.             if {[file tail $mainfile] == "freewrap.tcl"} {
  602.                 _freewrap_main
  603.                 rename _freewrap_main ""
  604.                }
  605.             unset mainfile
  606.              }
  607.               if {![info exists tk_patchLevel] && $tcl_interactive == 0} {
  608.             exit 0
  609.              }
  610.              }
  611.    } {
  612.       catch {console show}
  613.       puts "freeWrap configuration file (_freewrap_init.txt) not found.\nUnable to determine which script to run."
  614.      }
  615.  
  616.