#!/bin/sh
# the next line restarts using wish \
exec wish "$0" "$@"
#  TkZip  Copyright  1996, 2002 by Robert Woodside.
#  A Tcl/Tk program for managing zipped & tarred archives

#-------------------------------------------------
#            Set a few globals
#-------------------------------------------------
set PgmName "TkZip"
set Copy "Copyright  1996, 2002 by Robert Woodside."
set TkzVer 1.1.4
set TkzDate 11/19/2002
set TkzTime 23:37:34
set Debugon 0
#set AuthEmail "root@localhost"
set AuthEmail "tkzip@woodsway.com"
set PgmNamelc "tkzip"
set TkzG(Windows) 0
set TkzG(Crippled) 0
if [info exists embed_args] {
  set TkzG(Crippled) 1
  set TkzG(Plugin) 1
  }  else  {
  set TkzG(Plugin) 0
  }
if [catch {set TclVer $tcl_version}]  {set TclVer 0.0}
if [catch {set TkVer $tk_version}]  {set TkVer 0.0}

set StartDir [pwd]
if {! $TkzG(Crippled)}  {
  if [info exists env(HOME)] {
    set Home $env(HOME)
    }  else  {
    set Home [pwd]
    }
  }  else  {
  set Home [pwd]
  }
set MyPid [pid]

#  Doesn't work under 4.0, dammit!
if {$TkVer > 4.0} {
  set OsName $tcl_platform(os)
  set OsVer $tcl_platform(osVersion)
  }  else  {
  if [catch {set OsName [exec uname -s]}]  {set OsName "Unknown System"}
  if [catch {set OsVer [exec uname -r]}]  {set OsVer "Unknown Version"}
  }
if {$TkVer >= 8.0}  {
  set TkzG(Portable) 1
  }  else  {
  set TkzG(Portable) 0
  }
if {[string first "Windows" $OsName] != -1}  {
  set TkzG(Windows) 1
#  RBW - 1.0.15 - follow the general practice
#  However, for NT we should really use a user dir for this.
#  Also, should we automatically move stuff from releases earlier than 1.0.15?
#  set Home "C:/"
  set Home "C:/Program Files/$PgmName/"
  if {! $TkzG(Portable)}  {
    #  We won't try to support WinDOG on older Tk releases...
    set TkzG(Crippled) 1
    }
  }
#  RBW 07/21/1999 1.0.13 - fix Home == "/" problem...
if {$Home == "/"}  {
  set Home ""
  }
if {! $TkzG(Windows)}  {
  if [catch {set TkzG(WhoIAm) [exec id -un]}]  {set TkzG(WhoIAm) ""}
  #  This causes problems on too many different systems to be worth 
  #  the trouble...
#  if [catch {set TkzG(WhereIAm) [exec hostname -f]}] {set TkzG(WhereIAm) ""}
  set TkzG(WhereIAm) ""
  set TkzG(DfltCache) $Home
  set TempDir "$Home/.$PgmName$MyPid"
  }  else  {
  set TkzG(WhoIAm) ""
  set TkzG(WhereIAm) ""
  set TkzG(DfltCache) "C:/Temp"
  set TempDir "C:/Temp/$PgmName$MyPid"
#puts "...setting TempDir = $TempDir."
  }
set TkzG(CacheDir) $TkzG(DfltCache)
#if {$TkzG(Windows)}  {
#  set TkzG(CacheDir) "C:/Temp"
#  }
# Temp for Win testing...
# puts "    ...we set TempDir = $TempDir...  Why?"





#-------------------------------------------------
#  Init  --  Initialization
#-------------------------------------------------
proc Init {} {
global argc argv env
global PgmName TclVer TkVer Home TempDir InitFile
global MainBg MainFg MainButBg WhoBg TBg TButBg TButFg TFg
global CurDir ExtDir TgzLstFlags TgzExtFlags ArcTypes
global FTypes RTypes RawDev ArcWin DirWin ExtWin TmpNo
global ArcPgm UnarcPgm ArcFlags ListFlags ExtFlags VNames VBins VNum
global GotTar GotGtar GotGzip GotZip GotZcat GotCompress GotPgmFlags NeededPgmFlags
global GotAr GotArj GotRar GotShn GotBzip GotBzip2 GotLha GotCpio GotRpm 
global GotPgmFlags2 NeededPgmFlags2 NeededPgmFlags3
global ForceStat MenuHelp ShDesperation ShIgnITG ShNoProbe
global MyPid ErrArgs GtRel XsetResp
global MainSelected
global VDWarn ADWarn MDWarn
global WinList FLList 
global ExtDirs
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global DSlidBg NumWins SpecWinFirst SpecWinLast
global StartDir RarVer PagePrg ViewButtons
global MimeNum MimeTags MimeExtns MimeTypes MimeViewers 
global clicky clicky1 clicky2 clickybg1 clickybg2
global MimeEdit
global licreq RegGeom
global TkzVer TkzrcVer OptDir OptFile Button3VD HelpTrail HelpGeom HelpPos HelpNav
global Hex GotWhich
global UpgRel InstSrcDir InstDestDir IconsOk Installing ScrW ScrH
global InstBinDir TkzDir2 OsName DfltCfg ChgCache
global TkzG
set thisproc "Init"

#  I'm not really pleased with the icon business, since Tk doesn't
#  seem to grok transparent gifs... Slows startup down, but looks nicer.
#  This option will disable it. 
set TkzG(UseMainIcon) 1
set TkzG(TkzIcon) "TkZip01.gif"
#  Might want to make this a non-root user...
set TkzG(SysAdmin) "root"
#  Package installers *may* want to patch these...
if {! $TkzG(Windows)}  {
  set TkzG(TkzDir) "/usr/local/share/$PgmName"
  set InstBinDir "/usr/local/bin"
  }  else  {
  set tmp [pwd]
#  RBW - 1.0.15 - follow the general practice
#  set tmp "C:/$PgmName"
  set tmp "C:/Program Files/$PgmName"
  set TkzG(TkzDir) $tmp
  set InstBinDir $tmp
  }

#--------------------------------
#  Options for package installers to override the Autoinstall logic...
set TkzG(ForceInstall) 0
set TkzG(NoInstall) 0
set TkzG(RootInstall) 0
#--------------------------------
#  Only prompt sysadmin to install on new release...
if {$TkzG(WhoIAm) == "root" || $TkzG(WhoIAm) == $TkzG(SysAdmin)}  {
  set TkzG(InstallUpg) 1
  } else  {
  set TkzG(InstallUpg) 0
  }



#--------------------------------------------------
#  Nothing below here should need to be customized.
#--------------------------------------------------

#  Recognized archive types and raw archive device types
#  (A lot of people like names like "mystuff_tar.gz" - let's humor 'em....)
set FTypes ".tgz tar.z tar.Z tar.gz .zip .z .Z .tar .gz .taz .exe .a .rar .arj .shn .bz .bz2 .lzh .rpm .deb .jar"
set RTypes "fd ftape rft rmt st nft nrft nrmt nst"
# obsolete...?
# set ATypes "1 3 5 2 4 6 0   8 9 10 11 12"

set RawDev 0
set GotWhich 0

SetDefaultColors
SetDefaultScroll
#  For future use...
set DfltCfg 0
##------------------------------------------
##  The slider sizes
#set TkzG(TrW) 12
#set TkzG(TrEBw) 3
#set TkzG(TrHTh) 1
##  The default slider color - a charcoal grey
#set DSlidBg "#202030"
##------------------------------------------
#  If this is an 8-bit display, some of the default colors will look pretty awful.
#  The alternates are crappy, too, but should be legible. We'll add a color 
#  selection dialogue later.
set tmp ""
#  Old way seems to fail on some newer systems (like mine)
#catch {set tmp [exec xset q]}
#  Non-portable...
set tmp ""
if {! $TkzG(Windows)}  {
  set rc [catch {exec xset q} XsetResp]
  }
#  Just save the whole response
#  Not sure how far back the visual info was implemented...
set TkzG(TheVisual) ""
set TkzG(ColorBits) ""
if {! [ catch {set TkzG(TheVisual) [winfo visual .]}]}  {
  set visavail [winfo visualsavailable .]
  set l1 [string first $TkzG(TheVisual) $visavail]
  while {[string index $visavail $l1] != " "}  {
    incr l1
    }
  while {[string index $visavail $l1] == " "}  {
    incr l1
    }
  set l2 [string first "\}" [string range $visavail $l1 end]]
  incr l2 [expr $l1 -1]
  set TkzG(ColorBits) [string range $visavail $l1 $l2]
  }
#  Old way fails on some systems
#  catch {set TkzG(fileprobe) [exec file -v]}
  set rc [catch {exec file -v} TkzG(fileprobe)]
  #  See if they have a working which...
  set rc [catch {exec which which} whichprobe]
  if {[string first "/which" $whichprobe] != -1}  {
    set GotWhich 1
    }


set TkzG(InitFlag) 0
set TkzG(Debug) 0
set TkzG(Debugi) 1
set TkzG(Debugl) 0
set TkzG(OpenStartDir) 0
set TkzG(PipeIn) 0
set DfltDir $Home
set CurDir $Home
set ExtDir "/tmp"
set ChgCache 0

set licreq 0
set TkzG(Licensed) 0
if {! $TkzG(Windows)}  {
  set TkzG(NavLinks) 1
  }  else  {
  set TkzG(NavLinks) 0
  }
set WinList ""
set FLList ""
set TkzG(ArcOnly) 0
set TmpNo 0
set ArcWin 0
set DirWin 0
set ExtWin 0
set TkzG(NoMainWin) 0
set TkzG(StartIconic) 0
set TkzG(LastCloseExits) 0

set TkzrcVer "0.0.0"
set UpgRel 0
set TkzG(Lser) ""
set IconsOk 0
set Installing 0
set TkzG(StartWarn) 0
set TkzG(CldFlag) 1
set TkzG(CleFlag) 1
set TkzG(DseFlag) 1
set TkzG(SavOpt) 0
set TkzG(StdNames) 1
set TkzG(GnuLin) 0
set TkzG(ShnHeur) 1
set TkzG(FastClean) 0
set TkzG(MultView) 0
set TkzG(Vpn) 0
set TkzG(CompOpt) 0
set ExtDirs 1
set TkzG(UsePager) 1
set TkzG(IntView) 1
set MimeNum 0
set TkzG(Mime4All) 0
set TlzG(DV4All) 0
set MimeEdit 0
set Button3VD 0
set HelpTrail ""
set HelpGeom ""
set HelpPos 0
set HelpNav 0
set clicky "red"
set clicky1 "Red4"
set clickybg1 "#fee0d8"
set clicky2 "Green4"
set clickybg2 "#e0fed8"
#  12/14/1999 - added hacks for some Win98 brain damage...
if {$TkzG(Windows)}  {
  set TkzG(FixFont) "Courier"
  set TkzG(DirHdFont) "Courier"
  set TkzG(NonameFont) "Courier"
  set TkzG(SwissFont) "Arial"
  set TkzG(RomanFont) "Times"
  set TkzG(Pt12) 120
  set TkzG(SlantO) "I"
  }  else  {
  set TkzG(FixFont) "fixed"
  set TkzG(DirHdFont) "fixed"
  set TkzG(NonameFont) "*"
  set TkzG(SwissFont) "Helvetica"
  set TkzG(RomanFont) "Times"
  set TkzG(Pt12) 120
  set TkzG(SlantO) "O"
  }
set TkzG(DrvLst)  ""

set TkzG(OvWarn) 1
set TkzG(OvOpt) 1
set ForceStat 0
#  1.1.0 - reversed this default.
set TkzG(Desperation) 0
set TkzG(IgnITG) 1
set TkzG(NoProbe) 0
set VDWarn 1
set ADWarn 1
set MDWarn 1
set TkzG(UseGtar) 1
set TkzG(PreferGtar) 1
set TkzG(GotGtar2) 0
set TkzG(GtarName) "tar"
set TkzG(TarIsGtar) 0
set TkzG(IgnDrvErr) 0
set RarVer 0
if {[string first "Linux" $OsName] == -1}  {
  set TkzG(EmUser) ""
  set TkzG(EmHost) ""
  }  else  {
  set TkzG(EmUser) $TkzG(WhoIAm)
  set TkzG(EmHost) $TkzG(WhereIAm)
  }

set TkzG(SysAdmp) 0
set TkzG(SysAdmp1) 0
set TkzG(Licensee) ""
set TkzG(LicenseNumber) 0
set TkzG(LicenseUsers) 0
set ViewButtons ""
#set OptDir "$Home/.TkZip"
#set OptFile "$OptDir/TkZip.rc"
if {! $TkzG(Windows)}  {
  set OptDir "$Home/.$PgmName"
  }  else  {
  set OptDir "$Home$PgmName"
  }
set OptFile "$OptDir/$PgmName.rc"
set RegGeom ""
#  One of these days this BSD-ism ought to 
#  be customized for SysV-ish systems...
set TkzG(PrtCmd) "lpr"
#  I think IRIX still has both, not sure what AIX uses...
#  we'll refine this later.
if {$OsName == "Solaris" || $OsName == "HP-UX" \
    || $OsName == "IRIX" || $OsName == "AIX"}  {
  set TkzG(PrtCmd) "lp"
  }

#  The shadow flag hack...
set MenuHelp 0
set ShDesperation $TkzG(Desperation)
set ShIgnITG $TkzG(IgnITG)
set ShNoProbe $TkzG(NoProbe)
set ShCompOpt $TkzG(CompOpt)

#  The context-sensitive help hack...
#  because we can't bind button-3 events to the menubuttons as they're
#  currently implemented, we have to do everything the hard way, pretending
#  that inactive buttons are greyed out.
set MainSelected 0

if {$TkVer <= 3.6} {
  set oldtkv36 1
  }  else {
  set oldtkv36 0
  }
#  Someday we'll put in support for old versions...maybe.
#  01/20/1996 - Oh, no we won't. Not since 8.0 is out - that old stuff's just too old now.
if {$oldtkv36} {
  puts "$PgmName version $TkzVer will not run under Tcl/Tk release $TclVer/$TkVer."
  exit
  }

#  New stuff for image manipulation...
set i 0
while {$i < 16}  {
  set Hex($i) [string range "0123456789abcdef" $i $i]
  incr i
  }


ParseArgs

# Temp for Win testing...
# puts "Init:  About to create TempDir = $TempDir"
if {! $TkzG(Crippled)}  {
  if {$TkzG(Portable)}  {
    #  i.e., 8.0 builtins, works on Unix & non-Unix...
    catch {file mkdir $TempDir}
    }  else  {
    catch {exec mkdir $TempDir}
    }
  }
if { [info exists env(PAGER)] } {
  set PagePrg $env(PAGER)
  }  else  {
  set PagePrg ""
  }
set ScrW [winfo screenwidth .]
set ScrH [winfo screenheight .]

#  See whether necessary pgms are present -
set TkzG(NeededPgms) "tar (Gnu-tar) zip gzip compress"
set NeededPgmFlags "GotTar GotGtar GotZip GotGzip GotCompress"
set TkzG(GotPgms) ""
set TkzG(NoGotPgms) ""

set TkzG(NeededPgms2) "zcat ar unarj unrar shorten"
set NeededPgmFlags2 "GotZcat GotAr GotArj GotRar GotShn"
set TkzG(GotPgms2) ""
set TkzG(NoGotPgms2) ""

set TkzG(NeededPgms3) "bzip bzip2 lha cpio rpm"
set NeededPgmFlags3 "GotBzip GotBzip2 GotLha GotCpio GotRpm"

set sysinfo "$TempDir/TkzSysinfo"

#  The default viewer list -
set VNum 11
set VNames(1) "Xless"
set VBins(1) "xless"
#set VNames(2) "CRiSP"
#set VBins(2) "mcr"
set VNames(2) "Nedit"
set VBins(2) "nedit"
set VNames(3) "Textedit"
set VBins(3) "textedit"
set VNames(4) "Emacs"
set VBins(4) "emacs"
set VNames(5) "Bradley's Famous XV"
set VBins(5) "xv"
set VNames(6) "Netscape"
set VBins(6) "netscape"
set VNames(7) "Mosaic"
set VBins(7) "mosaic"
set VNames(8) "Amaya"
set VBins(8) "amaya"
#set VNames(9) "TkZip"
#set VBins(9) "TkZip"
set VNames(9) "$PgmName"
set VBins(9) "$PgmName"
set VNames(10) "Xhexedit"
set VBins(10) "Xhexed"
set VNames(11) "User defined"
set VBins(11) ""


if {$TkzG(Crippled)}  {
  set GotTar 0
  set GotGtar 0
  set GotZip 0
  set GotGzip 0
  set GotZcat 0
  set GotCompress 0
  set TkzG(NoGotPgms) "tar (Gnu-tar) zip gzip zcat compress"
  set TkzG(NoGotPgms2) "ar unarj unrar shorten bzip"
  return 1
  }

#  OK, all defaults have been set - here's where we look for user config 
LoadConfig
#===========================================
CheckLicense
CheckProgs
if {! $TkzG(Windows)}  {
  unset XsetResp
  }
#===========================================

set NewCache $TkzG(CacheDir)
#if {! $TkzG(Windows)}  {
set TkzG(CacheDir) $TkzG(DfltCache)
#}
CleanDirs
set TkzG(CacheDir) $NewCache
#  This is not good under Windows...
#  the cache dir by default goes in C:/Temp, not in $Home.
#  This needs to be reworked.
#  If the user previously had C:/ set for CacheDir in his rc
#  file, the real (/Temp) one will get wiped out by the 2nd
#  CleanDirs call. Maybe trying to clean out both isn't a good idea.
#
#if {! $TkzG(Windows)}  {
if {$TkzG(CacheDir) != $TkzG(DfltCache)}  {
  SetCacheDir
  set sysinfo "$TempDir/TkzSysinfo"
  CleanDirs

  }
#}

#  This is as far as the WinDOG logic goes, so far...
#if {$TkzG(Windows)}  {
#  return 1
#  }

SetPager
SetIntView

#  No longer useful - windows have all been restructured to fit
#  In case screen is too small...
#set minw 800
#set minh 800
#if {$ScrW < $minw || $ScrH < $minh}  {
#  set TkzG(StartWarn) 1
#  wm iconify .
#  set ErrArgs "$ScrW $ScrH"
#  GErrMsgBox 71
#  update idletasks
#  }

#  New Autoinstall code...
#  Ok, we should be fully functional...
#  Check here whether we need to do an install or upgrade/install.
#
CheckInstall
#CheckLicense
#
#  Ok, in case they tried to set SysAdmin priv via cmd line,
#  make sure it's legal...
if {$TkzG(WhoIAm) != $TkzG(SysAdmin) && $TkzG(WhoIAm) != "root"}  {
  set TkzG(SysAdmp) 0
  set TkzG(SysAdmp1) 0
  }  else  {
  set TkzG(SysAdmp1) 1
  }

#  Then, we should probably create the images here, if needed, so
#  everything else will be much faster.
#
BuildIcons


#  If we couldn't check visual, don't try this stuff...
if {$TkzG(ColorBits) == ""}  {
  set TkzG(ColorHack) 0
  } else {
  set TkzG(ColorHack) 1
  }
if {$TkzG(ColorHack)}  {
  if {$TkzG(ColorBits) > 16}  {
    set TBg        "LightGrey MediumSpringGreen DarkSeaGreen SteelBlue NavajoWhite DarkSlateGrey MistyRose4 red red   yellow RosyBrown CadetBlue sienna ForestGreen DarkSalmon IndianRed4 turquoise1 ForestGreen DarkSalmon turquoise1"
    set TButBg     "NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite NavajoWhite"
    }
  }
if {$InitFile == ""}  {
  if {$TkzG(OpenStartDir)}  {
    set CurDir $StartDir
    }  else  {
    if {! $TkzG(Windows)}  {
      set CurDir $Home
      }  else  {
      set CurDir "C:/"
      }
    }
  }
if {$TkzG(PipeIn)}  {
# Read the piped stdin into a temp file for main to open...
# - gotta keep this from dying if we have no stdin input.
# - shouldn't have to set DOS style eofchar, but it seems to 
#   be needed for some files (gzip whines, for one thing).
  set si "stdin"
  fconfigure $si -blocking no -translation binary
  set pipefile "$TempDir/TkzPipe"
  catch {set of [open $pipefile w]}
  fconfigure $of -eofchar "\x1a" -buffering none
#  fconfigure $of -buffering none
#  fconfigure $of -translation binary
  set rc 0

  while {$rc != -1}  {
    if [catch {gets $si line} rc]  {
      set rc -1
      }
    if {$rc != -1}  {
      catch {puts $of "$line"}
      }
    }
#fcopy $si $of
  catch {close $of}
  }


return 1
}


#----------------------------------------------------
#  CheckProgs   --  See if needed pgms exist
#----------------------------------------------------
proc CheckProgs {} {
global TkzG ScrW ScrH XsetResp
global GotTar GotGtar GotGzip GotZip GotZcat GotCompress GotPgmFlags NeededPgmFlags
global GotAr GotArj GotRar GotShn GotBzip GotBzip2 GotLha GotCpio GotRpm 
global GotPgmFlags2 NeededPgmFlags2 NeededPgmFlags3
global RarVer GtRel TempDir TclVer TkVer GotWhich

set sysinfo "$TempDir/TkzSysinfo"
#  Let's hope this catches most tars... 
#    we'll need user feedback on this one.
set NL "\n"
catch {set si [open $sysinfo a+]}

#  Add a couple of useful pieces of info...
catch {puts $si "\n================\nXserver probe response:\n    $XsetResp\n================\n"}
# catch {puts $si "\n================\nWhitePixel value:\n    $TkzG(WhitePixel)\n================\n"}
catch {puts $si "\n================\nVisual:\n    $TkzG(TheVisual)  -  $TkzG(ColorBits) bits\n================\n"}
catch {puts $si "\n================\nScreen Resolution:\n    $ScrW x $ScrH\n================\n"}
catch {puts $si "\n================\nTcl/Tk version:\n    $TclVer/$TkVer\n================\n"}
catch {puts $si "\n================\nFile probe response:\n    $TkzG(fileprobe)\n================\n"}
if {$TkzG(Licensed)}  {
  catch {puts $si "\n================\nLicensed to:\n       $TkzG(Licensee)"}
  catch {puts $si "License Number:\n    $TkzG(LicenseNumber)"}
  catch {puts $si "Licensed Users:\n    $TkzG(LicenseUsers)\n================\n"}
  }


set bitbucket "/dev/null"
if {$TkzG(Windows)}  {
  set bitbucket "NUL"
  }
set GotGtar 0
set GtRel 0.0.0
set rc [catch {exec tar >$bitbucket} cc]
catch {puts $si "\n================\nTar probe response:\n    $cc\n================\n"}
# set cc [string tolower $cc]
if {[string first "tar" [string tolower $cc]] == 0 || [string first "Usage" [string tolower $cc]] != -1 || [string first "usage" [string tolower $cc]] != -1 \
  || [string first "must specify" $cc] != -1}  {
  set GotTar 1
  set TkzG(GotPgms) "tar"
  
  #  Test for Gnu Tar...
  set rc [catch {exec tar --version } cc]
  catch {puts $si "\n================\nGnu Tar probe response:\n    $cc\n================\n"}
  if {[string first "GNU" [string toupper $cc]] != -1}  {
    set GotGtar 1
    set TkzG(TarIsGtar) 1
    #  Gotta check for 1.12 since RMS's minions changed the rules on us...
    set i [string first "GNU TAR" [string toupper $cc]]
    incr i 7
    set tmps [string range $cc $i end]
    set i 0
    while {[string range $tmps $i $i] == " " || [string range $tmps $i $i] == ")"}  {
      incr i
      }
    set tmps [string range $tmps $i end]
    set tmps [lindex $tmps 0]
    set GtRel $tmps
    } else {
    set GotGtar 0
    set GtRel 0.0.0
    }
  } else {
  set GotTar 0
  set GotGtar 0
  set TkzG(NoGotPgms) "tar"
  }

#  Check for GNU tar under a pseudonym...
CheckGtar {si}


#  These guys are predictable & rational 
set rc [catch {set dummy [exec unzip -v ]} cc]
catch {puts $si "\n================\nUnZip probe response:\n    $cc\n================\n"}
if { [string first "UnZip" $cc] != -1 }  {
  set GotZip 1
  set TkzG(GotPgms) "$TkzG(GotPgms) zip"
  } else {
  set GotZip 0
  set TkzG(NoGotPgms) "$TkzG(NoGotPgms) zip"
  }
#  Change for gzip 1.3 - but still works for good ol' 1.2.4 as well. (They
#  switched to writing this response to stdout instead of stderr.)
#set rc [catch {exec gzip -V > $bitbucket} cc]
set rc [catch {exec gzip -V} cc]
catch {puts $si "\n================\nGzip probe response:\n    $cc\n================\n"}
if { [string first "gzip" $cc] == 0 } {
  set GotGzip 1
  set TkzG(GotPgms) "$TkzG(GotPgms) gzip"
  } else {
  set GotGzip 0
  set TkzG(NoGotPgms) "$TkzG(NoGotPgms) gzip"
  }
#  Don't even look for zcat under Windows...
if {! $TkzG(Windows)}  {
#  set rc [catch {exec echo "$NL" | zcat -V > $bitbucket} cc]
  set rc [catch {exec echo "$NL" | zcat -V} cc]
  catch {puts $si "\n================\nZcat probe response:\n    $cc\n================\n"}
  if {[string first "zcat" $cc] == 0 || [string first "Usage" $cc] != -1 || [string first "usage" $cc] != -1 || [string first "options" $cc] != -1}  {
    set GotZcat 1
    set TkzG(GotPgms) "$TkzG(GotPgms) zcat"
    } else {
    set GotZcat 0
    set TkzG(NoGotPgms) "$TkzG(NoGotPgms) zcat"
    }
  }  else  {
  set GotZcat 0
  set TkzG(NoGotPgms) "$TkzG(NoGotPgms) zcat"
  }
#  Right or wrong, under WinDOS we assume GNU uncompress...
if {! $TkzG(Windows)}  {
  set rc [catch {exec echo "$NL" | uncompress -V > $bitbucket} cc]
  }  else  {
  set rc [catch {exec uncompress -V > $bitbucket} cc]
  }
catch {puts $si "\n================\nCompress probe response:\n    $cc\n================\n"}
if {[string first "ompress" $cc] == 1 || [string first "ompress" $cc] == 3 || [string first "sage" $cc] != -1 || [string first "ption" $cc] != -1}  {
  set GotCompress 1
  set TkzG(GotPgms) "$TkzG(GotPgms) compress"
  }  else  {
  set GotCompress 0
  set TkzG(NoGotPgms) "$TkzG(NoGotPgms) compress"
  }
set GotPgmFlags "$GotTar $GotZip $GotGzip $GotZcat $GotCompress"

#catch {puts $si "\n================\nArchive Programs Found:\n    $TkzG(GotPgms)\nArchive Programs Not Found:\n    $TkzG(NoGotPgms)\n================\n"}
#catch {close $si}



#  Test for the new types...
set TkzG(GotPgms2) ""
set rc [catch {exec ar -V} cc]
catch {puts $si "\n================\nAr probe response:\n    $cc\n================\n"}
if {[string first "ar " $cc] != -1 || [string first "usage" $cc] != -1 || [string first "ersion" $cc] != -1}  {
  set GotAr 1
  set TkzG(GotPgms2) "$TkzG(GotPgms2) ar"
  }  else  {
  set GotAr 0
  set TkzG(NoGotPgms2) "$TkzG(NoGotPgms2) ar"
  }
set rc [catch {exec unarj} cc]
catch {puts $si "\n================\nArj probe response:\n    $cc\n================\n"}
if {[string first "UNARJ" [string tolower $cc]] != -1 || [string first "usage" [string tolower $cc]] != -1}  {
  set GotArj 1
  set TkzG(GotPgms2) "$TkzG(GotPgms2) arj"
  }  else  {
  set GotArj 0
  set TkzG(NoGotPgms2) "$TkzG(NoGotPgms2) arj"
  }
set rc [catch {exec unrar} cc]
catch {puts $si "\n================\nRar probe response:\n    $cc\n================\n"}
if {[string first "UNRAR" $cc] != -1 || [string first "usage" $cc] != -1}  {
  set tmp [lindex $cc 1]
  set tmp [string range $tmp 0 0]
  set RarVer $tmp
  set GotRar 1
  set TkzG(GotPgms2) "$TkzG(GotPgms2) rar"
  }  else  {
  set GotRar 0
  set TkzG(NoGotPgms2) "$TkzG(NoGotPgms2) rar"
  }
set rc [catch {exec shorten -h} cc]
catch {puts $si "\n================\nShorten probe response:\n    $cc\n================\n"}
if {[string first "shorten:" $cc] == 0 || [string first "usage" $cc] != -1}  {
  set GotShn 1
  set TkzG(GotPgms2) "$TkzG(GotPgms2) shorten"
  }  else  {
  set GotShn 0
  set TkzG(NoGotPgms2) "$TkzG(NoGotPgms2) shorten"
  }
set rc [catch {exec bzip -h} cc]
catch {puts $si "\n================\nbzip probe response:\n    $cc\n================\n"}
if {[string first "BZIP," $cc] != -1 || [string first "usage" $cc] != -1}  {
  set GotBzip 1
  set TkzG(GotPgms2) "$TkzG(GotPgms2) bzip"
  }  else  {
   set GotBzip 0
  set TkzG(NoGotPgms2) "$TkzG(NoGotPgms2) bzip"
  }
set rc [catch {exec bzip2 -h} cc]
catch {puts $si "\n================\nbzip2 probe response:\n    $cc\n================\n"}
if {[string first "bzip2," $cc] != -1}  {
  set GotBzip2 1
  set TkzG(GotPgms2) "$TkzG(GotPgms2) bzip2"
  }  else  {
  set GotBzip2 0
  set TkzG(NoGotPgms2) "$TkzG(NoGotPgms2) bzip2"
  }
set rc [catch {exec lha } cc]
catch {puts $si "\n================\nLHarc probe response:\n    $cc\n================\n"}
if {[string first "LHarc" $cc] != -1 || [string first "usage" $cc] != -1}  {
  set GotLha 1
  set TkzG(GotPgms2) "$TkzG(GotPgms2) lha"
  }  else  {
  set GotLha 0
  set TkzG(NoGotPgms2) "$TkzG(NoGotPgms2) lha"
  }
if {$GotWhich}  {
  set rc [catch {exec which cpio} cc]
  }  else  {
  set rc [catch {exec cpio } cc]
  }
catch {puts $si "\n================\ncpio probe response:\n    $cc\n================\n"}
if {$GotWhich}  {
  if {[string first "/cpio" $cc] != -1}  {
    set GotCpio 1
    set TkzG(GotPgms2) "$TkzG(GotPgms2) cpio"
    }  else  {
    set GotCpio 0
    set TkzG(NoGotPgms2) "$TkzG(NoGotPgms2) cpio"
    }
  }  else  {
  if {[string first " cpio " $cc] != -1 || [string first "Usage" $cc] != -1}  {
    set GotCpio 1
    set TkzG(GotPgms2) "$TkzG(GotPgms2) cpio"
    }  else  {
    set GotCpio 0
    set TkzG(NoGotPgms2) "$TkzG(NoGotPgms2) cpio"
    }
  }
#  RPM is useless if cpio isn't available...
#  Check what to test for...
set rc [catch {exec rpm --version } cc]
catch {puts $si "\n================\nrpm probe response:\n    $cc\n================\n"}
if {[string first "RPM " $cc] != -1 || [string first "sage:" $cc] != -1}  {
  set GotRpm 1
  set TkzG(GotPgms2) "$TkzG(GotPgms2) rpm"
  }  else  {
  set GotRpm 0
  set TkzG(NoGotPgms2) "$TkzG(NoGotPgms2) rpm"
  }

#  Obsolete...?  If not, it's out of sync.
set GotPgmFlags2 "$GotAr $GotArj $GotRar $GotShn $GotBzip $GotBzip2 $GotCpio $GotRpm"
catch {puts $si "\n================\nArchive Programs Found:\n    $TkzG(GotPgms) $TkzG(GotPgms2)\nArchive Programs Not Found:\n    $TkzG(NoGotPgms) $TkzG(NoGotPgms2)\n================\n"}
catch {close $si}


return 0
}


#----------------------------------------------------
#  CheckGtar   --  See if GNU tar has a special name
#----------------------------------------------------
proc CheckGtar {si} {
global TkzG
global GotTar GotGtar
global GtRel TempDir


if {$TkzG(GtarName) != "tar"}  {
  set rc [catch {exec $TkzG(GtarName) --version } cc]
  if {$si != ""}  {
    catch {puts $si "\n================\n2nd Gnu Tar probe response:\n    $cc\n================\n"}
    }
  if {[string first "GNU" [string toupper $cc]] != -1}  {
    set GotGtar 1
    set TkzG(GotGtar2) 1
    #  Gotta check for 1.12 since RMS's minions changed the rules on us...
    set i [string first "GNU TAR" [string toupper $cc]]
    incr i 7
    set tmps [string range $cc $i end]
    set i 0
    while {[string range $tmps $i $i] == " " || [string range $tmps $i $i] == ")"}  {
      incr i
      }
    set tmps [string range $tmps $i end]
    set tmps [lindex $tmps 0]
    set GtRel $tmps
    }  else  {
    set TkzG(GotGtar2) 0
    if {! $TkzG(TarIsGtar)}  {
      set GotGtar 0
      }
    }
  }


}


#----------------------------------------------------
#  CheckInstall   --  See if we need a new install
#----------------------------------------------------
proc CheckInstall {} {
global TkVer TkzVer StartDir PgmName UpgRel
global InstSrcDir InstDestDir InstDestRoot InstallFile IconsOk
global InstBinDir Installing GotWhich 
global TkzG CurDir
set thisproc "CheckInstall"

#  In case there was a file to open...
set SaveCur $CurDir
# Temp for Win testing...
# puts "$thisproc:  Entered - TkzDir = $TkzG(TkzDir)"
set InstDestDir $TkzG(TkzDir)
set i [string last "/$PgmName" $InstDestDir]
incr i -1
set InstDestRoot [string range $InstDestDir 0 $i]
set InstSrcDir $StartDir
set InstDirOk 0
set InstBinDir "/usr/local/bin"

if {$GotWhich}  {
  #  See if they have a working which...
  set rc [catch {exec which $PgmName} whichprobe]
  set ll1 [string first "/$PgmName" $whichprobe]
  if {$ll1 != -1}  {
    incr ll1 -1
    set InstBinDir [string trim [string range $whichprobe 0 $ll1]]
    #  In case current dir is in path and that's what we pick
    #  up, don't try to copy it to itself.
    if {$InstBinDir == "."}  {
      set InstBinDir "/usr/local/bin"
      }
    }
  }

#puts "Autoinstall:    "
#puts "    InstFile = $InstFile1 or $InstFile2"
#puts "     InstRoot = $InstDestRoot   SrcDir = $InstSrcDir"
if {[file exists $InstDestDir]}  {
  if {[file isdirectory $InstDestDir]}  {
#    puts "A-I:  found the install dir A-ok..."
    set InstDirOk 1
    }
  }
FindInstallFile

#  Different package distributions may have patched these variables 
#  at the front, if they prefer to handle installing...
set installit 0
#  Offer to install on release upgrade?
if {! $TkzG(NoInstall)}  {
  if {$TkzG(InstallUpg) && $UpgRel}  {
    set verrc "$InstDestDir/TkzVer.rc"
    if {[file exists $verrc]}  {
      LoadConfigFile $verrc
      if {[CheckVer]}  {
        set installit 1
        }
      }  else  {
      set installit 1
      }
    }
#  No extras directory, new install?
  if {! $InstDirOk}  {
    set installit 1
    }
  }
#  Force theinstall?
if {$TkzG(ForceInstall)}  {
  if {$TkzG(WhoIAm) == "root" || $TkzG(WhoIAm) == $TkzG(SysAdmin)}  {
    set installit 1
    }
  }
#  Finally...is install restricted to root?
#  Then don't pester the mere mortals.
if {$TkzG(RootInstall) && $TkzG(WhoIAm) != $TkzG(SysAdmin)}  {
  if {$TkzG(WhoIAm) != "root"}  {
    set installit 0
    }
  }

if {$installit}  {
  if {$TkzG(ForceInstall)}  {
    DoInstall "dummy"
    return
    }

  #  Install will do nasty things that are incompatible with
  #  --iconic or --nomain, so we have to force them off for now.
  set TkzG(NoMainWin) 0
  set TkzG(StartIconic) 0
  wm iconify .
  set Installing 1
  BuildInstallWin
#-----------------------------
#  if {$TkzG(ForceInstall)}  {
#    # Force install to default places if this is a new install?
#    # Then just do it, don't ask.
#    update idletasks
#    if [winfo exists .install.topf.but.inst] {
#       if {![file exists $InstBinDir/$PgmName]} {
#          .install.topf.but.inst invoke
#          update idletasks
#          update
#          }
#       }
#    if [winfo exists .install] {
#       tkwait window .install
#       }
#    }  else  {
#    tkwait window .install
#    }
#-----------------------------
  tkwait window .install
  }

set CurDir $SaveCur
return
}


#---------------------------------------------------------
#  BuildInstallWin   --  Build the install dialogue window
#---------------------------------------------------------
proc BuildInstallWin {} {
global MainBg MainFg MainButBg WhoBg ArcWin WinList
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg DSlidBg
global EntBg EntFg SelBg SelFg ScrW ScrH
global TkVer TkzVer StartDir PgmName UpgRel
global InstSrcDir InstDestDir InstDestRoot InstallFile IconsOk 
global InstBinDir
global TkzG

#----------------------------------
set WBg $TwBg(0)
set WButBg $TwButBg(0)
set WButFg $TwButFg(0)
set WEntBg $EntBg(0)
set WEntFg $EntFg(0)
set WSelBg $SelBg(0)
set WSelFg $SelFg(0)
set WFg $TwFg(0)
set lbg $TwLFg(0)
set lfg $TwLFg(0)
set WDisab "grey"
set TBBg "#fef8ec"
set lfg "black"
set minw 800
set minh 800
#----------------------------------

#  Make some unique names for us...
set thiswin "install"
set WinName ".$thiswin"
set owner $thiswin

if [catch {toplevel $WinName}] {
  raise $WinName
  } else {
  #  Build the window...

  set wintitle "$PgmName: Install"
  wm title $WinName $wintitle
  set topf [frame $WinName.topf -bg $WBg -highlightbackground $WBg]
  set headf [frame $topf.headf -bg $WBg -highlightbackground $WBg]
  set buttons [frame $topf.but -bg $WBg -highlightbackground $WBg]
  set tbody [frame $topf.tbody -bg $WBg -highlightbackground $WBg]
  set fbody [frame $topf.fbody -bg $WBg -highlightbackground $WBg]

#-------------------
  set cmd "KillInstall $owner"
  button $buttons.quit -text "Close" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
#  Gotta intercept wm killing the window with this command too
  wm protocol $WinName "WM_DELETE_WINDOW" $cmd
  wm protocol $WinName "WM_SAVE_YOURSELF" $cmd

  set cmd "SetInstallDir $owner 0"
  button $buttons.dest -text "Set Install Root" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  set cmd "SetInstallDir $owner 1"
  button $buttons.src -text "Set Source" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  set cmd "SetInstallDir $owner 2"
  button $buttons.bin -text "Set Binary Dir" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  set cmd "DoInstall $owner"
  button $buttons.inst -text "Install " -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg


  pack $buttons.quit $buttons.dest $buttons.src $buttons.bin $buttons.inst \
    -side left -padx 4 -pady 8
#-------------------


#-------------------
  frame $headf.edf1 -bg $WBg -highlightbackground $WBg
  frame $headf.edf2 -bg $WBg -highlightbackground $WBg
  frame $headf.edf3 -bg $WBg -highlightbackground $WBg
  frame $headf.edf4 -bg $WBg -highlightbackground $WBg
  frame $headf.edf5 -bg $WBg -highlightbackground $WBg

  label $headf.edf1.ddirl -bg $WBg -fg $WFg -text "Install Root:" -width 15
  entry $headf.edf1.ddire -bg $WEntBg -highlightbackground $WEntBg -fg $WEntFg -width 44 \
    -state normal -relief sunken -textvariable InstDestRoot
  label $headf.edf2.sdirl -bg $WBg -fg $WFg -text "Source Dir:  " -width 15
  entry $headf.edf2.sdire -bg $WEntBg -highlightbackground $WEntBg -fg $WEntFg -width 44 \
    -state normal -relief sunken -textvariable InstSrcDir
  label $headf.edf3.ifill -bg $WBg -fg $WFg -text "InstallFile: " -width 15
  entry $headf.edf3.ifile -bg $WEntBg -highlightbackground $WEntBg -fg $WEntFg -width 44 \
    -state disabled -relief sunken -textvariable InstallFile
  label $headf.edf4.bdirl -bg $WBg -fg $WFg -text "Binary Dir:  " -width 15
  entry $headf.edf4.bdire -bg $WEntBg -highlightbackground $WEntBg -fg $WEntFg -width 44 \
    -state normal -relief sunken -textvariable InstBinDir
  label $headf.edf5.cdirl -bg $WBg -fg $WFg -text "Current Dir: " -width 15
  entry $headf.edf5.cdire -bg $WBg -highlightbackground $WBg -fg $WFg -width 44 \
    -state disabled -relief flat -textvariable InstallFile -justify left \
    -font "-*-fixed-bold-*-*-*-*-*-*-*-*-*-iso8859-1"

  pack $headf.edf1.ddirl $headf.edf1.ddire \
    -side left
  pack $headf.edf2.sdirl $headf.edf2.sdire \
    -side left
  pack $headf.edf3.ifill $headf.edf3.ifile \
    -side left
  pack $headf.edf4.bdirl $headf.edf4.bdire \
    -side left
  pack $headf.edf5.cdirl $headf.edf5.cdire \
    -side left -anchor w

  pack $headf.edf5 -side bottom -fill x -pady 4 -pady 6 -expand yes
  pack $headf.edf4 -side bottom -fill x -pady 4 -pady 2 -expand yes
  pack $headf.edf3 -side bottom -fill x -pady 4 -pady 2 -expand yes
  pack $headf.edf2 -side bottom -fill x -pady 4 -pady 2 -expand yes
  pack $headf.edf1 -side bottom -fill x -pady 4 -pady 2 -expand yes
#-------------------


#-------------------
  text $tbody.txt
  scrollbar $tbody.sby
  $tbody.txt tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
  $tbody.txt tag configure heading \
    -font -*-$TkzG(SwissFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* -justify center
  $tbody.txt tag configure bold \
    -font -*-$TkzG(SwissFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-* 
  $tbody.txt tag configure boldred \
    -font -*-$TkzG(SwissFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-* -foreground "red"

  set text "\n"
  $tbody.txt insert end $text
  set text "Installing $PgmName"
  $tbody.txt insert end $text heading
 
  set text "\n\n    To install $PgmName, set the \"Install Root\", \"Source Dir\",\
    and \"Binary Dir\"\
    fields to your satisfaction, then click the \"Install\" button."
  $tbody.txt insert end $text 

  set text " Shared users: "
  $tbody.txt insert end $text boldred
  set text "do not try to install before reading the Note for Shared Users below."
  $tbody.txt insert end $text


  set text "\n    You may type\
    the directory names directly into the fields, or use the file/directory list\
    to select the directories.Clicking the \"Set Install Root\", \"Set Source\",\
    or \"Set Binary Dir\" buttons will set the appropriate field to the currently\
    selected (highlighted) directory; if no directory is selected, the current\
    directory will be used. If you entered an invalid directory path, or the source\
    directory is set to a directory that does not contain a copy of the install file\
    (see below), the field in error will be highlighted in red when you click\
    \"Install\".\
    \n    Install Root is a directory in which $PgmName will create a subdirectory\
    called $PgmName, where it will store miscellaneous files like icons and the\
    README file.\
    \n    Source Directory is the directory where $PgmName can find its original\
    distribution file. If you followed the directions in the README, you should\
    have unpacked this archive and executed $PgmName from the directory where you\
    unpacked it, so $PgmName should already have located this directory and the\
    Install File.\
    \n    Install File is the name of the file from which $PgmName will install. It may\
    be either the original distribution file, or the $PgmName Extras file that\
    was extracted from it. You cannot enter this field: when you set a Source\
    Directory in which $PgmName finds an install file, it will fill this in\
    automatically.\
    \n    Binary Directory is where $PgmName will install the executable. Set this field\
    to null if you do not wish the binary to be installed automatically.\
    \n    If you just click \"Close\" without installing, nothing terrible will happen,\
    and $PgmName will finish starting up.\
    $PgmName will run without installing, but certain features may be missing.\
    As of Release $TkzVer, that simply means that all bitmaps, like the logo icon\
    in the main window, will be replaced by simple text. It also means that you'll\
    see this annoying window every time you start it up.\
    \n\n"
  $tbody.txt insert end $text 

  set text "    Important Note on Older Releases: "
  $tbody.txt insert end $text bold
  set text "Running releases earlier than 0.9.6 will delete your \
    new style configuration file directory (releases 0.9.6 and later).\
    Earlier versions think this is a stale cache directory that needs to be cleaned\
    up, so the next time you run the current version of $PgmName, you will be prompted to\
    install again.\n"
  $tbody.txt insert end $text 

  set text "    Note for Shared Users: "
  $tbody.txt insert end $text bold
  set text "If your System Administrator has already installed $PgmName, do not\
    try to install it. Simply set the Install Root field to the location where your\
    Sysadmin has placed the $PgmName common directory, then click \"Close\". This will\
    update your private configuration file to point to the shared directory.\n\n"
  $tbody.txt insert end $text 

  set ycmd "$tbody.sby set"
  $tbody.txt configure -bg $TBBg -fg $lfg -wrap word -state disabled \
    -yscroll $ycmd  -height 10
  set ycmd "$tbody.txt yview"
  $tbody.sby configure -command $ycmd 

  pack $tbody.txt -side left -fill both -expand yes
  pack $tbody.sby -side right -fill y -expand yes

  ConfigureScrollbar $tbody.sby 0 0
#-------------------


#-------------------
  set flbody "$thiswin.topf.fbody"
  set dummy [BuildDirList "$flbody"]

  set where [pwd]
  set cradir "CraDir$flbody"
  global $cradir
  set $cradir $where
  set cmd "UpdCraDir $flbody"
  bind $fbody.list1.dirlist <Double-1> $cmd
  $fbody.list1.dirlist configure -selectmode browse \
    -selectbackground $WSelBg -selectforeground $WSelFg
  $fbody.list2.arclist configure -selectmode single \
    -selectbackground "white" -selectforeground "black" -selectborderwidth 0
  set cmd "FindInstallFile"
  bind $headf.edf2.sdire <Return> $cmd
  $headf.edf5.cdire configure -textvariable $cradir

  set $cradir [UpdDirList "$flbody" "$where"]
#-------------------

  pack $fbody -anchor w -fill x -side bottom -fill both -expand yes
  pack $tbody -side bottom -fil both -expand yes
  pack $headf -side bottom -anchor w -fill x -expand no
  pack $buttons -side bottom

  pack $topf -side bottom -anchor center -expand yes -fill both

  #  Because the window is too big for some screens, shrink the
  #  default height of some widgets.
  $fbody.list1.dirlist configure -height 8
  $fbody.list2.arclist configure -height 8
  $tbody.txt configure -height 8

  }

if {$UpgRel}  {
  update idletasks
  set updmsg ".updaterc1"
  catch {raise $updmsg}
  }
if {$TkzG(StartWarn)}  {
  set stwarn ".smalscr1"
  catch {raise $stwarn}
  set stwarn ".smalscr2"
  catch {raise $stwarn}
  }

return
}


#----------------------------------------------------
#  SetInstallDir   --  A directory is seleced, set it
#----------------------------------------------------
proc SetInstallDir {owner func} {
global TkVer TkzVer StartDir PgmName UpgRel ScrW ScrH
global InstSrcDir InstDestDir InstDestRoot InstallFile IconsOk 
global InstBinDir
global TkzG

set ddire ".$owner.topf.headf.edf1.ddire"
set sdire ".$owner.topf.headf.edf2.sdire"
set bdire ".$owner.topf.headf.edf4.bdire"
set WBg "black"
set flist ".$owner.topf.fbody.list1.dirlist"
set cradir "CraDir$owner.topf.fbody"
global $cradir
set dirn1 [set $cradir]
if {$dirn1 == "/"}  {
  set dirn1 ""
  }
set l1 [$flist curselection]
if {$l1 == ""}  {
  set dirn "$dirn1/"
  if {[string range $dirn 0 0] == "/"}  {
    set dirn [string range $dirn 1 end]
    }
  set dirn1 ""
  }  else  {
  set dirn [string trim [$flist get $l1]]
  if {$dirn == "../"}  {
    if {$dirn1 == ""}  {
      return
      }  else  {
      set tmp [string last "/" $dirn1]
      incr tmp -1
      set dirn1 [string range $dirn1 0 $tmp]
      set dirn ""
      }
    }
  }

set ll1 [string length $dirn]
incr ll1 -2
set dirn [string range $dirn 0 $ll1]
set where [pwd]

switch  $func    {

  0         {
        if {$InstBinDir != "$dirn1/$dirn"}  {
          set InstDestRoot $dirn1/$dirn
          $ddire configure -fg $WBg
          }  else  {
          GErrMsgBox 61
          }
        }
  1         {
        set InstSrcDir $dirn1/$dirn
        $sdire configure -fg $WBg
        FindInstallFile
        }
  2         {
        if {$InstDestRoot != "$dirn1/$dirn"}  {
          set InstBinDir $dirn1/$dirn
          $bdire configure -fg $WBg
          }  else  {
          GErrMsgBox 61
          }
        }
  default   {
      set dummy $dirn1/$dirn
      }


  }


return
}


#----------------------------------------------------
#  FindInstallFile   --  Look for one of the possible
#    install files 
#----------------------------------------------------
proc FindInstallFile {} {
global TkVer TkzVer StartDir PgmName UpgRel 
global InstSrcDir InstDestDir InstDestRoot InstallFile IconsOk
global TkzG

set InstFile1 "$PgmName-$TkzVer.tar.gz"
set InstFile2 "$PgmName-$TkzVer.tar.Z"
set ExtrasFile1 "$PgmName-$TkzVer-Extras.tar"
set ExtrasFile2 "$PgmName-$TkzVer-Extras"
set InstallDir ""
set InstallFile ""

if {[file exists "$InstSrcDir/$ExtrasFile1"]}  {
  set InstallFile $ExtrasFile1
  }  else  {
  if {[file exists "$InstSrcDir/$InstFile1"]}  {
    set InstallFile $InstFile1
    }  else  {
    if {[file exists "$InstSrcDir/$ExtrasFile2"]}  {
      set InstallFile $ExtrasFile2
      }  else {
      if {[file exists "$InstSrcDir/$InstFile2"]}  {
        set InstallFile $InstFile2
        }
      }
    }
  }



}


#----------------------------------------------------
#  DoInstall   --  Ok, do it.
#----------------------------------------------------
proc DoInstall {owner} {
global TkVer TkzVer StartDir PgmName UpgRel
global InstSrcDir InstDestDir InstDestRoot InstallFile
global InstBinDir Installing ScrW ScrH Home ErrArgs
global GotTar GotGtar
global TkzG

set errs 0
set ddire ".$owner.topf.headf.edf1.ddire"
set sdire ".$owner.topf.headf.edf2.sdire"
set bdire ".$owner.topf.headf.edf4.bdire"
set InstSrcDir [string trim $InstSrcDir]
set InstDestRoot [string trim $InstDestRoot]
set InstBinDir [string trim $InstBinDir]

if {"$InstBinDir" == "$InstDestRoot"}  {
  GErrMsgBox 61
  return
  }
if {$InstallFile == ""}  {
  if {$owner != "dummy"}  {
    $sdire configure -fg "red"
    }  else  {
    puts "$PgmName:  Cannot install - the distribution file cannot be located."
    }
  return
  }
if {! [file isdirectory $InstDestRoot]}  {
  if {$owner != "dummy"}  {
    $ddire configure -fg "red"
    }  else  {
    puts "$PgmName:  Cannot install - the install directory $InstDestRoot does not exist."
    }

  return
  }
if {! [file isdirectory $InstSrcDir]}  {
  if {$owner != "dummy"}  {
    $sdire configure -fg "red"
    }  else  {
    puts "$PgmName:  Cannot install - the source directory $InstSrcDir does not\
      exist,\nor does not contain the distribution file."
    }

  return
  }
if {$InstBinDir != ""}  {
  if {! [file isdirectory $InstBinDir]}  {
    if {$owner != "dummy"}  {
      $bdire configure -fg "red"
      }  else  {
    puts "$PgmName:  Cannot install binary - directory $InstBinDir does not exist."
    }

    return
    }
  }

set rc 0
#set logfile "$Home/TkZip-Install-Log"
set logfile "$Home/$PgmName-Install-Log"
catch {set of [open $logfile a+]}
if {$TkzG(Portable)}  {
  set when [clock format [clock seconds] -format "%c %Z"]
  }  else  {
  set when [exec date]
  }

puts $of "             $PgmName Install Log"
puts $of "               Release $TkzVer"
puts $of "        $when\n"
set msg1 "Installing from $InstSrcDir/$InstallFile"
set msg3 "    Extras installed in $InstDestRoot/$PgmName"
if {$InstBinDir != ""}  {
  set msg4 "    $PgmName installed in $InstBinDir"
  }  else  {
  set msg4 "    ...not installing binary."
  }


set inner 0
cd $InstSrcDir
puts $of $msg1
if {[string first "Extras" $InstallFile] == -1}  {
  set InstallFile2 "$PgmName-$TkzVer-Extras.tar"
  if {[string first "gz" $InstallFile] == -1}  {
set msg2 "    - Extracting $InstallFile2 from $InstSrcDir/$InstallFile"
    set cmd "exec uncompress -c $InstSrcDir/$InstallFile | tar -x $InstallFile2"
    }  else  {
set msg2 "    - Extracting $InstallFile2 from $InstSrcDir/$InstallFile"
    set cmd "exec gzip -c -d $InstSrcDir/$InstallFile | tar -x $InstallFile2"
    }
  set rc [catch {eval $cmd} dummy] 
  if {! $rc}  {
    puts $of $msg2
    }
  set inner 1
  }  else  {
  set InstallFile2 $InstallFile
  }

set where [pwd]
cd $InstDestRoot
if {$TkzG(GotGtar2) && $TkzG(PreferGtar)}  {
  set arcpgm $TkzG(GtarName)
  }  else  {
  if {! $GotTar && $TkzG(GotGtar2)}  {
    set arcpgm $TkzG(GtarName)
    }  else  {
    set arcpgm "tar"
    }
  }
if {$GotGtar && $TkzG(UseGtar)}  {
  set cmd "exec $arcpgm -xf $InstSrcDir/$InstallFile2"
  }  else  {
  set cmd "exec $arcpgm xf $InstSrcDir/$InstallFile2"
  }
set rc [catch {eval $cmd} dummy]
cd $where
if {$inner}  {
  if {$TkzG(Portable)}  {
    catch {file delete -force $InstSrcDir/$InstallFile2}
    }  else  {
    catch {exec rm -f $InstSrcDir/$InstallFile2}
    }
  }
#DispArc $InstSrcDir $InstallFile2 0 0
if {! $rc}  {
  puts $of $msg3
  }  else  {
  incr errs
  puts "Error installing $InstDestRoot/$PgmName:\n   '$dummy'"
  puts $of "    Error installing $InstDestRoot/$PgmName:\n       '$dummy'"
  }

if {$InstBinDir != ""}  {
  if {$TkzG(Portable)}  {
    set cmd "file copy -force $PgmName $InstBinDir"
    }  else  {
    set cmd "exec cp $PgmName $InstBinDir"
    }
  set rc [catch {eval $cmd} dummy]
  }
if {! $rc}  {
  puts $of $msg4
  }  else  {
  incr errs
  puts "Error installing binary:\n   '$dummy'"
  puts $of "    Error installing binary:\n       '$dummy'"
  }

puts $of "Installation completed with $errs error(s).\n\n"

catch {close $of}
set ErrArgs [list $logfile]
GErrMsgBox 72

#  In case they changed the install dir...
if {$owner != "dummy"}  {
  SaveConfig
  KillInstall $owner
  }

puts "Installation of $PgmName Release $TkzVer complete - $errs error(s)."
set tags ""
DisplayList $logfile "$PgmName Install Log" 1 "" $tags


return
}


#----------------------------------------------------
#  KillInstall   --  Destroy the Install window
#----------------------------------------------------
proc KillInstall {owner} {
global PgmName InstDestRoot ScrW ScrH ScrWarn
global TkzG

#  In case they changed the install dir...
set TkzG(TkzDir) $InstDestRoot/$PgmName

PluckFromList $owner "FLList"
destroy ".$owner"
SaveConfig

}


#----------------------------------------------------
#  CheckLicense   --  Check the Licensee file to see
#    if this is a licensed copy.
#    (This should probably be called immediately
#    after LoadConfig)
#----------------------------------------------------
proc CheckLicense {} {
global TkzG CurDir

#  If unlicensed, Licensee = "", LicenseNumber = 0, LicenseUsers = 0
set lfile1 "$TkzG(TkzDir)/License"
set lfile2 "$TkzG(TkzDir)/Licensee"
  if {[file exists $lfile2]}  {
    #  Read the Licensee file and set the vars...
    set TkzG(Licensed) 1
    LoadConfigFile $lfile2
    }
if {$TkzG(Licensed)}  {
  #  Make sure the Licensee and License2 files are read-only...?
  #  If root, make them so; if not, whine?

  }  else  {

  }

return
}



#----------------------------------------------------
#  BuildIcons   --  Build any icons we'll use
#----------------------------------------------------
proc BuildIcons {} {
global TkVer UpgRel InstSrcDir InstDestDir IconsOk 
global TkzG

#  Do we use an icon for the logo?
set IconX 56
set IconY 46
#  Say 4.0 for testing...may be 4.1, I've lost my 4.0 Tk...
if {$TkVer >= 4.0 && [file exists $TkzG(TkzDir)/$TkzG(TkzIcon)] \
    && [file exists "$TkzG(TkzDir)/lbutton"] && [file exists "$TkzG(TkzDir)/rbutton"]}  {
  set IconsOk 1
  if {$TkzG(UseMainIcon)}  {
    image create photo Tmplogo -width $IconX -height $IconY \
        -file "$TkzG(TkzDir)/$TkzG(TkzIcon)"
    image create photo TkzLogo -width $IconX -height $IconY
    TransPic "Tmplogo" "TkzLogo"
    image delete Tmplogo
    }
  image create bitmap BakBut -file "$TkzG(TkzDir)/lbutton" -foreground "grey"
  image create bitmap ForBut -file "$TkzG(TkzDir)/rbutton" -foreground "grey"
  }  else  {
  set IconsOk 0
  }

return
}



#----------------------------------------------------
#  SetPager   --  Set PAGER use
#----------------------------------------------------
proc SetPager {} {
global PagePrg VNames VBins VNum VDWarn ViewButtons
global TkzG

set dummy "Dummy"
# If $PAGER is to be the default viewer, add it to the list now...
if {$TkzG(UsePager)}  {
  if {$PagePrg != ""}  {
    # See if it's already in the list...
    set i1 0
    set i2 1
    set i3 0
    while {$i1 < $VNum}  {
      incr i1
      if {$VBins($i1) != $PagePrg}  {
        continue
        }  else  {
        break
        }
      }
    if {$i1 == $VNum}  {
      incr VNum
      set i2 $VNum
      while {$i1 > 0}  {
        set VNames($i2) $VNames($i1)
        set VBins($i2) $VBins($i1)
        incr i2 -1
        incr i1 -1
        }
      set VNames(1) "\$PAGER"
      set VBins(1) $PagePrg
      }  else  {
      set tmpVN $VNames($i1)
      set tmpVB $VBins($i1)
      set i2 $i1
      incr i1 -1
      while {$i1 > 0}  {
        set VNames($i2) $VNames($i1)
        set VBins($i2) $VBins($i1)
        incr i2 -1
        incr i1 -1
        }
      set VNames(1) $tmpVN
      set VBins(1) $tmpVB
      }
    #  Now update any active menus...
    foreach buttons "$ViewButtons"  {
      set wn [string range "$buttons" 1 [expr [string last ".top.but" "$buttons"] - 1]]
      set menu "$buttons.selv.m"
      set i1 $VNum
      incr i1 -1
      while {$i1 > 0}  {
        $menu delete $i1
        incr i1 -1
        }
      while {$i1 < $VNum}  {
        incr i1
        $menu add radiobutton -label "$VNames($i1)" -command "SetViewer $wn $dummy $dummy $i1" \
            -indicatoron 0
        }
      }
    }
  }  else  {
  if {$VNames(1) == "\$PAGER"}  {
    # Otherwise, remove it if we've inserted it into the list
    # (suppress warnings for this one).
    set tmp $VDWarn
    set VDWarn 0
    DeleteViewer "Dummy" "Dummy" "Dummy" 1
    set VDWarn $tmp
    }
  }

return
}


#----------------------------------------------------
#  SetIntView   --  Set Up Internal Viewer Selection
#----------------------------------------------------
proc SetIntView {} {
global PagePrg VNames VBins VNum VDWarn ViewButtons GotWhich
global Home MimeEdit MimeNum MimeTags MimeExtns MimeTypes MimeViewers
global TkzG

#  This wasn't valid during startup...and wasn't really useful.
#if {$TkzG(IntView) && $TkzG(Mime4All)}  {
#  #  The first one of these set caused a MIME type load.
#  return
#  }
  
if {$MimeEdit}  {
  #  Edit already caused a load, don't overlay new stuff.
  set MimeEdit 0
  return
  }

if {$TkzG(IntView) || $TkzG(Mime4All)}  {
#  First one turned on, loads types.
  if {$MimeNum == 0}  {
#   No MIME types found...build a default list, if they have xv.
#   Otherwise, leave it empty.
    set GotXv 0
    set xvname "xv"
    if {$GotWhich}  {
      set rc [catch {exec which xv} dummy]
      if {[string first "/xv" $dummy] != -1}  {
        set GotXv 1
        set xvname $dummy
        }
      }  else  {
      set rc [catch {exec xv -help} dummy]
      if {[string first "Usage:" $dummy] != -1 && [string first "xv" $dummy] != -1}  {
        set GotXv 1
        }
      }
    if {$GotXv}  {
      set MimeTags(0) "pixmap"
      set MimeExtns(0) ".xpm"
      set MimeTypes(0) "image/x-xpixmap"
      set MimeViewers(0) "$xvname -visual default $*"
      set MimeTags(1) ""
      set MimeExtns(1) ".gif"
      set MimeTypes(1) "Giffy Picture"
      set MimeViewers(1) "xv"
      set MimeTags(2) "TIFF image"
      set MimeExtns(2) ""
      set MimeTypes(2) "image/tiff"
      set MimeViewers(2) "xv"
      set MimeNum 3
      }
    }
  LoadMimeTypes
  }  else  {
  UnsetIntView
  }

return
}


#----------------------------------------------------
#  UnsetIntView   --  Unset Internal Viewer Selection
#----------------------------------------------------
proc UnsetIntView {} {
global PagePrg VNames VBins VNum VDWarn ViewButtons 
global MimeNum MimeTags MimeExtns MimeTypes MimeViewers
global TkzG

if {! $TkzG(IntView) && ! $TkzG(Mime4All)}  {
  #  Both options off, kill MIME types.
  set i 0
  while {$i < $MimeNum}  {
    unset MimeTags($i)
    unset MimeTypes($i)
    unset MimeViewers($i)
    incr i
    }
  set MimeNum 0
  }

return
}


#--------------------------------------------------------------
#  LoadMimeTypes   --  Set the MIME types from the file, if any
#--------------------------------------------------------------
proc LoadMimeTypes {} {
global Home PgmName OptDir 
global MimeNum MimeTags MimeExtns MimeTypes MimeViewers
global TkzG

if {$TkzG(Crippled)}  {
  return 1
  }

#set mimefile "$OptDir/TkZip.mimetypes"
set mimefile "$OptDir/$PgmName.mimetypes"
if [ catch {set of [open $mimefile r]} ]  {
  SaveMimeTypes
  return
  }
while {[ gets $of line ] > -1}  {
  #  First, strip comments... 
  set ti [string first "#" $line]
  if {$ti != -1}  {
    if {$ti == 0}  {
      set line ""
      }  else  {
#      incr ti -1
#      set line [string range $line 0 $ti]
      }
    }
  set line [string trim $line]

  #  Now, identify our stuff... 
  if {[string first $PgmName $line] == 0}  {
    set ti [string first "*" $line]
    incr ti
    set line [string range $line $ti end]
    set ti [string first ":" $line]
    if {$ti > 0}  {
      set opt [string trim [string range $line 0 [expr $ti - 1] ] ]
      incr ti
      set val [string trim [string range $line $ti end] ]
      SetConfigOpt $opt $val
      #  End - we have an option name... 
      }
    #  End - it's one of ours... 
    }
  } 
catch {close $of}

set MimeNum 0
set alldone 0
while {! $alldone}  {
  if {! [info exists MimeTags($MimeNum)]}  {
    set alldone 1
    }  else  {
    incr MimeNum
    }
  }

return
}


#----------------------------------------------------
#  SaveMimeTypes   --  Save the MIME types
#----------------------------------------------------
proc SaveMimeTypes {} {
global Home PgmName MimeNum MimeTags MimeExtns MimeTypes MimeViewers OptDir
global TkzG

set thisproc "SaveMimeTypes"
#set mimefile "$OptDir/TkZip.mimetypes"
if {! $TkzG(Windows)}  {
  set mimefile "$OptDir/$PgmName.mimetypes"
  }  else  {
  set mimefile "$OptDir/$PgmName.mimetypes"
  }

set rc [catch {set of [open $mimefile w]} dummy]
# puts "$thisproc:  open rc = <$rc>   open response = <$dummy>"


set i 0
while {$i < $MimeNum}  {
  puts $of "$PgmName*MimeTags($i):            $MimeTags($i) "
  puts $of "$PgmName*MimeExtns($i):           $MimeExtns($i) "
  puts $of "$PgmName*MimeTypes($i):           $MimeTypes($i) "
  puts $of "$PgmName*MimeViewers($i):         $MimeViewers($i) "
  incr i
  }


catch {close $of}

return
}


#----------------------------------------------------
#  EditMimeTypes   --  Edit the MIME types list
#----------------------------------------------------
proc EditMimeTypes {} {
global Home PgmName MimeNum MimeTags MimeExtns MimeTypes MimeViewers
global TempDir MyPid ErrArgs MenuHelp
global MainBg MainFg MainButBg WhoBg ArcWin WinList
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg DSlidBg
global EntBg EntFg SelBg SelFg
global MimeNum MimeEdit mimet mimev mimeex mimetag
global TkzG



if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 47
  return 1
  }

if {$MimeNum == 0}  {
  set MimeEdit 1
  LoadMimeTypes
  }

#--------------------------------------
set WBg $TwBg(0)
set WButBg $TwButBg(0)
set WButFg $TwButFg(0)
set WEntBg $EntBg(0)
set WEntFg $EntFg(0)
set WSelBg $SelBg(0)
set WSelFg $SelFg(0)
set WFg $TwFg(0)
set lbg $TwLBg(0)
set lfg $TwLFg(0)
set WDisab "grey"

set mimet ""
set mimev ""
set mimeex ""
set mimetag ""
#----------------------------------

#  Make some unique names for us...
set thiswin "mimetype"
set WinName ".$thiswin"
set owner $thiswin

if [catch {toplevel $WinName}] {
  raise $WinName
  } else {
  #  Build the window...

  set wintitle "$PgmName: Edit MIME Types"
  wm title $WinName $wintitle
  set topf [frame $WinName.topf -bg $WBg -highlightbackground $WBg]
  set headf [frame $topf.headf -bg $WBg -highlightbackground $WBg]
  set buttons [frame $topf.but -bg $WBg -highlightbackground $WBg]
  set vbody [frame $topf.vbody -bg $WBg -highlightbackground $WBg]

  set cmd "KillMimeEdit $owner"
  button $buttons.quit -text "Close" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
#  Gotta intercept wm killing the window with this command too
  wm protocol $WinName "WM_DELETE_WINDOW" $cmd
  wm protocol $WinName "WM_SAVE_YOURSELF" $cmd
  set cmd "SaveMimeTypes"
  button $buttons.sav -text "Save" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  set cmd "EditAMimeType 1 $owner"
  button $buttons.edit -text "Edit" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  button $buttons.del -text "Delete" \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg -state disabled
  set cmd "EditAMimeType 0 $owner"
  button $buttons.new -text "New " -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  button $buttons.act -text "Update" -width 8 \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg -state disabled
  set cmd "ResetMimeType $owner"
  button $buttons.reset -text "Reset" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg

  pack $buttons.quit $buttons.sav $buttons.edit $buttons.new $buttons.act \
    $buttons.del $buttons.reset -side left -padx 4 -pady 8

  frame $headf.edf1 -bg $WBg -highlightbackground $WBg
  frame $headf.edf2 -bg $WBg -highlightbackground $WBg
  frame $headf.edf3 -bg $WBg -highlightbackground $WBg

#-------------------
  label $headf.edf1.mtypl -bg $WBg -fg $WFg -text "MIME Type:" -width 12
  entry $headf.edf1.mtype -bg $WEntBg -highlightbackground $WEntBg -fg $WDisab -width 24 \
    -state disabled -relief sunken -textvariable mimet

  label $headf.edf1.mel -bg $WBg -fg $WFg -text "  Extension:" -width 12
  entry $headf.edf1.mee -bg $WEntBg -highlightbackground $WEntBg -fg $WDisab -width 10 \
    -state disabled -relief sunken -textvariable mimeex

  label $headf.edf2.mtagl -bg $WBg -fg $WFg -text "File tag:   " -width 12
  entry $headf.edf2.mtage -bg $WEntBg -highlightbackground $WEntBg -fg $WDisab -width 47 \
    -state disabled -relief sunken -textvariable mimetag

  label $headf.edf3.mvl -bg $WBg -fg $WFg -text "Viewer    " -width 12
  entry $headf.edf3.mve -bg $WEntBg -highlightbackground $WEntBg -fg $WDisab -width 47 \
    -state disabled -relief sunken -textvariable mimev
#-------------------

  pack $headf.edf1.mtypl $headf.edf1.mtype $headf.edf1.mel $headf.edf1.mee \
    -side left
  pack $headf.edf2.mtagl $headf.edf2.mtage \
    -side left
  pack $headf.edf3.mvl $headf.edf3.mve \
    -side left
#-------------------

  label $headf.id1 -bg $WBg -fg $WFg -justify center \
    -text " MIME Types " 
  label $headf.id2 -bg $WBg -fg $WFg -justify left \
    -text "Type                       Viewer                      Extension                 Tag    " 

  pack $headf.id2 -side bottom -anchor w -fill none -expand no
  pack $headf.id1 -side bottom -fill x -expand yes
  pack $headf.edf3 -side bottom -fill x -pady 4 -expand yes
  pack $headf.edf2 -side bottom -fill x -pady 4 -expand yes
  pack $headf.edf1 -side bottom -fill x -pady 4 -expand yes
  pack $vbody -side bottom -fill both -expand yes
  pack $headf -side bottom -anchor w -fill x -expand no
  pack $buttons -side bottom

  #  Display the known MIME types in a listbox
  scrollbar $vbody.scrolly -command "$vbody.vlist yview"
  pack $vbody.scrolly -side right -fill y
  listbox $vbody.vlist -relief sunken -bg $lbg -fg $lfg -width 60 \
    -selectbackground $WSelBg \
    -selectforeground $WSelFg \
    -yscroll "$vbody.scrolly set" \
    -selectmode single \
    -height 6  -font "-*-fixed-bold-*-*-*-*-*-*-*-*-*-iso8859-1"

  ConfigureScrollbar $vbody.scrolly 0 0
  ListMimeTypes $owner



  pack $topf -side bottom -anchor center -expand yes -fill both

  set cmd "EditAMimeType 1 $owner"
  bind $vbody.vlist <Double-1> $cmd

  }



return
}


#---------------------------------------------------------------------
#  KillMimeEdit  --  Save MIME types and destroy edit window.
#---------------------------------------------------------------------
proc KillMimeEdit {owner}  {
global mimet mimev mimeex mimetag
global TkzG

destroy ".$owner"
unset mimet
unset mimev
unset mimeex
unset mimetag

return 0
}


#---------------------------------------------------------------------
#  ListMimeTypes  --  List the known MIME types/viewers.
#---------------------------------------------------------------------
proc ListMimeTypes {owner}  {
global Home PgmName MimeNum MimeTags MimeExtns MimeTypes MimeViewers
global mimet mimev mimeex mimetag
global TkzG


set vlist ".$owner.topf.vbody.vlist"

$vlist delete 0 end
set i 0
while {$i < $MimeNum}  {
  set mimet "$MimeTypes($i)                      "
  set mimev "$MimeViewers($i)                      "
  set mimeex "$MimeExtns($i)                      "
  set mimetag "$MimeTags($i)                      "
  set mimet [string range $mimet 0 15]
  set mimev [string range $mimev 0 15]
  set mimeex [string range $mimeex 0 15]
  set mimetag [string range $mimetag 0 15]
  set line "$mimet  $mimev  $mimeex  $mimetag"
  $vlist insert end $line
  incr i
  }
set mimet ""
set mimev ""
set mimeex ""
set mimetag ""
pack $vlist  -side left -fill both -expand yes

return 0
}


#---------------------------------------------------------------------
#  EditAMimeType  --  Edit a MIME types/viewer entry.
#---------------------------------------------------------------------
proc EditAMimeType {func owner}  {
global EntBg EntFg TwButFg
global Home PgmName MimeNum MimeTags MimeExtns MimeTypes MimeViewers
global mimet mimev mimeex mimetag
global TkzG

set WEntBg $EntBg(0)
set WEntFg $EntFg(0)
set WButFg $TwButFg(0)
set action ".$owner.topf.but.act"
set delbutton ".$owner.topf.but.del"
set headf ".$owner.topf.headf"
set vlist ".$owner.topf.vbody.vlist"
if {$func == 0}  {
  set whichone $MimeNum
  }  else  {
  set whichone [$vlist curselection]
  if {$whichone == ""}  {
    GErrMsgBox 77
    return 0
    }
  }

if {$whichone < $MimeNum}  {
  set mimet $MimeTypes($whichone)
  set mimev $MimeViewers($whichone)
  set mimeex $MimeExtns($whichone)
  set mimetag $MimeTags($whichone)
  $action configure -text "Update"
  set cmd "DeleteMimeType $whichone $owner"
  $delbutton configure -state normal -command $cmd
  }  else  {
  set mimet ""
  set mimev ""
  set mimeex ""
  set mimetag ""
  $action configure -text "Add"
  $delbutton configure -state disabled
  }

set cmd "UpdateMimeType $whichone $owner"
$action configure -state normal -command $cmd
$headf.edf1.mtype configure -relief sunken -fg $WEntFg -state normal
$headf.edf1.mee configure -relief sunken -fg $WEntFg -state normal
$headf.edf2.mtage configure -relief sunken -fg $WEntFg -state normal
$headf.edf3.mve configure -relief sunken -fg $WEntFg -state normal
$action configure -state normal

return 0
}


#---------------------------------------------------------------------
#  UpdateMimeType  --  Update or add a MIME types/viewer entry.
#---------------------------------------------------------------------
proc UpdateMimeType {whichone owner}  {
global Home PgmName MimeNum MimeTags MimeExtns MimeTypes MimeViewers
global mimet mimev mimeex mimetag
global TkzG

set action ".$owner.topf.but.act"
set delbutton ".$owner.topf.but.del"
set vlist ".$owner.topf.vbody.vlist"
set mimet [string trim $mimet]
set mimev [string trim $mimev]
set mimeex [string trim $mimeex]
set mimetag [string trim $mimetag]
set cursor [$vlist curselection]

if {$mimev == ""}  {
  GErrMsgBox 76
  return 0
  }
if {$mimetag == "" && $mimeex == ""}  {
  GErrMsgBox 76
  return 0
  }

if {$whichone == $MimeNum}  {
  incr MimeNum
  if {$cursor != ""}  {
    set i [expr $MimeNum - 1]
    set i2 [expr $i - 1]
    while {$i > $cursor}  {
      set MimeTypes($i) $MimeTypes($i2)
      set MimeViewers($i) $MimeViewers($i2)
      set MimeExtns($i) $MimeExtns($i2)
      set MimeTags($i) $MimeTags($i2)
      incr i -1
      incr i2 -1
      }
    set whichone $i
    }  
  }

set MimeTypes($whichone) $mimet
set MimeViewers($whichone) $mimev
set MimeExtns($whichone) $mimeex
set MimeTags($whichone) $mimetag

$action configure -text "Update" -state disabled
$delbutton configure -state disabled
#SaveMimeTypes
ListMimeTypes $owner

return 0
}


#---------------------------------------------------------------------
#  DeleteMimeType  --  Delete a MIME types/viewer entry.
#---------------------------------------------------------------------
proc DeleteMimeType {whichone owner}  {
global Home PgmName MimeNum MimeTags MimeExtns MimeTypes MimeViewers
global mimet mimev mimeex mimetag
global TkzG

set action ".$owner.topf.but.act"
set delbutton ".$owner.topf.but.del"
set vlist ".$owner.topf.vbody.vlist"

if {$whichone == $MimeNum}  {
  $action configure -text "Update" -state disabled
  $delbutton configure -state disabled
  return 0
  }

$action configure -text "Update" -state disabled
$delbutton configure -state disabled
set i $whichone
set i2 [expr $i + 1]
while {$i2 < $MimeNum}  {
  set MimeTypes($i) $MimeTypes($i2)
  set MimeViewers($i) $MimeViewers($i2)
  set MimeTags($i) $MimeTags($i2)
  set MimeExtns($i) $MimeExtns($i2)
  incr i 
  incr i2
  }
incr MimeNum -1
unset MimeTypes($MimeNum)
unset MimeViewers($MimeNum)
unset MimeTags($MimeNum)
unset MimeExtns($MimeNum)
#SaveMimeTypes
ListMimeTypes $owner

return 0
}


#---------------------------------------------------------------------
#  ResetMimeType  --  Reset selected MIME types/viewer entry.
#---------------------------------------------------------------------
proc ResetMimeType {owner}  {
global Home PgmName MimeNum MimeTags MimeExtns MimeTypes MimeViewers
global mimet mimev mimeex mimetag
global TkzG

set action ".$owner.topf.but.act"
set delbutton ".$owner.topf.but.del"
set reset ".$owner.topf.but.reset"
set vlist ".$owner.topf.vbody.vlist"
set mimet ""
set mimev ""
set mimeex ""
set mimetag ""
$action configure -text "Update" -state disabled
$delbutton configure -state disabled
$vlist selection clear 0 [$vlist size]

return 0
}



#-----------------------------------------------------------
#  Build Scrollbar   --  Common func to build a scrollbar
#    owner = widget it will be attached to - common
#            owning frame is expected to be one dot-level up
#    wno   = type of window
#    loc   = 0, 1, 2, 3 = right, bottom, left, top
#            (owner.sby, sbx, sbl, sbt)
#-----------------------------------------------------------
proc BuildScrollbar {owner wno loc}  { 
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg DSlidBg
global EntBg EntFg
global TkzG


set i [string last "." $owner]
incr i -1
set ownf [string range $owner 0 $i]

switch  $loc  {

  0     -
  2     {
     if {$loc == 0}  {
       set bar "$ownf.sby"
       }  else  {
       set bar "$ownf.sbl"
       }
     scrollbar $bar
     set ycmd "$bar set"
     $owner configure -yscroll $ycmd 
     set ycmd "$owner yview"
     $bar configure -command $ycmd 
     }
  1     -
  3     {
     if {$loc == 1}  {
       set bar "$ownf.sbx"
       }  else  {
       set bar "$ownf.sbt"
       }
     scrollbar $bar
     set xcmd "$bar set"
     $owner configure -xscroll $xcmd 
     set xcmd "$owner xview"
     $bar configure -command $xcmd -orient horizontal
     }
  }

ConfigureScrollbar $bar $wno 0

return
}

#---------------------------------------------------------
#  ConfigureScrollbar   --  Set appearance for a scrollbar
#    (for cleanup release, change all the older code to
#    use this common func)
#---------------------------------------------------------
proc ConfigureScrollbar {scrollbar wno coloronly}  { 
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg DSlidBg
global EntBg EntFg
global TkzG


set sbg $SlidBg($wno)
set tcol $TrCol($wno)

#  First configure the slider background
if {$sbg != "UseTk"}  {
  if {$sbg == "UseDefault"}  {
    $scrollbar configure -bg $DSlidBg
    }  else  {
    $scrollbar configure -bg $sbg
    }
  }  else  {
  set tmp [$scrollbar configure -bg]
  set tmp [lindex $tmp 3]
  $scrollbar configure -bg $tmp
  }
#  Now the trough color
if {$tcol != "UseTk"}  {
  if {$tcol == "UseBg"}  {
    $scrollbar configure -troughcolor $TwBg($wno)
    }  else  {
    $scrollbar configure -troughcolor $tcol
    }
  }  else  {
  set tmp [$scrollbar configure -troughcolor]
  set tmp [lindex $tmp 3]
  $scrollbar configure -troughcolor $tmp
  }
if {$coloronly}  {
  return 0
  }

#  Now the element border width...
if {$TkzG(TrEBw) == -3}  {
  set tmp [$scrollbar configure -elementborderwidth]
  set TkzG(TrEBw) [lindex $tmp 3]
  }  else  {
  if {$TkzG(TrEBw) == -2}  {
    set TkzG(TrEBw) 3
    }
  }
#  Highlight thickness
if {$TkzG(TrHTh) == -3}  {
  set tmp [$scrollbar configure -highlightthickness]
  set TkzG(TrHTh) [lindex $tmp 3]
  }  else  {
  if {$TkzG(TrHTh) == -2}  {
    set TkzG(TrHTh) 1
    }
  }
#  Width
if {$TkzG(TrW) == -3}  {
  set tmp [$scrollbar configure -width]
  set TkzG(TrW) [lindex $tmp 3]
  }  else  {
  if {$TkzG(TrW) == -2}  {
    set TkzG(TrW) 12
    }
  }
$scrollbar configure -elementborderwidth $TkzG(TrEBw) 
$scrollbar configure -highlightthickness $TkzG(TrHTh) 
$scrollbar configure -width $TkzG(TrW) 

return 0
}


#----------------------------------------------------------
#  TransPic - Transparentify an image, because Tk by itself
#  doen't do the transparent gif thing.
#    - assumes the upper left-hand pixel is bg color
#----------------------------------------------------------
proc TransPic {src dest}  {
global TkzG

if {$TkzG(Windows)}  {
  return
  }

set x 0
set y 0
set trans [$src get $x $y]
#set Time1 [exec date]
while {$y < 46}  {
  set x 0
  while {$x < 56}  {
    set xy [$src get $x $y]
    if {$xy != $trans}  {
       set xcolor [HexifyColor $xy]
#      puts "Copying pixel color at $x,$y  =  $xy"
#      TkzLogo copy tmplogo -from $x $y $x $y -to $x $y 
      $dest put "$xcolor" -to $x $y 
      }
    incr x
    }
  incr y
  }


return
}


#---------------------------------------------------------
#  HexifyColor - because the Tk photo widget will give us
#  color info in decimal, but won't take it back that way.
#  Hmmph!
#---------------------------------------------------------
proc HexifyColor {dcolors}  {
global Hex
global TkzG

set xcolor "#000000"
set rv [lindex $dcolors 0]
set gv [lindex $dcolors 1]
set bv [lindex $dcolors 2]
#puts "Decoding $rv $gv $bv"

set rv [D2X $rv]
set gv [D2X $gv]
set bv [D2X $bv]

set xcolor "#$rv$gv$bv"

return $xcolor
}

#---------------------------------------
#  D2X - Convert a Decimal number to Hex
#---------------------------------------
proc D2X {num}  {
global Hex
global TkzG

set hi [expr $num / 16]
set lo [expr $num % 16]

set hi $Hex($hi)
set lo $Hex($lo)

set hexnum "$hi$lo"

return $hexnum
}




#----------------------------------------------------
#  SetCacheDir   --  Switch to a new Cache Directory,
#    creating it if necessary
#----------------------------------------------------
proc SetCacheDir {} {
global TempDir MyPid PgmName ErrArgs
global TkzG

set oldtmp $TempDir
#set newtmp "$TkzG(CacheDir)/.TkZip$MyPid"
set td $TkzG(CacheDir)
#  There was another of those double slash quirks here...
if {$td == "/"}  {
  set td ""
  }  else  {
  set tmpl [string length $td]
  incr tmpl -1
  if {[string range $td $tmpl end] == "/"}  {
    incr tmpl -1
    set td [string range $td 0 $tmpl]
    }
  }

if {! $TkzG(Windows)}  {
  set newtmp "$td/.$PgmName$MyPid"
  }  else  {
  set newtmp "$td/$PgmName$MyPid"
  }
#set sysinfo "TkzSysinfo"
if {! [file exists $TkzG(CacheDir)]}  {
  if {$TkzG(Portable)}  {
    set rc [catch {file mkdir $TkzG(CacheDir)} cc]  
    }  else  {
    set rc [catch { exec mkdir $TkzG(CacheDir) } cc]
    }
  if  {$rc}  {
#    puts "$PgmName  --  couldn't create $TkzG(CacheDir) for cache directory."
#    puts "$PgmName  --  continuing to used old cache directory  -  $oldtmp."
    set ErrArgs [list $oldtmp $TkzG(CacheDir)]
    GErrMsgBox 81
    return -1
    }
  }
if {$TkzG(Portable) && $oldtmp != $newtmp}  {
  catch {file mkdir $newtmp}
  catch {file copy -force $oldtmp/TkzSysinfo $newtmp/TkzSysinfo}
  catch {file copy -force $oldtmp.* $newtmp}
  catch {file delete -force $oldtmp}
  }  else  {
  catch {exec mkdir $newtmp}
  catch {exec cp $oldtmp/TkzSysinfo $newtmp/TkzSysinfo}
  catch {exec cp -rf $oldtmp.* $newtmp}
  catch {exec rm -rf $oldtmp}
  }

set TempDir $newtmp

return 1
}


#----------------------------------------------------
#  ChangeCacheDir   --  Dialogue for changing the 
#    cache directory
#----------------------------------------------------
proc ChangeCacheDir {} {
global TempDir MyPid PgmName ErrArgs MenuHelp
global MainBg MainFg MainButBg WhoBg ArcWin WinList
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg DSlidBg
global EntBg EntFg SelBg SelFg ChgCache
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 42
  return 1
  }

#--------------------------------------
if {$WinList != ""}  {
  set ErrArgs [list $TempDir]
  GErrMsgBox 80
  return 1
  }
set ChgCache 1

set WBg $TwBg(0)
set WButBg $TwButBg(0)
set WButFg $TwButFg(0)
set WEntBg $EntBg(0)
set WEntFg $EntFg(0)
set WSelBg $SelBg(0)
set WSelFg $SelFg(0)
set WFg $TwFg(0)
set lbg $TwLFg(0)
set lfg $TwLFg(0)


set owner "main"

#-------------------------------------------------------------------
#  Make some unique names for us...
#incr ArcWin
set thiswin "chgc000"
set WinName ".$thiswin"
set owner $thiswin

set dirname "/"


#set arcn "arcname$thiswin"
#global $arcn
#set $arcn $arcname
#set atype "ArcFno$owner"
#global $atype
#set type [set $atype]


if [catch {toplevel $WinName}] {
  raise $WinName
  } else {
#  Build the window...
  set wintitle "$PgmName: Select New Cache Directory"
  wm title $WinName $wintitle
  set topf [frame $WinName.top -bg $WBg -highlightbackground $WBg]
  set buttons [frame $topf.but -bg $WBg -highlightbackground $WBg]
  set namef [frame $WinName.top.namef -bg $WBg -highlightbackground $WBg]

  set cmd "ChangeCacheDir2 $owner"
  button $buttons.add2arc -text "Change Cache" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  bind $buttons.add2arc <3> {ShowHelp 42a}
set cmd "destroy $WinName"
set cmd "KillCacheWin $thiswin"
  button $buttons.quit -text "Cancel" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  bind $buttons.quit <3> {ShowHelp 42a}
#  Gotta intercept wm killing the window with this command too
  wm protocol $WinName "WM_DELETE_WINDOW" $cmd
  wm protocol $WinName "WM_SAVE_YOURSELF" $cmd

  label $namef.where -text "   Directory:  " -relief flat -bg $WBg -fg $WFg
  entry $namef.dir -text " " -relief sunken -bg $WEntBg -fg $WEntFg -width 30 \
  -font "-*-fixed-bold-*-*-*-*-*-*-*-*-*-*-1" -state disabled

  pack $buttons.add2arc $buttons.quit -side left
  pack $namef.where $namef.dir -side left -expand no


#  Now build a file selection list for directory to create in & filename...
  set flbody [ frame $WinName.body  -bg $WBg -highlightbackground $WBg]
  set body $thiswin.body

  set stuff [BuildDirList "$body"]

  pack $flbody -anchor w -fill x -side bottom -fill both -expand yes
  
  pack $namef -side bottom -anchor center 
  pack $buttons -side bottom
  
  pack $topf -side bottom -anchor center -expand yes -fill x

  $flbody.list1.dirlist configure -selectbackground $WSelBg \
    -selectforeground $WSelFg
  $flbody.list2.arclist configure -selectbackground $WSelBg \
    -selectforeground $WSelFg
  set cradir "CraDir$body"
  global $cradir
  set $cradir $dirname
  set cmd "UpdCraDir $body"
  bind $flbody.list1.dirlist <Double-1> $cmd
  $flbody.list1.dirlist configure -selectmode extended
  $flbody.list2.arclist configure -selectmode extended
  set cmd "UpdCraDir2 $thiswin"
  bind $namef.dir <Return> $cmd


  $namef.dir configure -textvariable $cradir
  set $cradir [UpdDirList "$body" "$dirname"]


  }

#--------------------------------------

return 1 	
}


#----------------------------------------------------
#  ChangeCacheDir2   --  OK, do it. 
#----------------------------------------------------
proc ChangeCacheDir2 {owner} {
global TempDir MyPid PgmName ErrArgs MenuHelp FLList
set thisproc "ChangeCacheDir2"
global TkzG

set body "$owner.body"
set cradir "CraDir$body"
global $cradir
set newdir [set $cradir]
set olddir $TkzG(CacheDir)
set TkzG(CacheDir) $newdir
set rc [SetCacheDir]

set oldcache $TempDir
#set newcache "$newdir/.TkZip$MyPid"
if {! $TkzG(Windows)}  {
  set newcache "$newdir/.$PgmName$MyPid"
  }  else  {
  set newcache "$newdir/$PgmName$MyPid"
  }

KillCacheWin $owner
RefDirs "$olddir"
RefDirs "$newdir"
if {$rc != -1}  {
  set ErrArgs [list $oldcache $newcache]
  GErrMsgBox 79
  }
return 1 	
}


#-------------------------------------------------
#  KillCacheWin   --  Deal with cmd line args
#-------------------------------------------------
proc KillCacheWin {owner} {
global FLList ChgCache
global TkzG

set body "$owner.body"

set ChgCache 0
PluckFromList $body "FLList"
destroy .$owner

}


#----------------------------------------------------
#  NameThatTar   --  Dialogue for setting the name
#    by which GNU tar is known.
#----------------------------------------------------
proc NameThatTar {} {
global TempDir MyPid PgmName ErrArgs MenuHelp
global MainBg MainFg MainButBg WhoBg ArcWin WinList
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg DSlidBg
global EntBg EntFg SelBg SelFg
global TempGt
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 62
  return 1
  }

#--------------------------------------
set WBg $TwBg(0)
set WButBg $TwButBg(0)
set WButFg $TwButFg(0)
set WEntBg $EntBg(0)
set WEntFg $EntFg(0)
set WSelBg $SelBg(0)
set WSelFg $SelFg(0)
set WFg $TwFg(0)
set lbg $TwLFg(0)
set lfg $TwLFg(0)


set owner "main"

#-------------------------------------------------------------------
#  Make some unique names for us...
#incr ArcWin
set thiswin "gtnm000"
set WinName ".$thiswin"
set owner $thiswin

if [catch {toplevel $WinName}] {
  raise $WinName
  } else {
#  Build the window...
  set wintitle "$PgmName: Set GNU Tar Name"
  wm title $WinName $wintitle
  set topf [frame $WinName.top -bg $WBg -highlightbackground $WBg]
  set buttons [frame $topf.but -bg $WBg -highlightbackground $WBg]
  set namef [frame $WinName.top.namef -bg $WBg -highlightbackground $WBg]

  set cmd "SetGtarName $owner"
  button $buttons.setit -text "Set" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
#  bind $buttons.setit <3> {ShowHelp 62}
set cmd "destroy $WinName"
set cmd "KillSetGtWin $thiswin"
  button $buttons.quit -text "Cancel" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
#  bind $buttons.quit <3> {ShowHelp 63}
#  Gotta intercept wm killing the window with this command too
  wm protocol $WinName "WM_DELETE_WINDOW" $cmd
  wm protocol $WinName "WM_SAVE_YOURSELF" $cmd

  label $namef.tag -text "GNU Tar Name:  " -relief flat -bg $WBg -fg $WFg
  entry $namef.nam -text " " -relief sunken -bg $WEntBg -fg $WEntFg -width 30 \
  -font "-*-fixed-bold-*-*-*-*-*-*-*-*-*-*-1" -state disabled

  pack $buttons.setit $buttons.quit -side left
  pack $namef.tag $namef.nam -side left -expand no

  pack $namef -side bottom -anchor w -padx 8 -pady 8
  pack $buttons -side bottom 
  pack $topf -side bottom -anchor center -expand yes -fill both -ipady 4

  set cmd "SetGtarName $owner"
  bind $namef.nam <Return> $cmd
  set TempGt $TkzG(GtarName)
  $namef.nam configure -textvariable TempGt -state normal



  }


return 0
}


#---------------------------------------------------
#  SetGtarName   --  Set the Gtar Name
#---------------------------------------------------
proc SetGtarName {owner} {
global FLList TempGt
global TkzG

set TkzG(GtarName) $TempGt
CheckGtar ""

KillSetGtWin $owner

return 1
}


#---------------------------------------------------
#  KillSetGtWin   --  Destroy the Gtar Name window
#---------------------------------------------------
proc KillSetGtWin {owner} {
global FLList
global TkzG

set body "$owner.body"

PluckFromList $body "FLList"
destroy .$owner

}




#-------------------------------------------------
#  ParseArgs   --  Deal with cmd line args
#-------------------------------------------------
proc ParseArgs {} {
global argc argv PgmName TkzVer Debugon CurDir InitFile
global TkzG

set InitFile ""

if {$argc > 0} {
  set argnum [expr $argc - 1]
  set curarg 0
  while {$curarg < $argc} {
    set thisarg [lindex $argv $curarg]

    switch -exact -- [lindex $argv $curarg] {
      "-v"           -
      "--version"    {
         puts "$PgmName version $TkzVer"
	 exit
         }

      "--debug"      {
         set Debugon 1
         }

      "--adm"     {
         set TkzG(SysAdmp) 1
         }

      "--ForceInstall"     {
         if {$TkzG(WhoIAm) == "root" || $TkzG(WhoIAm) == $TkzG(SysAdmin)}  {
           set TkzG(ForceInstall) 1
           }
         }

      "--pipein"     {
         set TkzG(PipeIn) 1
         }

      "--nomain"     {
         set TkzG(NoMainWin) 1
         set TkzG(LastCloseExits) 1
         }

      "--iconic"     {
         set TkzG(StartIconic) 1
         }

      "--LastCloseExits"     {
         set TkzG(LastCloseExits) 1
         }

      default      {
         if {[string first "--"  $thisarg]  !=  0}  {
           set lsl [string last "/" $thisarg]
           if {$lsl < 0}  {
             set CurDir [pwd]
             set InitFile $thisarg
             }
           if {$lsl == 0}  {
             set CurDir "/"
             set InitFile [string range $thisarg 1 end]
             }
           if {$lsl > 0}  {
             set dstrt 0
               set CurDir [pwd]
             set fdsl [string first "./" $thisarg]
             if {$fdsl == 0}  {
               set CurDir "$CurDir/[string range $thisarg 2 [expr $lsl - 1]]"
               set InitFile [string range $thisarg [expr $lsl + 1] end]
               }  else  {
               set fsl [string first "/" $thisarg]
               if {$fsl == 0}  {
                 set CurDir ""
                 }
               set CurDir "$CurDir/[string range $thisarg 0 [expr $lsl - 1]]"
               set InitFile [string range $thisarg [expr $lsl + 1] end]
               }
             }
           }
         #  Otherwise, just ignore something that looks like a pgm switch arg
         }
      }
    incr curarg
    }
  #  If there's no file to open, --nomain would leave the program hanging
  #  around with no window open. Let's not do that.
  if {$InitFile == ""}  {
    set TkzG(NoMainWin) 0
    }
  #  One last sanity check - there's a parsing bug somewhere.
  if {[string first "//" $CurDir] == 0}  {
    set CurDir [string range $CurDir 1 end]  
    }
  }

return 1
}


#-------------------------------------------------
#  CleanDirs   --  Clean up any stale files/dirs
#-------------------------------------------------
proc CleanDirs {} {
global Home PgmName TempDir
global Debugon
global TkzG
set thisproc "CleanDirs"

if {! $TkzG(CldFlag) && !$TkzG(CleFlag)}  {
  return 1
  }

#puts "$thisproc entered to delete old stuff."
#puts "TempDir = $TempDir   cache dir = $TkzG(CacheDir)"
#if {$Debugon}  {
#  #  Ugly hack - the user cannot have set Debug on at this point, and we're
#  #  not through with init, so we aren't ready to do interactive mode yet.
#  set tdbi $TkzG(Debugi)
#  set tdbl $TkzG(Debugl)
#  set TkzG(Debugl) 1
#  set TkzG(Debugi) 0
  set owner "dummy"
#  }
set cacheroot $TkzG(CacheDir)
set tkzdirs ""
set tkzerrs ""
#set ignl [string length "$cacheroot/.TkZip"]
if {! $TkzG(Windows)}  {
  set ignl [string length "$cacheroot/.$PgmName"]
  }  else  {
  set ignl [string length "$cacheroot/$PgmName"]
  }
set ignl2 [string length "$cacheroot/TkzErr"]
#catch {set tkzdirs [glob $cacheroot/.TkZip*]}
if {! $TkzG(Windows)}  {
  catch {set tkzdirs [glob $cacheroot/.$PgmName*]}
  }  else  {
  catch {set tkzdirs [glob $cacheroot/$PgmName*]}
  }
catch {set tkzerrs [glob $cacheroot/TkzErr*]}
set pids ""
if [ catch {set in [open [ concat "|ps"] ]} ]  {
  return 1
  }
set lno 0
while  { [ gets $in line ] > -1 } {
  incr lno
  if {$TkzG(Debug)}  {
#    puts "$thisproc:  ps line $lno:  <$line>"
    set dbmsg "$thisproc:  ps line $lno:  <$line>"
    DeBug $owner $dbmsg
    }
  if {$lno == 1}  {
    continue
    }
  set line [string trim $line]
  set pidend [string first " " $line]
  set pid [string trim [string range $line 0 $pidend]]
  if {$TkzG(Debug)}  {
#    puts "$thisproc:  extracted pid <$pid> from ps line."
    set dbmsg "$thisproc:  extracted pid <$pid> from ps line."
    DeBug $owner $dbmsg
    }
  set pids "$pids $pid"
  }
catch { close $in }

set pids "$pids "
if {$TkzG(CldFlag)}  {
  if {! $TkzG(Windows)}  {
    set confdir ".$PgmName"
    }  else  {
    set confdir "$PgmName"
    }
  if {$TkzG(Debug)}  {
    set dbmsg "\n$thisproc:  pid list = <$pids>."
    DeBug $owner $dbmsg
    }
  foreach file "$tkzdirs"  {
    if {[file isdirectory $file] && $file != "$Home/$confdir" && $file != "$Home$confdir"}  {
      set pid [string range $file $ignl end]
      if {$TkzG(Debug)}  {
#        puts "$thisproc:  extracted pid <$pid> from directory name <$file> (pos $ignl to end)."
        set dbmsg "$thisproc:  extracted pid <$pid> from directory name <$file> (pos $ignl to end)."
        DeBug $owner $dbmsg
        }
      set pid " $pid "
      if {[string first $pid $pids] != -1}  {
        }  else  {
	#  Temp debugging...
        if {$TkzG(Debug)}  {
          set dbmsg "$thisproc:  Deleting <$file> because pid <$pid> isn't in the list. "
          DeBug $owner $dbmsg
          }
	if {$file == $TempDir}  {
          if {$TkzG(Debug)}  {
            set dbmsg "            Damn! We're about to delete the cache <$TempDir>. Why did we think this was a good idea?"
            DeBug $owner $dbmsg
            set dbmsg "            Let's just not do it, what say?"
            DeBug $owner $dbmsg
            }
	  }  else  {
        if {$TkzG(Portable)}  {
          catch {file delete -force $file}
          }  else  {
          catch {exec rm -rf $file}
          }
	  }
	#  Temp debugging...
        }
      }
    }
  }
if {$TkzG(CleFlag)}  {
  foreach file "$tkzerrs"  {
    set pid [string range $file $ignl end]
    set pid " $pid "
    if {[string first $pid $pids] != -1}  {
      #  *** Oops! - what used to be here?
      }  else  {
      if {$TkzG(Portable)}  {
        catch {file delete -force $file}
        }  else  {
        catch {exec rm -f $file}
        }
      }
    }
  }

#if {$Debugon}  {
#  set TkzG(Debugi) $tdbi
#  set TkzG(Debugl) $tdbl
#  }

return 1
}


#----------------------------------------------------------
#  LoadConfig  --  Load user's config, if any - 
#----------------------------------------------------------
proc LoadConfig {} {
global PgmName Home ViewOpts VNames VBins VNum
global TkzVer TkzrcVer
global ErrArgs OptDir OptFile
global UpgRel InstSrcDir InstDestDir
global TkzG
set thisproc "LoadConfig"

if {$TkzG(Crippled)}  {
  return 1
  }

set ViewOpts 0
#set oldoptfile "$Home/.TkZip.rc"
#set optdir "$Home/.TkZip"
#set optfile "$optdir/TkZip.rc"
if {! $TkzG(Windows)}  {
  set oldoptfile "$Home/.$PgmName.rc"
  set optdir "$Home/.$PgmName"
  set optfile "$optdir/$PgmName.rc"
  }  else  {
  #  1.0.15 change
#  set oldoptfile "$Home.$PgmName.rc"
  set oldoptfile "C:/$PgmName/$PgmName.rc"
  set oldmimefile "C:/$PgmName/$PgmName.rc"
  set oldoptdir "C:/$PgmName"
  set optdir "$Home$PgmName"
  set optfile "$optdir/$PgmName.rc"
  set OptFile $optfile
  }

# Temp for Win testing...
# puts "$thisproc:  optfile = $optfile  oldoptfile = $oldoptfile"
#  Check for pre-0.9.6 config...
if {! [file exists $OptDir]}  {
  if {$TkzG(Portable)}  {
    set rc [catch {file mkdir $OptDir} dummy]
    }  else  {
    set rc [catch {exec mkdir $OptDir} dummy]
    }
  set UpgRel 1
  }
set ErrArgs ""
if {! [file exists $OptFile]}  {
# Temp for Win testing...
# puts "$thisproc:  No $OptFile..."
  if {[file exists $oldoptfile]}  {
# Temp for Win testing...
# puts "$thisproc:  Found $oldoptfile..."
    if {$TkzG(Portable)}  {
      if {! $TkzG(Windows)}  {
        catch {file copy -force $oldoptfile $OptFile}
        lappend ErrArgs "pre-0.9.6" "$OptDir" "$oldoptfile"
        }  else  {
        catch {file copy -force $oldoptdir/TkZip.rc $OptDir}
        catch {file copy -force $oldoptdir/TkZip.mimetypes $OptDir}
        lappend ErrArgs "pre-1.0.15" "$OptDir" "$oldoptfile"
        }
      }  else  {
      catch {exec cp $oldoptfile $OptFile}
      lappend ErrArgs "pre-0.9.6" "$OptDir" "$oldoptfile"
      }
    set UpgRel 1
#    lappend ErrArgs "pre-0.9.6" "$OptDir" "$oldoptfile"
    GErrMsgBox 75
    }
  }

# Temp for Win testing...
# puts "$thisproc:  calling LoadConfigFile for $OptFile..."
LoadConfigFile $OptFile

if {$ViewOpts != 0}  {
  incr ViewOpts
  set VNum $ViewOpts
  set VNames($VNum) "User defined"
  set VBins($VNum) ""
  }
unset ViewOpts

#  This is as far as the WinDOG logic goes, so far...
if {$TkzG(Windows)}  {
  return 1
  }
#  Check config for older release, upgrade if so.
if {[CheckVer]}  {
  SaveConfig
  set UpgRel 1
  if {$TkzrcVer != "0.0.0"}  {
    set ErrArgs [list $TkzrcVer]
    GErrMsgBox 74
    }
  }

return 1
}


#----------------------------------------------------------
#  LoadConfigFile  --  Load config from a named file - 
#    - allows for supplemental options files
#----------------------------------------------------------
proc LoadConfigFile {config} {
global PgmName Home ViewOpts VNames VBins VNum
global TkzVer TkzrcVer
global ErrArgs OptDir OptFile
global UpgRel InstSrcDir InstDestDir
global TkzG
set thisproc "LoadConfigFile"

#puts "$thisproc:  Loading config from $config..."

if [ catch {set of [open $config r]} dummy]  {
  SaveConfig
  set TkzG(InitFlag) 1
  return 1
  }

while {[ gets $of line ] > -1}  {
  #  First, strip comments... 
  set ti [string first "#" $line]
  if {$ti != -1}  {
    if {$ti == 0}  {
      set line ""
      }  else  {
#      incr ti -1
#      set line [string range $line 0 $ti]
      }
    }
  set line [string trim $line]

  #  Now, identify our stuff... 
  if {[string first $PgmName $line] == 0}  {
    set ti [string first "*" $line]
    incr ti
    set line [string range $line $ti end]
    set ti [string first ":" $line]
    if {$ti > 0}  {
      set opt [string trim [string range $line 0 [expr $ti - 1] ] ]
      incr ti
      set val [string trim [string range $line $ti end] ]
      SetConfigOpt $opt $val
      #  End - we have an option name... 
      }
    #  End - it's one of ours... 
    }
  } 
catch {close $of}

return 1
}


#--------------------------------------------------
#  CheckVer - Check for older version 
#  Account for base release diff, as well as
#  suffixes (a,b...)
#--------------------------------------------------
proc CheckVer {} {
global TkzVer TkzrcVer
global TkzG

set oldver 0
set rcver4 ""
set pver4 ""
set fmt "%d%c%d%c%d%s"
scan $TkzrcVer $fmt rcver1 d1 rcver2 d2 rcver3 rcver4
scan $TkzVer $fmt pver1 d1 pver2 d2 pver3 pver4
if {$rcver4 == ""}  {
  set rcver4 "p"
  }
if {$pver4 == ""}  {
  set pver4 "p"
  }

if {$rcver1 < $pver1}  {
  set oldver 1
  }  else  {
  if {$rcver1 == $pver1 && $rcver2 < $pver2}  {
    set oldver 1
    }  else  {
    if {$rcver1 == $pver1 && $rcver2 == $pver2 && $rcver3 < $pver3}  {
      set oldver 1
      }  else  {
      if {$rcver1 == $pver1 && $rcver2 == $pver2 \
        && $rcver3 == $pver3 && $rcver4 < $pver4}  {
        set oldver 1
        }
      }
    }
  }

return $oldver
}



#--------------------------------------------------
#  SetConfigOpt - Set an option the new way
#--------------------------------------------------
proc SetConfigOpt {opt val} {
global PgmName Home
global ViewOpts VNames VBins VNum
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg 
global EntBg EntFg SelBg SelFg
global DSlidBg NumWins
global MimeNum MimeTags MimeExtns MimeTypes MimeViewers
global Lserrc
global TkzVer TkzrcVer
#global StdOpts SpecOpts Partials 
global Debugon
global TkzG
set thisproc "SetConfigOpt"

#  First the special case of old-style viewers... 
#  They can really call it Viewer3200-xyz-anyoldstuff...  
if {[string first "Viewer" $opt] == 0}  {
  if {$ViewOpts == 0}  {
    unset VNames
    unset VBins
    }
  incr ViewOpts
#  set opti [string range $opt 6 end]
#  set opti $ViewOpts
  set opt1 "Viewer"
  set ti [string first ":" $val]
  set val1 [string trim [string range $val 0 [expr $ti - 1] ] ]
  set val1 [string trim $val1 "\""]
  set val2 [string trim [string range $val [expr $ti + 1] end] ]
  set VNames($ViewOpts) $val1
  set VBins($ViewOpts) $val2

  return 1
  }

#set Partials "TwBg TwFg TwButBg TwButFg TwLBg TwLFg EntBg EntFg\
#  SelBg SelFg TrCol SlidBg MimeTags MimeExtns MimeTypes MimeViewers"
set Partials [list "TwBg" "TwFg" "TwButBg" "TwButFg" "TwLBg" "TwLFg"\
  "EntBg" "EntFg" "SelBg" "SelFg" "TrCol" "SlidBg" "MimeTags" "MimeExtns"\
  "MimeTypes" "MimeViewers"]
set onum [llength $Partials]
set i 0
while {$i < $onum}  {
#puts "  checking <$opt> for [lindex $Partials $i]..."
  if {[string first [lindex $Partials $i] $opt] == 0}  {
#puts "    - got it."
    set $opt $val
    return 1
    }
  incr i
  }


#  The simple ones...
set StdOpts "Desperation IgnITG NoProbe EmUser EmHost CldFlag CleFlag DseFlag\
  SavOpt StdNames GnuLin ShnHeur FastClean MultView Vpn CompOpt CacheDir\
  ArcOnly OpenStartDir NavLinks UsePager IntView Mime4All DV4All UseMainIcon\
  SysAdmin Lser NoInstall InstallUpg RootInstall PrtCmd TkzDir TkzIcon UseGtar\
  GtarName PreferGtar TrEBw TrHTh TrW Licensee LicenseNumber LicenseUsers IgnDrvErr "
#set StdOpts "Desperation TkzG(IgnITG) NoProbe TkzG(EmUser) TkzG(EmHost) TkzG(CldFlag) TkzG(CleFlag) TkzG(DseFlag)\
#  TkzG(SavOpt) TkzG(StdNames) TkzG(GnuLin) TkzG(ShnHeur) TkzG(FastClean) TkzG(MultView) TkzG(Vpn) TkzG(CompOpt) TkzG(CacheDir)\
#  TkzG(ArcOnly) TkzG(OpenStartDir) TkzG(NavLinks) TkzG(UsePager) TkzG(IntView) TkzG(Mime4All) TkzG(DV4All) TkzG(UseMainIcon)\
#  TkzG(SysAdmin) Tkz(Lser) TkzG(NoInstall) TkzG(InstallUpg) TkzG(RootInstall) PrtCmd TkzDir TkzIcon TkzG(UseGtar)\
#  TkzG(TrEBw) TkzG(TrHTh) TkzG(TrW) "
set topt "$opt "
if {[string first $topt $StdOpts] != -1}  {
#puts "  <$topt> is in std list"
  set opt "TkzG($opt)"
  set $opt $val
  return 1
  }



#  These have special considerations...
set SpecOpts "TkzVer OvWarn OvOpt ForceInstall Debug Debugi Debugl"
#set SpecOpts "TkzVer TkzG(OvWarn) TkzG(OvOpt) TkzG(ForceInstall) Debug Debugi Debugl"
#puts "  checking the special cases <$SpecOpts> for $opt..."

switch $opt        {

  "OvWarn"         {
      #  Since OvOpt got inverted, & they're mutually exclusive - these 2 must be the same. 
      set TkzG(OvWarn) $val
      if {$TkzG(OvWarn) == 1}  {
          set TkzG(OvOpt) 1
	  }
      }

  "OvOpt"         {
      set TkzG(OvOpt) $val
      if {$TkzG(OvOpt) == 0}  {
        set TkzG(OvWarn) 0
        }
      }

  "TkzVer"             {
      set TkzrcVer $val
      }

  "Debug"             {
      if {$Debugon}  {
        set TkzG(Debug) $val
	}
      }

  "Debugi"             {
      if {$Debugon}  {
        set TkzG(Debugi) $val
	}
      }

  "Debugl"             {
      if {$Debugon}  {
        set TkzG(Debugl) $val
	}
      }

  "ForceInstall"             {
      #  If SysAdmin set this on cmd line, override config setting.
      if {! $TkzG(ForceInstall)}  {
        set TkzG(ForceInstall) $val
        }
      }

  default         {
      }

  }
  #  End switch...  

return 1
}




#--------------------------------------------------------
#  SaveAllConfig  --  Save user's config and MIME types - 
#--------------------------------------------------------
proc SaveAllConfig {} {

SaveConfig
SaveMimeTypes

return 0
}

#--------------------------------------------------
#  SaveConfig  --  Save user's config - 
#--------------------------------------------------
proc SaveConfig {} {
global PgmName Home
global VNames VBins VNum
global MenuHelp
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg 
global EntBg EntFg SelBg SelFg
global DSlidBg NumWins SpecWinFirst SpecWinLast
global TkzVer TkzrcVer OptFile 
global Debugon
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 14
  return 1
  }

set thisproc "SaveConfig"
#puts "$thisproc:  Entered in [pwd] for file $OptFile"
#catch [{set of [open $OptFile w] } dummy]
set rc [catch {open $OptFile w} dummy]
#puts "        open rc = <$rc>    open response = <$dummy>"
set of $dummy

catch {puts $of "$PgmName*TkzVer:              $TkzVer "}
catch {puts $of "$PgmName*OvWarn:              $TkzG(OvWarn) "}
catch {puts $of "$PgmName*OvOpt:               $TkzG(OvOpt) "}
catch {puts $of "$PgmName*Desperation:         $TkzG(Desperation) "}
catch {puts $of "$PgmName*IgnITG:              $TkzG(IgnITG) "}
catch {puts $of "$PgmName*NoProbe:             $TkzG(NoProbe) "}
catch {puts $of "$PgmName*EmUser:              $TkzG(EmUser) "}
catch {puts $of "$PgmName*EmHost:              $TkzG(EmHost) "}
catch {puts $of "$PgmName*CldFlag:             $TkzG(CldFlag) "}
catch {puts $of "$PgmName*CleFlag:             $TkzG(CleFlag) "}
catch {puts $of "$PgmName*DseFlag:             $TkzG(DseFlag) "}
catch {puts $of "$PgmName*SavOpt:              $TkzG(SavOpt) "}
catch {puts $of "$PgmName*StdNames:            $TkzG(StdNames) "}
catch {puts $of "$PgmName*GnuLin:              $TkzG(GnuLin) "}
catch {puts $of "$PgmName*ShnHeur:             $TkzG(ShnHeur) "}
catch {puts $of "$PgmName*FastClean:           $TkzG(FastClean) "}
catch {puts $of "$PgmName*MultView:            $TkzG(MultView) "}
catch {puts $of "$PgmName*Vpn:                 $TkzG(Vpn) "}
catch {puts $of "$PgmName*CompOpt:             $TkzG(CompOpt) "}
catch {puts $of "$PgmName*CacheDir:            $TkzG(CacheDir) "}
catch {puts $of "$PgmName*ArcOnly:             $TkzG(ArcOnly) "}
catch {puts $of "$PgmName*OpenStartDir:        $TkzG(OpenStartDir) "}
catch {puts $of "$PgmName*NavLinks:            $TkzG(NavLinks) "}
catch {puts $of "$PgmName*UseGtar:             $TkzG(UseGtar) "}
catch {puts $of "$PgmName*GtarName:            $TkzG(GtarName) "}
catch {puts $of "$PgmName*PreferGtar:          $TkzG(PreferGtar) "}
catch {puts $of "$PgmName*TrEBw:               $TkzG(TrEBw) "}
catch {puts $of "$PgmName*TrHTh:               $TkzG(TrHTh) "}
catch {puts $of "$PgmName*TrW:                 $TkzG(TrW) "}
catch {puts $of "$PgmName*UsePager:            $TkzG(UsePager) "}
catch {puts $of "$PgmName*IntView:             $TkzG(IntView) "}
catch {puts $of "$PgmName*Mime4All:            $TkzG(Mime4All) "}
catch {puts $of "$PgmName*DV4All:              $TkzG(DV4All) "}
catch {puts $of "$PgmName*UseMainIcon:         $TkzG(UseMainIcon) "}
catch {puts $of "$PgmName*SysAdmin:            $TkzG(SysAdmin) "}
catch {puts $of "$PgmName*Lser:                $TkzG(Lser) "}
catch {puts $of "$PgmName*ForceInstall:        $TkzG(ForceInstall) "}
catch {puts $of "$PgmName*NoInstall:           $TkzG(NoInstall) "}
catch {puts $of "$PgmName*InstallUpg:          $TkzG(InstallUpg) "}
catch {puts $of "$PgmName*RootInstall:         $TkzG(RootInstall) "}
catch {puts $of "$PgmName*PrtCmd:              $TkzG(PrtCmd) "}
catch {puts $of "$PgmName*TkzDir:              $TkzG(TkzDir) "}
catch {puts $of "$PgmName*TkzIcon:             $TkzG(TkzIcon) "}
catch {puts $of "$PgmName*IgnDrvErr:           $TkzG(IgnDrvErr) "}
catch {puts $of "$PgmName*Licensee:            $TkzG(Licensee) "}
catch {puts $of "$PgmName*LicenseNumber:       $TkzG(LicenseNumber) "}
catch {puts $of "$PgmName*LicenseUsers:        $TkzG(LicenseUsers) "}
if {$Debugon}  {
  catch {puts $of "$PgmName*Debug:               $TkzG(Debug) "}
  catch {puts $of "$PgmName*Debugi:              $TkzG(Debugi) "}
  catch {puts $of "$PgmName*Debugl:              $TkzG(Debugl) "}
  }

set i 1
while {$i < $VNum}  {
  puts $of "$PgmName*Viewer$i: \"$VNames($i)\" : $VBins($i) "
  incr i
  }


set i 0
while {$i < $NumWins}  {
  puts $of "$PgmName*TwBg($i):            $TwBg($i) "
  puts $of "$PgmName*TwFg($i):            $TwFg($i) "
  puts $of "$PgmName*TwButBg($i):         $TwButBg($i) "
  puts $of "$PgmName*TwButFg($i):         $TwButFg($i) "
  puts $of "$PgmName*TwLBg($i):           $TwLBg($i) "
  puts $of "$PgmName*TwLFg($i):           $TwLFg($i) "
  puts $of "$PgmName*EntBg($i):           $EntBg($i) "
  puts $of "$PgmName*EntFg($i):           $EntFg($i) "
  puts $of "$PgmName*SelBg($i):           $SelBg($i) "
  puts $of "$PgmName*SelFg($i):           $SelFg($i) "
  puts $of "$PgmName*TrCol($i):           $TrCol($i) "
  puts $of "$PgmName*SlidBg($i):          $SlidBg($i) "
  incr i
  }
set i $SpecWinFirst
while {$i <= $SpecWinLast}  {
  puts $of "$PgmName*TwBg($i):            $TwBg($i) "
  puts $of "$PgmName*TwFg($i):            $TwFg($i) "
  puts $of "$PgmName*TwButBg($i):         $TwButBg($i) "
  puts $of "$PgmName*TwButFg($i):         $TwButFg($i) "
  puts $of "$PgmName*TwLBg($i):           $TwLBg($i) "
  puts $of "$PgmName*TwLFg($i):           $TwLFg($i) "
  puts $of "$PgmName*EntBg($i):           $EntBg($i) "
  puts $of "$PgmName*EntFg($i):           $EntFg($i) "
  puts $of "$PgmName*SelBg($i):           $SelBg($i) "
  puts $of "$PgmName*SelFg($i):           $SelFg($i) "
  puts $of "$PgmName*TrCol($i):           $TrCol($i) "
  puts $of "$PgmName*SlidBg($i):          $SlidBg($i) "
  incr i
  }

catch {close $of}

return 1
}




#-------------------------------------------------
#  SetAppearance  --  Pop up Appearance dialogue
#
#  Note: scale value of -1 = Use TkZip default
#                       -2 = Use Tk default
#
#-------------------------------------------------
proc SetAppearance {} {
global MenuHelp PgmName WhoBg
global DSlidBg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg
global hth ebw wid tcol slbg
global wnum
global TkzG


if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 44
  return 1
  }

set thisproc "SetAppearance"
set wnum 104
#set sabg $WhoBg
#set sabg2 $TwBg(0)
#set safg2 $TwFg(0)
set sabg2 $TwBg($wnum)
set safg2 $TwFg($wnum)
set sabutbg $TwButBg($wnum)
set sabutfg $TwButFg($wnum)
set sabg $TwBg($wnum)
set safg $TwFg($wnum)
set tc "green"
set colset 0


set wn "setapp"
set win ".$wn"
set wintitle "$PgmName: Set Appearance"

if [catch {toplevel $win} rc]  {
  raise $win
  }  else  {
  wm title $win $wintitle
  wm iconname $win $wintitle

  set hth $TkzG(TrHTh)
  set ebw $TkzG(TrEBw)
  set wid $TkzG(TrW)
  set tcol $TwBg(0)
#  set slbg $SlidBg(0)
  set slbg $DSlidBg

  set winframe "$win.f"
  frame $winframe -bg $sabg2
  set winframe2 "$winframe.f2"
  frame $winframe2 -bg $sabg2
  frame $winframe2.f1 -bg $sabg2
  frame $winframe2.f2 -bg $sabg2
  set buttons "$winframe.but1"
  frame $buttons -bg $sabg
  set cmd "KillSetapp $win"
  button $buttons.exit -bg $sabutbg -text "Dismiss" -command $cmd
  set cmd "OkSetapp $win"
  button $buttons.ok -bg $sabutbg -text "OK" -command $cmd
  set cmd "SetApp2"
  button $buttons.scr -bg $sabutbg -text "Scrollbars" -command $cmd
  set cmd "DefaultSetapp $win"
  button $buttons.dflt -bg $sabutbg -text "Defaults" -command $cmd
  set cmd "ApplySetapp $win"
  button $buttons.apply -bg $sabutbg -text "Apply" -command $cmd

  pack $buttons.exit $buttons.ok $buttons.scr $buttons.dflt $buttons.apply -side left

  set colstuf "$winframe2.f2.col"
  frame $colstuf -bg $sabg2 -highlightbackground $sabg2
  text $colstuf.lab -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -height 12

  $colstuf.lab tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
  $colstuf.lab tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
  $colstuf.lab tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*
  $colstuf.lab tag configure creallybig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-180-*-*-*-*-*-* -justify center
  set text "      Colors      \n\n"
  $colstuf.lab insert end "$text" creallybig
  set text "	Click below on the type of window whose colors you want to set. A sample window\
    will pop up, decked out in the colors of that window type, and allow you to set the window-specific\
    attributes.\n	The Main window colors are also used for all of the file/directory listboxes and various\
    other general purposes."
  $colstuf.lab insert end $text big

  $colstuf.lab configure -wrap word -state disabled -relief flat

  set colbut1 "$colstuf.bf1"
  frame $colbut1 -bg $sabg2
  set cmd "SASample $win 0"
  radiobutton $colbut1.main  -variable colset -value 0  -text "Main              " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 16 -command "$cmd 0"
  radiobutton $colbut1.tar   -variable colset -value 3  -text "Tar               " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 16 -command "$cmd 3"
  radiobutton $colbut1.tgz   -variable colset -value 1  -text "Gzipped Tar    " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 16 -command "$cmd 1"
  radiobutton $colbut1.taz   -variable colset -value 5  -text "Compressed Tar " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 20 -command "$cmd 5"

  set colbut2 "$colstuf.bf2"
  frame $colbut2 -bg $sabg2
  radiobutton $colbut2.gzp   -variable colset -value 4  -text "Gzip               " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 16 -command "$cmd 4"
  radiobutton $colbut2.bzp   -variable colset -value 17 -text "Bzip             " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 16 -command "$cmd 17"
  radiobutton $colbut2.cmp   -variable colset -value 6  -text "Compress       " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 16 -command "$cmd 6"
  radiobutton $colbut2.tbz   -variable colset -value 18 -text "Bzipped Tar        " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 20 -command "$cmd 18"

  set colbut3 "$colstuf.bf3"
  frame $colbut3 -bg $sabg2
  radiobutton $colbut3.arj   -variable colset -value 10 -text "Arj                 " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 16 -command "$cmd 10"
  radiobutton $colbut3.rar   -variable colset -value 11 -text "Rar              " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 16 -command "$cmd 11"
  radiobutton $colbut3.shn   -variable colset -value 12 -text "Shorten          " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 16 -command "$cmd 12"
  radiobutton $colbut3.ar    -variable colset -value 9  -text "Ar Archive         " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 20 -command "$cmd 9"

  set colbut4 "$colstuf.bf4"
  frame $colbut4 -bg $sabg2
  radiobutton $colbut4.lha   -variable colset -value 15 -text "Lharc              " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 16 -command "$cmd 15"
  radiobutton $colbut4.cpio  -variable colset -value 16 -text "Cpio               " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 16 -command "$cmd 16"
  radiobutton $colbut4.zip   -variable colset -value 2  -text "Zip                " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 16 -command "$cmd 2"
  radiobutton $colbut4.zipx  -variable colset -value 7  -text "DOS Zip executable " \
    -anchor w -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 20 -command "$cmd 7"
#  label $colbut4.pad1 -text "                      " \
#    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 18
#  label $colbut4.pad2 -text "                      " \
#    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 19

  set colbut5 "$colstuf.bf5"
  frame $colbut5 -bg $sabg2
  radiobutton $colbut5.sysinf   -variable colset -value 101 -text "SysInfo              " \
    -anchor nw -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 16 -command "$cmd 101"
  radiobutton $colbut5.hlp  -variable colset -value 102 -text "Help               " \
    -anchor nw -justify left \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 -width 16 -command "$cmd 102"
  label $colbut5.pad1 -text "                      " \
    -bg $sabg2 -fg $safg2 -highlightbackground $sabg2 

  pack $colbut1.main $colbut1.tar  $colbut1.tgz  $colbut1.taz  -side left
  pack $colbut2.gzp  $colbut2.bzp  $colbut2.cmp  $colbut2.tbz  -side left
  pack $colbut3.arj  $colbut3.rar  $colbut3.shn  $colbut3.ar   -side left
  pack $colbut4.lha  $colbut4.cpio $colbut4.zip $colbut4.zipx  -side left
  pack $colbut5.sysinf  $colbut5.hlp -anchor nw -side left -fill none
  pack $colbut5.pad1 -side right -fill x

  pack $colstuf.lab -side top -fill x -expand no
#  pack $colbut1 -side top
#  pack $colbut2 -side top
#  pack $colbut3 -side top
#  pack $colbut4 -side top
  pack $colbut1 $colbut2 $colbut3 $colbut4 $colbut5 -side top -anchor nw -fill x -expand yes

  set dummy "$colstuf.dummyf"
  frame $dummy -bg $sabg2
  label $dummy.dum -bg $sabg2 -text "            "
  pack $dummy.dum -fill both -expand yes
  pack $dummy -anchor sw -side top -fill both -expand yes

#  pack $scrstuf $colstuf -side top -fill x -expand yes
  pack $colstuf -side top -fill x -expand yes

  pack $winframe2.f1 $winframe2.f2 -side left -fill both -expand yes

  pack $winframe2 -side top -fill both -expand yes
  pack $buttons -side top -pady 8
  pack $winframe -expand yes

  }


return 1
}


#-------------------------------------------------
#  SetApp2  --  Pop up Scrollbar dialogue
#
#  Note: scale value of -1 = Use TkZip default
#                       -2 = Use Tk default
#
#-------------------------------------------------
proc SetApp2 {} {
global MenuHelp PgmName WhoBg
global DSlidBg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg
#global hth ebw wid tcol slbg
#global wnum
global GlSl GlTr Gscol Gtcol
global TkzG


if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 44
  return 1
  }

set thisproc "SetApp2"
#set sabg $WhoBg
set wno 103
#set sabg2 "RoyalBlue4"
set sabg2 "#10366e"
set safg2 $TwFg($wno)
set sabutbg $TwButBg(0)
set sabutfg $TwButFg(0)
#set sabg "IndianRed4"
#set safg "AntiqueWhite"
set sabg $TwBg($wno)
set safg $TwFg($wno)
set tc "green"
set colset 0
set gslcol 1
set gtrcol 1
set Gscol $DSlidBg
set Gtcol $TwBg($wno)
set GlSl 0
set GlTr 0


set wn "sascroll"
set win ".$wn"
set wintitle "$PgmName: Set Appearance"

if [catch {toplevel $win} rc]  {
  if {[wm state $win] == "iconic"}  {
    wm deiconify $win
    }
  raise $win
  }  else  {
  wm title $win $wintitle
  wm iconname $win $wintitle

  set hth $TkzG(TrHTh)
  set ebw $TkzG(TrEBw)
  set wid $TkzG(TrW)
  set tcol $TwBg($wno)
#  set slbg $SlidBg(0)
  set slbg $DSlidBg

  set winframe "$win.f"
  frame $winframe -bg $sabg
  set winframe2 "$winframe.f2"
  frame $winframe2 -bg $sabg
  frame $winframe2.f1 -bg $sabg
  frame $winframe2.f2 -bg $sabg
  set buttons "$winframe.but1"
  frame $buttons -bg $sabg
  set cmd "KillSetapp2 $win"
  button $buttons.exit -bg $sabutbg -text "Dismiss" -command $cmd
  set cmd "OkSetapp2 $win"
  button $buttons.ok -bg $sabutbg -text "OK" -command $cmd
  set cmd "ApplySetapp2 $win"
  button $buttons.apply -bg $sabutbg -text "Apply" -command $cmd

  pack $buttons.exit $buttons.ok $buttons.apply -side left

  set scrstuf "$winframe2.f1.scrf"
  set scrstuf1 "$winframe2.f1.scrf.f1"
  set scrstuf2 "$winframe2.f1.scrf2"
  set scrstuf3 "$winframe2.f1.scrf3"
  frame $scrstuf -bg $sabg
  frame $scrstuf1 -bg $sabg2
  frame $scrstuf2 -bg $sabg
  frame $scrstuf3 -bg $sabg

  label $scrstuf.lab -bg $sabg -fg $safg -text "Scrollbar Appearance" 
  label $scrstuf.lab3 -bg $sabg -fg $safg -text " -3 = Use the Tk Default" 
#  label $scrstuf.lab4 -bg $sabg -fg $safg -text " -2 = Use TkZip Default " 
  label $scrstuf.lab4 -bg $sabg -fg $safg -text " -2 = Use $PgmName Default " 

  scrollbar $scrstuf1.scr -orient horizontal \
    -troughcolor $Gtcol -bg $Gscol 
#    -troughcolor $tcol -bg $slbg 
  scale $scrstuf.hth -variable hth -label "Highlight Thickness" -orient horizontal \
    -borderwidth 3 -bg $sabg -troughcolor $tc -from -3 -to 6 -length 140 -command RefApp2 
  scale $scrstuf.ebw -variable ebw -label "Element Border Width" -orient horizontal \
    -borderwidth 3 -bg $sabg -troughcolor $tc -from -3 -to 6 -length 140 -command RefApp2 
  scale $scrstuf.wid -variable wid -label "Scrollbar Width" -orient horizontal \
    -borderwidth 3 -bg $sabg -troughcolor $tc -from -3 -to 24 -length 140 -command RefApp2
  pack $scrstuf1.scr -side top -pady 10 -padx 6 -fill x
  pack $scrstuf.lab -side top -pady 6 
  pack $scrstuf.lab3 -side top
  pack $scrstuf.lab4 -side top -pady 6
  pack $scrstuf1 -side top -expand yes -fill x -padx 3 -pady 3
  pack $scrstuf.wid $scrstuf.ebw $scrstuf.hth \
    -side top -expand yes -pady 3

  set cmd "ColorSliders"
  checkbutton $scrstuf2.lab1 -text "Set All Slider Colors:"  \
    -bg $sabg -highlightbackground $sabg -fg $safg \
    -variable GlSl -command "$cmd 0"
  radiobutton $scrstuf2.slc1 -variable gslcol -value 0 -text "Tk" \
    -anchor w -justify left -state disabled \
    -bg $sabg -fg $safg -highlightbackground $sabg -width 2 -command "$cmd 1"
  radiobutton $scrstuf2.slc2 -variable gslcol -value 1 -text "$PgmName" \
    -anchor w -justify left -state disabled \
    -bg $sabg -fg $safg -highlightbackground $sabg -width 4 -command "$cmd 2"
  radiobutton $scrstuf2.slc3 -variable gslcol -value 2 -text "Custom" \
    -anchor w -justify left -state disabled \
    -bg $sabg -fg $safg -highlightbackground $sabg -width 6 -command "$cmd 3"
  $scrstuf2.slc1 deselect
  $scrstuf2.slc2 deselect
  $scrstuf2.slc3 deselect
  pack $scrstuf2.lab1 -side top -anchor w
  pack $scrstuf2.slc1 $scrstuf2.slc2 $scrstuf2.slc3 -side left

  set cmd "ColorTroughs"
  checkbutton $scrstuf3.lab1 -text "Set All Trough Colors:"  \
    -bg $sabg -highlightbackground $sabg -fg $safg \
    -variable GlTr -command "$cmd 0"
  radiobutton $scrstuf3.trc1 -variable gtrcol -value 0 -text "Tk" \
    -anchor w -justify left -state disabled \
    -bg $sabg -fg $safg -highlightbackground $sabg -width 2 -command "$cmd 1"
  radiobutton $scrstuf3.trc2 -variable gtrcol -value 1 -text "$PgmName" \
    -anchor w -justify left -state disabled \
    -bg $sabg -fg $safg -highlightbackground $sabg -width 4 -command "$cmd 2"
  radiobutton $scrstuf3.trc3 -variable gtrcol -value 2 -text "Custom" \
    -anchor w -justify left -state disabled \
    -bg $sabg -fg $safg -highlightbackground $sabg -width 6 -command "$cmd 3"
  $scrstuf3.trc1 deselect
  $scrstuf3.trc2 deselect
  $scrstuf3.trc3 deselect
#  pack $scrstuf2.lab1 -side top -anchor w
#  pack $scrstuf2.slc1 $scrstuf2.slc2 $scrstuf2.slc3 -side left
  pack $scrstuf3.lab1 -side top -anchor w
  pack $scrstuf3.trc1 $scrstuf3.trc2 $scrstuf3.trc3 -side left

#  pack $scrstuf $colstuf -side top -fill x -expand yes
  pack $scrstuf -side top -fill x -expand yes
  pack $scrstuf2 -side top -fill x -expand yes
  pack $scrstuf3 -side top -fill x -expand yes

  pack $winframe2.f1 -side left -fill both -expand yes

  pack $winframe2 -side top -fill both -expand yes
  pack $buttons -side top -pady 8
  pack $winframe -expand yes

  }


return 1
}



#------------------------------------------------------
#  KillSetapp  --  in case any special cleanup needed 
#------------------------------------------------------
proc KillSetapp {win}  {
global hth ebw wid tcol slbg
global TkzG

set win ".sasamp"
if {! [catch {wm state $win}]}  {
  KillSetapp1 $win
  }
set win ".sascroll"
if {! [catch {wm state $win}]}  {
  KillSetapp2 $win
  }
set win ".setapp"
destroy $win

return 1
}

#------------------------------------------------------
#  KillSetapp1  --  in case any special cleanup needed 
#------------------------------------------------------
proc KillSetapp1 {win}  {
global hth ebw wid tcol slbg
global TkzG

destroy $win
return 1
}

#------------------------------------------------------
#  KillSetapp2  --  in case any special cleanup needed 
#------------------------------------------------------
proc KillSetapp2 {win}  {
global hth ebw wid tcol slbg
global TkzG

destroy $win
#unset hth ebw wid tcol slbg
return 1
}


#------------------------------------------------------
#  ColorSliders  --  Set global color for all sliders
#------------------------------------------------------
proc ColorSliders {func}  {
global DSlidBg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg
global hth ebw wid tcol slbg
global sabg safg sabutbg sabutfg sabg2 safg2 wnum
global saentbg saentfg saselbg saselfg
global TkVer
global GlSl GlTr Gscol Gtcol
global TkzG

set win ".sascroll"
set wno 103
set buttons "$win.f.f2.f1.scrf2"
set bar "$win.f.f2.f1.scrf.f1.scr"

if {$func == 0}  {
  if {$GlSl}  {
    $buttons.slc1 configure -state normal
    $buttons.slc2 configure -state normal
    $buttons.slc3 configure -state normal
    $buttons.slc2 select
    set Gscol "UseDefault"
    }  else  {
    $buttons.slc1 configure -state disabled
    $buttons.slc2 configure -state disabled
    $buttons.slc3 configure -state disabled
    $buttons.slc1 deselect
    $buttons.slc2 deselect
    $buttons.slc3 deselect
    }
  return
  }

set tmp [$bar configure -bg]
set bartk [lindex $tmp 3]
set barcol [lindex $tmp 4]

switch  $func  {
  1   {
    set Gscol "UseTk"
    set SlidBg($wno) $Gscol
    ConfigureScrollbar $bar $wno 1
    }
  2   {
    set Gscol "UseDefault"
    set SlidBg($wno) $Gscol
    ConfigureScrollbar $bar $wno 1
    }
  3   {
    set tmp [tk_chooseColor -initialcolor $barcol]
    if {$tmp != ""}  {
      set Gscol $tmp
      set SlidBg($wno) $Gscol
      ConfigureScrollbar $bar $wno 1
      }
    }

  }


return
}

#------------------------------------------------------
#  ColorTroughs  --  Set global color for all troughs
#------------------------------------------------------
proc ColorTroughs {func}  {
global DSlidBg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg
global hth ebw wid tcol slbg
global sabg safg sabutbg sabutfg sabg2 safg2 wnum
global saentbg saentfg saselbg saselfg
global TkVer
global GlSl GlTr Gscol Gtcol
global TkzG


set win ".sascroll"
set wno 103
set buttons "$win.f.f2.f1.scrf3"
set bar "$win.f.f2.f1.scrf.f1.scr"

if {$func == 0}  {
  if {$GlTr}  {
    $buttons.trc1 configure -state normal
    $buttons.trc2 configure -state normal
    $buttons.trc3 configure -state normal
    $buttons.trc2 select
    set Gtcol "UseBg"
    }  else  {
    $buttons.trc1 configure -state disabled
    $buttons.trc2 configure -state disabled
    $buttons.trc3 configure -state disabled
    $buttons.trc1 deselect
    $buttons.trc2 deselect
    $buttons.trc3 deselect
    }
  return
  }

set tmp [$bar configure -troughcolor]
set bartk [lindex $tmp 3]
set barcol [lindex $tmp 4]

switch  $func  {
  1   {
    set Gtcol "UseTk"
    set TrCol($wno) $Gtcol
    ConfigureScrollbar $bar $wno 1
    }
  2   {
    set Gtcol "UseBg"
    set TrCol($wno) $Gtcol
    ConfigureScrollbar $bar $wno 1
    }
  3   {
    set tmp [tk_chooseColor -initialcolor $barcol]
    if {$tmp != ""}  {
      set Gtcol $tmp
    set TrCol($wno) $Gtcol
    ConfigureScrollbar $bar $wno 1
      }
    }

  }



return
}


#------------------------------------------------------
#  ApplySetapp  --  Apply SetAppearance changes 
#------------------------------------------------------
proc ApplySetapp {win}  {
global DSlidBg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg
global hth ebw wid tcol slbg
global sabg safg sabutbg sabutfg sabg2 safg2 wnum
global saentbg saentfg saselbg saselfg
global TkVer
global TkzG

set win ".sascroll"
if {! [catch {wm state $win}]}  {
  ApplySetapp2 $win
  }
set win ".sasamp"
if {! [catch {wm state $win}]}  {
  ApplySetapp1 $win
  }


return
}


#----------------------------------------------------------
#  DefaultSetapp  --  Restore all TkZip appearance defaults 
#----------------------------------------------------------
proc DefaultSetapp {win}  {
global DSlidBg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg
global hth ebw wid tcol slbg
global sabg safg sabutbg sabutfg sabg2 safg2 wnum
global saentbg saentfg saselbg saselfg
global PgmName TkVer DfltCfg
global TkzG


#  For future use...
set dfltrc1 "$TkzG(TkzDir)/Default1.rc"
set dfltrc2 "$TkzG(TkzDir)/Default2.rc"
KillSetapp $win

if {$DfltCfg == 0}  {
  SetDefaultColors
  SetDefaultScroll
  }
if {$DfltCfg == 1}  {
  if {[file exists $dfltrc1]}  {
    LoadConfigFile $dfltrc1
    }  else  {
    SetDefaultColors
    SetDefaultScroll
    }
  }
if {$DfltCfg == 2}  {
  if {[file exists $dfltrc2]}  {
    LoadConfigFile $dfltrc2
    }  else  {
    SetDefaultColors
    SetDefaultScroll
    }
  }

ConfigAllWins
SetAppearance

return
}

#------------------------------------------------------
#  ApplySetapp1  --  Apply Color changes 
#------------------------------------------------------
proc ApplySetapp1 {win}  {
global DSlidBg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg
global EntBg EntFg SelBg SelFg
global hth ebw wid tcol slbg
global sabg safg sabutbg sabutfg sabg2 safg2 wnum
global saentbg saentfg saselbg saselfg
global TkVer
global TkzG

set win ".setapp"
#set bar "$win.f.f2.f1.scrf.f1.scr"
set bar ".main.list1.diry"
set wnum2 ""
#  Bzips - set both
if {$wnum == 17}  {
  set wnum2 13
  }
#  Cpios & Rpms take the same color
if {$wnum == 16}  {
  set wnum2 19
  }
#  Bzipped tars - set both
if {$wnum == 18}  {
  set wnum2 14
  }


if {[info exists sabg] && $TkVer > 4.1}  {
#  OK, update the colors
  set TwBg($wnum)    $sabg
  set TwFg($wnum)    $safg
  set TwButBg($wnum) $sabutbg
  set TwButFg($wnum) $sabutfg
  set TwLBg($wnum)   $sabg2
  set TwLFg($wnum)   $safg2
  set EntBg($wnum)   $saentbg
  set EntFg($wnum)   $saentfg
  set SelBg($wnum)   $saselbg
  set SelFg($wnum)   $saselfg
  if {$wnum2 != ""}  {
    set TwBg($wnum2)    $sabg
    set TwFg($wnum2)    $safg
    set TwButBg($wnum2) $sabutbg
    set TwButFg($wnum2) $sabutfg
    set TwLBg($wnum2)   $sabg2
    set TwLFg($wnum2)   $safg2
    set EntBg($wnum2)   $saentbg
    set EntFg($wnum2)   $saentfg
    set SelBg($wnum2)   $saselbg
    set SelFg($wnum2)   $saselfg
    }
  }

#  Set the scrollbar colors
if {$tcol == -2 || $tcol == "UseBg"}  {
#  set TrCol($wnum) $sabg
  set TrCol($wnum) "UseBg"
  }  else  {
  if {$tcol == -1 || $tcol == "UseTk"}  {
#    set tmp [$bar configure -troughcolor]
#    set TrCol($wnum) [lindex $tmp 3]
    set TrCol($wnum) "UseTk"
    }  else  {
    set TrCol($wnum) $tcol
    }
  }
if {$slbg == -2 || $slbg == "UseDefault"}  {
#  set SlidBg($wnum) $DSlidBg
  set SlidBg($wnum) "UseDefault"
  }  else  {
  if {$slbg == -1 || $slbg == "UseTk"}  {
#    set tmp [$bar configure -bg]
#    set SlidBg($wnum) [lindex $tmp 3]
    set SlidBg($wnum) "UseTk"
    }  else  {
    set SlidBg($wnum) $slbg
    }
  }
if {$wnum2 != ""}  {
  set TrCol($wnum2) $TrCol($wnum)
  set SlidBg($wnum2) $SlidBg($wnum)
  }


#SASample $win 1 $wnum
#  Need a RedrawDirs func, and a RedrawArcs, and RedrawMain...?
#  Worth the trouble?
#RefDirs ""
ConfigAllWins

return 1
}

#------------------------------------------------------
#  ApplySetapp2  --  Apply Scrollbar changes 
#------------------------------------------------------
proc ApplySetapp2 {win}  {
global DSlidBg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg
global hth ebw wid tcol slbg
global sabg safg sabutbg sabutfg sabg2 safg2 wnum
global saentbg saentfg saselbg saselfg
global TkVer GlSl GlTr Gscol Gtcol
global NumWins SpecWinFirst SpecWinLast
global TkzG

set win ".sascroll"

set bar ".main.list1.diry"

if {$wid == -2}  {
  set wid 12
  }  else  {
  if {$wid == -3}  {
    set tmp [$bar configure -width]
    set wid [lindex $tmp 3]
    }
  }
set TkzG(TrW) $wid

if {$hth == -2}  {
  set hth 1
  }  else  {
  if {$hth == -3}  {
    set tmp [$bar configure -highlightthickness]
    set hth [lindex $tmp 3]
    }
  }
set TkzG(TrHTh) $hth

if {$ebw == -2}  {
  set ebw 3
  }  else  {
  if {$ebw == -3}  {
    set tmp [$bar configure -elementborderwidth]
    set ebw [lindex $tmp 3]
    }
  }
set TkzG(TrEBw) $ebw

#  Now apply any global scrollbar color changes
#  (pending single window changes will override these,
#  for that window)...
if {$GlSl || $GlTr}  {
  set i 0
  while {$i < $NumWins}  {
    if {$GlSl}  {
      set SlidBg($i) $Gscol
      }
    if {$GlTr}  {
      set TrCol($i) $Gtcol
      }
    incr i
    }
  set i $SpecWinFirst
  while {$i <= $SpecWinLast}  {
    if {$GlSl}  {
      set SlidBg($i) $Gscol
      }
    if {$GlTr}  {
      set TrCol($i) $Gtcol
      }
    incr i
    }
  }


RefApp2 $win
#SASample $win 1 $wnum
#  Need a RedrawDirs func, and a RedrawArcs, and RedrawMain...?
#  Worth the trouble?
#RefDirs ""
ConfigAllWins

return 1
}

#------------------------------------------------------
#  SAColor  --  Select a color and update sample window 
#------------------------------------------------------
proc SAColor {win num cnum}  {
global DSlidBg
global TwBg TwFg TwButBg TwLBg TwLFg TrCol SlidBg DSlidBg
global hth ebw wid tcol slbg tcol1 slbg1
global sabg safg sabutbg sabutfg sabg2 safg2 wnum
global saentbg saentfg saselbg saselfg
global TkVer PgmName
global TkzG

if {$TkVer < 4.2 && $cnum < 9}  {
  return 1
  }
if {$TkVer < 4.2 && $cnum > 12 && $cnum < 17}  {
  return 1
  }


#set bar "$win.listf.sby"
set bar ".main.list1.diry"
#  Do the color dialogue
switch  $cnum  {

  1  {
    set tmp [tk_chooseColor -initialcolor $sabg]
    if {$tmp != ""}  {
      set sabg $tmp
      }
    }
  2  {
    set tmp [tk_chooseColor -initialcolor $safg ]
    if {$tmp != ""}  {
      set safg $tmp
      }
    }
  3  {
    set tmp [tk_chooseColor -initialcolor $sabutbg ]
    if {$tmp != ""}  {
      set sabutbg $tmp
      }
    }
  4  {
    set tmp [tk_chooseColor -initialcolor $sabutfg ]
    if {$tmp != ""}  {
      set sabutfg $tmp
      }
    }
  5  {
    set tmp [tk_chooseColor -initialcolor $sabg2 ]
    if {$tmp != ""}  {
      set sabg2 $tmp
      }
    }
  6  {
    set tmp [tk_chooseColor -initialcolor $safg2 ]
    if {$tmp != ""}  {
      set safg2 $tmp
      }
    }
  7  {
    set tmp [tk_chooseColor -initialcolor $slbg1 ]
    if {$tmp != ""}  {
      set slbg $tmp
      set slbg1 $slbg
      }
    }
  8  {
    set tmp [tk_chooseColor -initialcolor $tcol1 ]
    if {$tmp != ""}  {
      set tcol $tmp
      set tcol1 $tcol
      }
    }
  9  {
    set slbg "UseTk"
    set tmp [$bar configure -bg]
    set slbg1 [lindex $tmp 3]
    }

  10 {
    set slbg "UseDefault"
    set slbg1 $DSlidBg
    }

  11 {
    set tcol "UseTk"
    set tmp [$bar configure -troughcolor]
    set tcol1 [lindex $tmp 3]
    }

  12  {
    set tcol "UseBg"
    set tcol1 $sabg
    }

  13  {
    set tmp [tk_chooseColor -initialcolor $saentbg]
    if {$tmp != ""}  {
      set saentbg $tmp
      }
    }

  14  {
    set tmp [tk_chooseColor -initialcolor $saentfg]
    if {$tmp != ""}  {
      set saentfg $tmp
      }
    }

  15  {
    set tmp [tk_chooseColor -initialcolor $saselbg]
    if {$tmp != ""}  {
      set saselbg $tmp
      }
    }

  16  {
    set tmp [tk_chooseColor -initialcolor $saselfg]
    if {$tmp != ""}  {
      set saselfg $tmp
      }
    }

  default  {
    puts "$PgmName Pgm Bug:  invalid setcolor func. $cnum"
    }
  }

#  Refresh the sample win...
SASample $win 1 $wnum

return 1
}


#----------------------------------------------------------
#  OkSetapp  --  Apply appearance changes and exit dialogue
#----------------------------------------------------------
proc OkSetapp {win}  {
global wnum
global TkzG

ApplySetapp $win 
KillSetapp $win

return 1
}

#-----------------------------------------------------------
#  OkSetapp1  --  Apply appearance changes and exit dialogue
#-----------------------------------------------------------
proc OkSetapp1 {win}  {
global wnum
global TkzG

ApplySetapp1 $win 
KillSetapp1 $win

return 1
}

#-----------------------------------------------------------
#  OkSetapp2  --  Apply appearance changes and exit dialogue
#-----------------------------------------------------------
proc OkSetapp2 {win}  {
global wnum
global TkzG

ApplySetapp2 $win 
KillSetapp2 $win

return 1
}

#----------------------------------------------------------
#  RefApp2  --  Update the sample scrollbar
#----------------------------------------------------------
proc RefApp2 {dummy}  {
global hth ebw wid tcol slbg
global TkzG

set win ".sascroll"
set bar "$win.f.f2.f1.scrf.f1.scr"
$bar configure -width $wid -elementborderwidth $ebw -highlightthickness $hth

return 1
}

#----------------------------------------------------------
#  SASample  --  Show a sample window for setting colors
#----------------------------------------------------------
proc SASample {win ref num}  {
global PgmName DSlidBg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg
global DSlidBg EntBg EntFg SelBg SelFg
global hth ebw wid tcol slbg tcol1 slbg1
global sabg safg sabutbg sabutfg sabg2 safg2 wnum
global saentbg saentfg saselbg saselfg
global dummyent
global TkzG

set wnum $num
set bar ".main.list1.diry"
set dummyent "A Sample Entry Field"

set wn "sasamp"
set win ".$wn"
set wintitle "$PgmName: Sample Window"
set topf "$win.topf"
set buttons "$win.buttons"
set buttons2 "$win.buttons2"
set buttons3 "$win.buttons3"
set buttons4 "$win.buttons4"
set buttons5 "$win.buttons5"
set listf "$win.listf"

if [catch {toplevel $win} rc]  {
  if {[wm state $win] == "iconic"}  {
    wm deiconify $win
    }
  raise $win
  if {! $ref}  {
    set sabg $TwBg($num)
    set safg $TwFg($num)
    set sabutbg $TwButBg($num)
    set sabutfg $TwButFg($num)
    set sabg2 $TwLBg($num)
    set safg2 $TwLFg($num)
    set saentbg $EntBg($num)
    set saentfg $EntFg($num)
    set saselbg $SelBg($num)
    set saselfg $SelFg($num)
    set tcol $TrCol($num)
    set slbg $SlidBg($num)
    if {$slbg != "UseTk"}  {
      if {$slbg == "UseDefault"}  {
        set slbg1 $DSlidBg
        }  else  {
        set slbg1 $SlidBg($num)
        }
      }  else  {
      set tmp [$bar configure -bg]
      set slbg1 [lindex $tmp 3]
      }
    if {$tcol1 != "UseTk"}  {
      if {$tcol == "UseBg"}  {
        set tcol1 $sabg
        }  else  {
        set tcol1 $TrCol($num)
        }
      }  else  {
      set tmp [$bar configure -troughcolor]
      set tcol1 [lindex $tmp 3]
      }
    }
  $topf configure -bg $sabg
  $topf.lab1 configure -bg $sabg -fg $safg
  $topf.lab2 configure -bg $sabg -fg $safg
  $topf.lab3 configure -bg $sabg -fg $safg
  $topf.lab4 configure -bg $sabg -fg $safg
  $topf.lab5 configure -bg $sabg -fg $safg
  $topf.lab6 configure -bg $sabg -fg $safg
  $topf.lab7 configure -bg $sabg -fg $safg
  $topf.lab8 configure -bg $sabg -fg $safg
  $topf.lab9 configure -bg $sabg -fg $safg
  $buttons configure -bg $sabg
  $buttons.setbg configure -bg $sabutbg -fg $sabutfg
  $buttons.setfg configure -bg $sabutbg -fg $sabutfg
  $buttons.setbutbg configure -bg $sabutbg -fg $sabutfg
  $buttons.setbutfg configure -bg $sabutbg -fg $sabutfg
  $buttons.setlbg configure -bg $sabutbg -fg $sabutfg
  $buttons.setlfg configure -bg $sabutbg -fg $sabutfg
#  $buttons.setslc configure -bg $sabutbg -fg $sabutfg
#  $buttons.settrc configure -bg $sabutbg -fg $sabutfg
  $buttons2 configure -bg $sabg
  $buttons2.setsld configure -bg $sabg -fg $safg
  $buttons2.setsltk configure -bg $sabutbg -fg $sabutfg
  $buttons2.setsltkz configure -bg $sabutbg -fg $sabutfg
  $buttons2.setslc configure -bg $sabutbg -fg $sabutfg
  $buttons3 configure -bg $sabg
  $buttons3.settrcl configure -bg $sabg -fg $safg
  $buttons3.settrtk configure -bg $sabutbg -fg $sabutfg
  $buttons3.settrtkz configure -bg $sabutbg -fg $sabutfg
  $buttons3.settrc configure -bg $sabutbg -fg $sabutfg
  $buttons4 configure -bg $sabg
  $buttons4.pad1 configure -bg $sabg -fg $safg
  $buttons4.setebg configure -bg $sabutbg -fg $sabutfg
  $buttons4.setefg configure -bg $sabutbg -fg $sabutfg
  $buttons4.setsbg configure -bg $sabutbg -fg $sabutfg
  $buttons4.setsfg configure -bg $sabutbg -fg $sabutfg
  $buttons5 configure -bg $sabg
  $buttons5.pad1 configure -bg $sabg -fg $safg
  $buttons5.quit configure -bg $sabutbg -fg $sabutfg
  $buttons5.ok configure -bg $sabutbg -fg $sabutfg
  $buttons5.apply configure -bg $sabutbg -fg $sabutfg
  $buttons5.pad2 configure -bg $sabg -fg $safg
  $buttons5.ent1 configure -bg $saentbg -fg $saentfg
  $listf  configure -bg $sabg2

  $listf.fakelist configure -bg $sabg2 -fg $safg2 \
    -selectbackground $saselbg -selectforeground $saselfg
  $listf.sby configure -bg $slbg1 -troughcolor $tcol1 \
    -width $wid -elementborderwidth $ebw -highlightthickness $hth
  }  else  {
  set sabg $TwBg($num)
  set safg $TwFg($num)
  set sabutbg $TwButBg($num)
  set sabutfg $TwButFg($num)
  set sabg2 $TwLBg($num)
  set safg2 $TwLFg($num)
  set saentbg $EntBg($num)
  set saentfg $EntFg($num)
  set saselbg $SelBg($num)
  set saselfg $SelFg($num)
  set tcol $TrCol($num)
  set slbg $SlidBg($num)

  if {$slbg != "UseTk"}  {
    if {$slbg == "UseDefault"}  {
      set slbg1 $DSlidBg
      }  else  {
      set slbg1 $SlidBg($wnum)
      }
    }  else  {
    set tmp [$bar configure -bg]
    set slbg1 [lindex $tmp 3]
    }
  if {$tcol != "UseTk"}  {
    if {$tcol == "UseBg"}  {
      set tcol1 $sabg
      }  else  {
      set tcol1 $TrCol($wnum)
      }
    }  else  {
    set tmp [$bar configure -troughcolor]
    set tcol1 [lindex $tmp 3]
    }

  wm title $win $wintitle
  wm iconname $win $wintitle

  frame $topf -bg $sabg -highlightbackground $sabg
  label $topf.lab1 -bg $sabg -fg $safg -width 32 \
    -text "                  " \
    -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-80-*-*-*-*-*-*
  label $topf.lab2 -bg $sabg -fg $safg -width 32   -text "  Official Sample Window  " \
    -anchor center -justify center
  label $topf.lab3 -bg $sabg -fg $safg -width 32   -text "                  "
  label $topf.lab4 -bg $sabg -width 32   -text "This is the Top Frame" \
    -anchor center -justify center
  label $topf.lab5 -bg $sabg -width 32 \
    -text "                                " \
    -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-80-*-*-*-*-*-*
#  entry $topf.lab5 -bg $sabg -width 32  -state disabled
  label $topf.lab6 -bg $sabg -fg $safg -text "Use the buttons below to set the colors for the various window" \
    -anchor nw -justify left \
    -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-*
  label $topf.lab7 -bg $sabg -fg $safg -text "components (requires Tk 4.2 or higher).   " \
    -anchor nw -justify left \
    -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-*
  label $topf.lab8 -bg $sabg -width 32 \
    -text "                                " \
    -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-80-*-*-*-*-*-* \
    -anchor nw -justify left
  label $topf.lab9 -bg $sabg -width 32 \
    -text "                                " \
    -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-80-*-*-*-*-*-* \
    -anchor nw -justify left
  frame $buttons -bg $sabg
  set cmd "SAColor $win $num 1"
  button $buttons.setbg -bg $sabutbg -fg $sabutfg -text "Top BG" -command $cmd
  set cmd "SAColor $win $num 2"
  button $buttons.setfg -bg $sabutbg -fg $sabutfg -text "Top FG" -command $cmd
  set cmd "SAColor $win $num 3"
  button $buttons.setbutbg -bg $sabutbg -fg $sabutfg -text "Button BG" -command $cmd
  set cmd "SAColor $win $num 4"
  button $buttons.setbutfg -bg $sabutbg -fg $sabutfg -text "Button FG" -command $cmd
  set cmd "SAColor $win $num 5"
  button $buttons.setlbg -bg $sabutbg -fg $sabutfg -text "List/Text BG" -command $cmd
  set cmd "SAColor $win $num 6"
  button $buttons.setlfg -bg $sabutbg -fg $sabutfg -text "List/Text FG" -command $cmd
#  set cmd "SAColor $win $num 7"
#  button $buttons.setslc -bg $sabutbg -fg $sabutfg -text "Slider" -command $cmd
#  set cmd "SAColor $win $num 8"
#  button $buttons.settrc -bg $sabutbg -fg $sabutfg -text "Trough" -command $cmd

  frame $buttons2 -bg $sabg -highlightbackground $sabg
  label $buttons2.setsld -bg $sabg -fg $safg -text "Slider Colors:    " \
    -width 16
  set cmd "SAColor $win $num 9"
  button $buttons2.setsltk -bg $sabutbg -fg $sabutfg -text "Use Tk Default" -command $cmd
  set cmd "SAColor $win $num 10"
  button $buttons2.setsltkz -bg $sabutbg -fg $sabutfg -text "Use $PgmName Default" -command $cmd
  set cmd "SAColor $win $num 7"
  button $buttons2.setslc -bg $sabutbg -fg $sabutfg -text "Set Color" -command $cmd

  frame $buttons3 -bg $sabg -highlightbackground $sabg
  label $buttons3.settrcl -bg $sabg -fg $safg -text "Trough Colors:    " \
    -width 16
  set cmd "SAColor $win $num 11"
  button $buttons3.settrtk -bg $sabutbg -fg $sabutfg -text "Use Tk Default" -command $cmd
  set cmd "SAColor $win $num 12"
  button $buttons3.settrtkz -bg $sabutbg -fg $sabutfg -text "Use $PgmName Default" -command $cmd
  set cmd "SAColor $win $num 8"
  button $buttons3.settrc -bg $sabutbg -fg $sabutfg -text "Set Color" -command $cmd

  frame $buttons4 -bg $sabg -highlightbackground $sabg
  label $buttons4.pad1 -bg $sabg -fg $safg -text "                " \
    -width 16
  set cmd "SAColor $win $num 13"
  button $buttons4.setebg  -bg $sabutbg -fg $sabutfg -text "Entry Bg" -command $cmd
  set cmd "SAColor $win $num 14"
  button $buttons4.setefg  -bg $sabutbg -fg $sabutfg -text "Entry Fg" -command $cmd
  set cmd "SAColor $win $num 15"
  button $buttons4.setsbg  -bg $sabutbg -fg $sabutfg -text "Select Bg" -command $cmd
  set cmd "SAColor $win $num 16"
  button $buttons4.setsfg  -bg $sabutbg -fg $sabutfg -text "Select Fg" -command $cmd

  frame $buttons5 -bg $sabg -highlightbackground $sabg
  label $buttons5.pad1 -bg $sabg -fg $safg -text "                " \
    -width 16
  set cmd "KillSetapp1 $win"
  button $buttons5.quit  -bg $sabutbg -fg $sabutfg -text "Dismiss" -command $cmd
  set cmd "OkSetapp1 $win"
  button $buttons5.ok  -bg $sabutbg -fg $sabutfg -text "OK" -command $cmd
  set cmd "ApplySetapp1 $win"
  button $buttons5.apply  -bg $sabutbg -fg $sabutfg -text "Apply" -command $cmd
  label $buttons5.pad2 -bg $sabg -fg $safg -text "    " \
    -width 4
  entry $buttons5.ent1 -bg $saentbg -fg $saentfg -textvariable dummyent \
    -state disabled

  set lw 76
  frame $listf -bg $sabg2
#  text $listf.fakelist
  listbox $listf.fakelist \
  -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
  scrollbar $listf.sby
#  set text "This is a list of stuff and \nthings to fill up a sample listbox... \nduhhh...  \
#    \n - get groceries \n - pick up laundry \n - reply to e-mail \n - unpack some archives \
#    \n - bad-mouth non-Unix systems \n - unpack some more files \n - eat \
#    \n - finish draft of \"Emacs - All the OS You'll Ever Need\" \n - reconfigure $PgmName colors \
#    \n - unpack a few more files \n - e-mail $PgmName author asking when he'll add an \"Uninstall Pkg\" option \
#    \n - reconfigure again and unpack one last file \n - sleep"
#  $listf.fakelist insert end $text
  $listf.fakelist insert end "This is a list of stuff and"
  $listf.fakelist insert end "things to fill up a sample listbox..."
  $listf.fakelist insert end "duhhh...  "
  $listf.fakelist insert end " - get groceries "
  $listf.fakelist insert end " - pick up laundry"
  $listf.fakelist insert end " - reply to e-mail"
  $listf.fakelist insert end " - unpack some archives "
  $listf.fakelist insert end " - bad-mouth non-Unix systems"
  $listf.fakelist insert end " - unpack some more files"
  $listf.fakelist insert end " - eat"
  $listf.fakelist insert end " - finish draft of \"Emacs - All the OS You'll Ever Need\""
  $listf.fakelist insert end " - reconfigure $PgmName colors"
  $listf.fakelist insert end " - unpack a few more files"
  $listf.fakelist insert end " - e-mail $PgmName author asking when he'll add an \"Uninstall Pkg\" option"
  $listf.fakelist insert end " - reconfigure again and unpack one last file"
  $listf.fakelist insert end " - sleep"
  set ycmd "$listf.sby set"
#  $listf.fakelist configure -bg $sabg2 -fg $safg2 -wrap word -state disabled \
#    -yscroll $ycmd  -height 10 -selectbackground $sabg
  $listf.fakelist configure -bg $sabg2 -fg $safg2 \
    -yscroll $ycmd  -height 10 \
    -selectbackground $saselbg -selectforeground $saselfg
  set ycmd "$listf.fakelist yview"
  $listf.sby configure -command $ycmd \
    -bg $slbg1 -troughcolor $tcol1 -width $wid -elementborderwidth $ebw -highlightthickness $hth


#  pack $topf.lab1 $topf.lab2 $topf.lab3 $topf.lab4 $topf.lab5 \
#    $topf.lab6 $topf.lab7 $topf.lab8 $topf.lab9  -side top
  pack $topf.lab1 $topf.lab2 \
    $topf.lab6 $topf.lab7  -side top
  pack $listf.fakelist -side left -fill x -expand yes
  pack $listf.sby -side right -fill y


#  pack $buttons.setbg $buttons.setfg $buttons.setbutbg $buttons.setbutfg $buttons.setlbg \
#    $buttons.setlfg $buttons.setslc $buttons.settrc $buttons.apply -side left
  pack $buttons.setbg $buttons.setfg $buttons.setbutbg $buttons.setbutfg $buttons.setlbg \
    $buttons.setlfg -side left -pady 6
  pack $buttons2.setsld $buttons2.setsltk $buttons2.setsltkz $buttons2.setslc -side left \
    -pady 6
  pack $buttons3.settrcl $buttons3.settrtk $buttons3.settrtkz $buttons3.settrc -side left \
    -pady 6
  pack $buttons4.pad1 $buttons4.setebg $buttons4.setefg $buttons4.setsbg $buttons4.setsfg \
    -side left \
    -pady 6
  pack $buttons5.pad1 $buttons5.quit $buttons5.ok $buttons5.apply \
    $buttons5.pad2 $buttons5.ent1  -side left \
    -pady 6
  pack $topf -side top -fill both -expand yes -anchor w
  pack $buttons -side top -fill both -expand yes -anchor w 
  pack $buttons4 -side top -fill both -expand yes -anchor w
  pack $buttons2 -side top -fill both -expand yes -anchor w
  pack $buttons3 -side top -fill both -expand yes -anchor w
  pack $buttons5 -side top -fill both -expand yes -anchor w
  pack $listf -side top -fill x -expand yes -anchor w

  }



return 1
}


#---------------------------------------------------
#  SetDefaultScroll  --  default scrollbar 3d-isness
#---------------------------------------------------
proc SetDefaultScroll {} {
global MainBg MainFg MainButBg WhoBg TBg TButBg TButFg TFg
global DSlidBg NumWins SpecWinFirst SpecWinLast
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global TkzG

#------------------------------------------
##  The slider sizes
set TkzG(TrW) 12
set TkzG(TrEBw) 3
set TkzG(TrHTh) 1
##  The default slider color - a charcoal grey
set DSlidBg "#202030"
#------------------------------------------

return
}


#-------------------------------------------------
#  SetDefaultColors  --  for all windows
#-------------------------------------------------
proc SetDefaultColors {} {
global MainBg MainFg MainButBg WhoBg TBg TButBg TButFg TFg
global DSlidBg NumWins SpecWinFirst SpecWinLast
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global TkzG

#------------------------------------------
set MainBg     "LightBlue"
set MainFg     "black"
set MainButBg  "SteelBlue"
set DisButFg   "Powder Blue"
set WhoBg      "AntiqueWhite"

set TkzG(MainTrCol) $MainButBg
set TkzG(MainSlidBg) "#202030"
#set TkzG(MainSlidBg) "$MainButBg"
#set TkzG(MainTrCol) "$WhoBg"


set TkzG(ColorHack) 1

#-----------------------------------
#  Colors for specific archive types...
#  One of these days we'll make this user-configurable
#-----------------------------------
set TBg        "LightGrey MediumSpringGreen DarkSeaGreen SteelBlue bisque DarkSlateGrey MistyRose4 red red   yellow RosyBrown CadetBlue sienna ForestGreen DarkSalmon IndianRed4 turquoise1 ForestGreen DarkSalmon turquoise1"
set TButBg     "bisque bisque bisque bisque sienna bisque bisque bisque bisque   bisque bisque bisque bisque bisque bisque bisque bisque bisque bisque bisque"
set TButFg     "black black black black black black black black black    black black black black black black black black black black black"
set TFg        "black black black black black LightYellow black black black    black black black black black bisque white black bisque white black"
set SFg        "white black white white sienna white white white white    black white white white white white white black white white black"
#-----------------------------------
#  New color and appearance handling
#  The slider sizes
#set TkzG(TrW) 12
#set TkzG(TrEBw) 3
#set TkzG(TrHTh) 1
#  The default slider color - a charcoal grey
set DSlidBg "#202030"
#  The main window colors
set TwBg(0)         "LightBlue"
set TwFg(0)         "black"
set TwButBg(0)      "SteelBlue"
set TwButFg(0)      "black"
set TwLBg(0)        "white"
set TwLFg(0)        "black"
set EntBg(0) "bisque"
set EntFg(0) "black"
set SelBg(0)        $TwButBg(0)
set SelFg(0)        "white"
set TrCol(0)        "UseBg"
set SlidBg(0)       "UseDefault"

set tmp 1
set tmp1 [llength $TBg]
while {$tmp < $tmp1}  {
  set TwBg($tmp) [lindex $TBg $tmp]
  set TwFg($tmp) [lindex $TFg $tmp]
  set TwButBg($tmp) [lindex $TButBg $tmp]
  set TwButFg($tmp) [lindex $TButFg $tmp]
  set TwLBg($tmp) "white"
  set TwLFg($tmp) "black"
  set TrCol($tmp) "UseBg"
  set SlidBg($tmp) "UseDefault"
  set EntBg($tmp) "bisque"
  set EntFg($tmp) "black"
  set SelBg($tmp) $TwBg($tmp)
  set SelFg($tmp) [lindex $SFg $tmp]
  incr tmp
  }
set SpecWinLast 104

#  Special windows - 101 = SysInfo,  102 = Help,
#  103 = Scrollbar config, 104 = Set Appearance
set NumWins $tmp1

#  Sysinfo
set SpecWinFirst 101
set tmp $SpecWinFirst
set TwBg($tmp) "MediumSpringGreen"
set TwFg($tmp) "black"
set TwButBg($tmp) "bisque"
set TwButFg($tmp) "black"
# Just here to keep arrays in sync...
set TwLBg($tmp) "white"
set TwLFg($tmp) "black"
set TrCol($tmp) "UseBg"
set SlidBg($tmp) "UseDefault"
set EntBg($tmp) "bisque"
set EntFg($tmp) "black"
set SelBg($tmp) $TwBg($tmp)
set SelFg($tmp) "black"

#  Help
incr tmp
set TwBg($tmp) "RosyBrown"
set TwFg($tmp) "black"
set TwButBg($tmp) "linen"
set TwButFg($tmp) "black"
# Just here to keep arrays in sync...
set TwLBg($tmp) "white"
set TwLFg($tmp) "black"
set TrCol($tmp) "UseBg"
set SlidBg($tmp) "UseDefault"
set EntBg($tmp) "bisque"
set EntFg($tmp) "black"
set SelBg($tmp) $TwBg($tmp)
set SelFg($tmp) "white"

#  Scrollbar Appearance
incr tmp
set TwBg($tmp) "IndianRed4"
set TwFg($tmp) "AntiqueWhite"
set TwButBg($tmp) "linen"
set TwButFg($tmp) "black"
# Just here to keep arrays in sync...
set TwLBg($tmp) "white"
set TwLFg($tmp) "black"
set TrCol($tmp) "UseBg"
set SlidBg($tmp) "UseDefault"
set EntBg($tmp) "bisque"
set EntFg($tmp) "black"
set SelBg($tmp) $TwBg($tmp)
set SelFg($tmp) "white"

#  Set Appearance
incr tmp
#set TwBg($tmp) "#10366e"
##set TwFg($tmp) "#feec86"
#set TwFg($tmp) "AntiqueWhite"
set TwBg($tmp)  "#fefee6"
set TwFg($tmp)  "black"
set TwButBg($tmp) "#ae9a66"
set TwButFg($tmp) "black"
# Just here to keep arrays in sync...
set TwLBg($tmp) "white"
set TwLFg($tmp) "black"
set TrCol($tmp) "UseBg"
set SlidBg($tmp) "UseDefault"
set EntBg($tmp) "bisque"
set EntFg($tmp) "black"
set SelBg($tmp) $TwBg($tmp)
set SelFg($tmp) "white"



#  In case rgb.txt is messed up, here are  some of the actual values....
#     Dec                  Std Name              Hex  
#    -----                ----------            ----- 
# 173 216 230		LightBlue              #add8e6
#  70 130 180		SteelBlue              #4682b4
# 250 235 215		AntiqueWhite           #faebd7
# 255 228 196		bisque                 #ffe4c4
# 211 211 211		LightGrey              #d3d3d3
#   0 250 154		MediumSpringGreen      #00fa9a
# 188 143 143		RosyBrown              #bc8f8f
#  47  79  79		DarkSlateGrey          #2f4f4f
# 139 125 123		MistyRose4             #8b7d7b
# e.g., 
# set MainBg     "#add8e6"
# set MainButBg  "#4682b4"
# etc....
#------------------------------------------

return
}





#-------------------------------------------------
#  Build MainFrame  --  Build the main window
#-------------------------------------------------
proc BuildMainFrame {} {
global whohdr timehdr TkVer TkzVer Copy PgmName WhoBg MainButBg MainBg MainFg
global OsName OsVer CurDir Debugon TempDir ErrArgs
global Timehdr ViewButtons FLList
global ForceStat MainSelected
global VDWarn ADWarn MDWarn 
global ExtDirs
global MainWhere2
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global DSlidBg EntBg EntFg
global Button3VD
global IconsOk Installing UpgRel
global TkzG



if {$TkzG(Plugin)}  {
  DieInPlugin
  return -1
  }

set MainBg $TwBg(0)
set MainFg $TwFg(0)
set MainButBg $TwButBg(0)
set MainButFg $TwButFg(0)
set WEntBg $EntBg(0)
set WEntFg $EntFg(0)
set WSelBg $SelBg(0)
set WSelFg $SelFg(0)

set Timehdr ""
UpdTime
set ViewButtons ""
#  The fixed portion
set mainf "main"
frame .main -bg $MainBg
#  Gotta intercept wm killing the window
set cmd "FinalExit"
wm protocol . "WM_DELETE_WINDOW" $cmd
wm protocol . "WM_SAVE_YOURSELF" $cmd

set cdvar "CurDir$mainf"
global $cdvar
set $cdvar $CurDir
set MainWhere2 $CurDir
set readme "$TkzG(TkzDir)/README"
set licinf "$TkzG(TkzDir)/License"
set faqfile "$TkzG(TkzDir)/TkZip-FAQ"

#  Start replacing hard-code with vars - for eventual user customization
set LogoFont "*"
set LogoWgt "bold"
set LogoSl "r"
set LogoPts 300
#  Test values for my system...
#set LogoFont "turkishsansssk"
#set LogoWgt "bold"
#set LogoSl "r"
#set LogoPts 480
set CopyWgt "bold"
set CopySl "r"
set CopyPts "120"
#  Do we use an icon for the logo?
set IconX 56
set IconY 46
if {$IconsOk && $TkzG(UseMainIcon)} {
  set IconOk 1
  }  else  {
  set IconOk 0
  }

#  Identify ourselves
frame .main.f1 -highlightbackground $MainBg -bg $MainBg -bd 8
frame .main.f1a -highlightbackground $MainBg -bg $MainBg -bd 8
set pgmhdr "release $TkzVer    $Copy"
set whohdr "$OsName $OsVer"
#  This gets too long with some verbose OS names/versions.
#set whohdr "$PgmName is running under $whohdr"
set whohdr "$PgmName - $whohdr"
#set timehdr [ exec date ]

if {$IconOk}  {
  label .main.f1.pad1 -relief flat -width 2 -bg $MainBg
  label .main.f1.hdr1 -image TkzLogo -relief flat -bg $MainBg -fg $MainFg 
  }  else  {
  label .main.f1.hdr1 -text $PgmName -relief flat -width 5 -bg $MainBg -fg $MainFg \
        -font "-*-$LogoFont-$LogoWgt-$LogoSl-*-*-*-$LogoPts-*-*-*-*-iso8859-1"
  }

label .main.f1.hdr2 -text $pgmhdr -relief flat -width 62 -bg $MainBg -fg $MainFg 
#      -font "-*-$TkzG(NonameFont)-$CopyWgt-$CopySl*-*-*-*-$CopyPts-*-*-*-*-*-*"
label .main.f1a.hdr3 -text $whohdr -relief sunken -width 36 -bg $WEntBg -fg $WEntFg
label .main.f1a.hdr4 -textvariable Timehdr -relief sunken -width 30 -bg $WEntBg -fg $WEntFg
if {$IconOk}  {
  pack  .main.f1.pad1 .main.f1.hdr1 .main.f1.hdr2 -side left 
  }  else  {
  pack  .main.f1.hdr1 .main.f1.hdr2 -side left 
  }
pack .main.f1a.hdr3 .main.f1a.hdr4 -side left



#  The main ctl buttons
frame .main.f2 -highlightbackground $MainBg -bg $MainBg
menubutton .main.f2.but1 -text "Exit" \
  -bg $MainButBg -fg $MainButFg -highlightbackground $MainBg -relief groove -bd 3 -padx 12
bind .main.f2.but1 <1> {FinalExit}

#button .main.f2.but1 -text "Exit" -bg $MainButBg -highlightbackground $MainBg -fg "$MainButFg" \
#  -relief groove -bd 3 -padx 12 -command {FinalExit} 
label .main.f2.s1 -width 3 \
  -bg $MainBg -fg $MainFg -highlightbackground $MainBg
label .main.f2.s2 -width 1
label .main.f2.s3 -width 8 -relief flat -bd 0 -highlightbackground $MainBg -bg $MainBg -fg $MainFg
label .main.f2.s4 -width 1

menubutton .main.f2.but2 -text "File" \
  -bg $MainButBg -fg $MainButFg -highlightbackground $MainBg -relief groove -bd 3 -padx 12
menu .main.f2.but2.m1 -bg $MainButBg -fg $MainButFg -disabledforeground $MainBg
.main.f2.but2.m1 add command -label "Exit" -command {FinalExit}
#  Fake disabled button
.main.f2.but2.m1 add command -label "New Archive         " -command {CreateArc "main" "dummy" "dummy"} -state normal
.main.f2.but2.m1 add command -label "Open Archive" \
  -command {SetupView "main"}
#  Fake disabled button
.main.f2.but2.m1 add command -label "Delete Archive      " -command {DelArc "main"} -state normal \
  -foreground PowderBlue
.main.f2.but2.m1 add command -label "Show System Info" -command {ShowSysInfo}
.main.f2.but2 configure -menu .main.f2.but2.m1
# Disable the placeholders...
.main.f2.but2.m1 entryconfigure 3 -state normal \
  -foreground PowderBlue

frame .main.f2.mbf1 -highlightbackground $MainBg -bg $MainBg
menubutton .main.f2.mbf1.but4 -text "Options" \
  -bg $MainButBg -fg $MainButFg -highlightbackground $MainBg -relief groove -bd 3 -padx 12
menu .main.f2.mbf1.but4.men1 -bg $MainButBg -disabledforeground $MainBg -fg $MainButFg
.main.f2.mbf1.but4.men1 add checkbutton -label "Show Archives Only" -command {ToggleArcOpt "main"} \
  -variable TkzG(ArcOnly)
.main.f2.mbf1.but4.men1 add checkbutton -label "Warn of Overwrites" -command {KillOvOpt} -variable TkzG(OvWarn) -state normal
.main.f2.mbf1.but4.men1 add checkbutton -label "Never Overwrite Existing Files" -command {KillOvWarn} -variable TkzG(OvOpt) \
  -offvalue 1 -onvalue 0 -state normal
.main.f2.mbf1.but4.men1 add checkbutton -label "Ignore Gnu \"trailing garbage\" Message" -command {CheckHelp 11} \
  -variable TkzG(IgnITG) -state normal
.main.f2.mbf1.but4.men1 add checkbutton -label "Improved Tar Detection" -command {CheckHelp 12} \
  -variable TkzG(Desperation) -state normal
.main.f2.mbf1.but4.men1 add checkbutton -label "Don't Probe Compressed Files" -command {CheckHelp 13} \
  -variable TkzG(NoProbe) -state normal
.main.f2.mbf1.but4.men1 add checkbutton -label "Warn on Viewer Delete" -command {CheckHelp 27} \
  -variable VDWarn -state normal
.main.f2.mbf1.but4.men1 add checkbutton -label "Warn on Archive Delete" -command {CheckHelp 28} \
  -variable ADWarn -state normal
.main.f2.mbf1.but4.men1 add checkbutton -label "Warn on Member Delete" -command {CheckHelp 29} \
  -variable MDWarn -state normal
.main.f2.mbf1.but4.men1 add checkbutton -label "Clean Old Temp Files" -command {CheckHelp 30} \
  -variable TkzG(CldFlag) -state normal
.main.f2.mbf1.but4.men1 add checkbutton -label "Clean Old Error Files" -command {CheckHelp 31} \
  -variable TkzG(CleFlag) -state normal
.main.f2.mbf1.but4.men1 add checkbutton -label "Don't Save Error Files" -command {CheckHelp 32} \
  -variable TkzG(DseFlag) -state normal

.main.f2.mbf1.but4.men1 add checkbutton -label "Save Options on Exit" -command {CheckHelp 33} \
  -variable TkzG(SavOpt) -state normal
.main.f2.mbf1.but4.men1 add checkbutton -label "Use Standard Name Extensions" -command {CheckHelp 34} \
  -variable TkzG(StdNames) -state normal
.main.f2.mbf1.but4.men1 add checkbutton -label "GNU/Linux tgz convention" -command {CheckHelp 35} \
  -variable TkzG(GnuLin) -state normal
.main.f2.mbf1.but4.men1 add checkbutton -label "Shorten Heuristic (experimental)" -command {CheckHelp 36} \
  -variable TkzG(ShnHeur) -state normal

#.main.f2.mbf1.but4.men1 add checkbutton -label "Disable Colormap Hack" -command {CheckHelp 37} \
#  -variable TkzG(ColorHack) -state normal -offvalue 1 -onvalue 0

menu .main.f2.mbf1.but4.men1.mormen -bg $MainButBg -fg $MainButFg -disabledforeground $MainBg
#  Note:  the CheckHelp kluge doesn't work...
.main.f2.mbf1.but4.men1 add cascade -label "(More)" -menu .main.f2.mbf1.but4.men1.mormen -command {CheckHelp 99}
.main.f2.mbf1.but4.men1.mormen add checkbutton -label "Use \$PAGER for Default Viewer" -command {CheckHelp 45} \
  -variable TkzG(UsePager) -state normal
.main.f2.mbf1.but4.men1.mormen add checkbutton -label "Automatic Viewer Selection" -command {CheckHelp 46} \
  -variable TkzG(IntView) -state normal
.main.f2.mbf1.but4.men1.mormen add checkbutton -label "Use MIME for All Files" -command {CheckHelp 48} \
  -variable TkzG(Mime4All) -state normal
.main.f2.mbf1.but4.men1.mormen add checkbutton -label "Use Default Viewer for All Files" -command {CheckHelp 49} \
  -variable TkzG(DV4All) -state normal
.main.f2.mbf1.but4.men1.mormen add checkbutton -label "Fast-Clean Viewer Files" -command {CheckHelp 38} \
  -variable TkzG(FastClean) -state normal
.main.f2.mbf1.but4.men1.mormen add checkbutton -label "View Multiple Files" -command {CheckHelp 39} \
  -variable TkzG(MultView) -state normal
.main.f2.mbf1.but4.men1.mormen add checkbutton -label "Use Pathnames when Viewing" -command {CheckHelp 41} \
  -variable TkzG(Vpn) -state normal
.main.f2.mbf1.but4.men1.mormen add checkbutton -label "Open In Start Directory" -command {CheckHelp 43} \
  -variable TkzG(OpenStartDir) -state normal
.main.f2.mbf1.but4.men1.mormen add checkbutton -label "Button-3 Viewer Delete" -command {CheckHelp 50} \
  -variable Button3VD -state normal
if {! $TkzG(Windows)}  {
.main.f2.mbf1.but4.men1.mormen add checkbutton -label "Remember Symlinks" -command {CheckHelp 52} \
  -variable TkzG(NavLinks) -state normal
  }
.main.f2.mbf1.but4.men1.mormen add checkbutton -label "Use $PgmName Logo" -command {CheckHelp 55} \
  -variable TkzG(UseMainIcon) -state normal
.main.f2.mbf1.but4.men1.mormen add checkbutton -label "Use GNU Tar Features" -command {CheckHelp 60} \
  -variable TkzG(UseGtar) -state normal
.main.f2.mbf1.but4.men1.mormen add checkbutton -label "Prefer GNU Tar" -command {CheckHelp 61} \
  -variable TkzG(PreferGtar) -state normal
# .main.f2.mbf1.but4.men1.mormen add checkbutton -label "Allow Extract of Directories" -command {CheckHelp 43} \
#   -variable ExtDirs -state normal

#  Compression options...
menu .main.f2.mbf1.but4.men1.mormen.cmpomen -bg $MainButBg -fg $MainButFg \
  -disabledforeground $MainBg
.main.f2.mbf1.but4.men1.mormen add cascade -label "Compression Options" \
  -menu .main.f2.mbf1.but4.men1.mormen.cmpomen 
.main.f2.mbf1.but4.men1.mormen.cmpomen add radiobutton -label "Default" -command {CheckHelp 40} \
  -variable TkzG(CompOpt) -value 0 -state normal
.main.f2.mbf1.but4.men1.mormen.cmpomen add radiobutton -label "Max Speed" -command {CheckHelp 40} \
  -variable TkzG(CompOpt) -value 1 -state normal
.main.f2.mbf1.but4.men1.mormen.cmpomen add radiobutton -label "Medium" -command {CheckHelp 40} \
  -variable TkzG(CompOpt) -value 6 -state normal
.main.f2.mbf1.but4.men1.mormen.cmpomen add radiobutton -label "Max Compression" -command {CheckHelp 40} \
  -variable TkzG(CompOpt) -value 9 -state normal
menu .main.f2.mbf1.but4.men1.mormen.instmen -bg $MainButBg -fg $MainButFg \
  -disabledforeground $MainBg
.main.f2.mbf1.but4.men1.mormen add cascade -label "Installation Options" \
  -menu .main.f2.mbf1.but4.men1.mormen.instmen 
.main.f2.mbf1.but4.men1.mormen.instmen add checkbutton -label "Install on Upgrade" -command {CheckHelp 58} \
  -variable TkzG(InstallUpg) -state normal
if {$TkzG(SysAdmp)}  {
.main.f2.mbf1.but4.men1.mormen.instmen add checkbutton -label "Never Install" -command {CheckHelp 56} \
  -variable TkzG(NoInstall) -state normal
.main.f2.mbf1.but4.men1.mormen.instmen add checkbutton -label "Root Install" -command {CheckHelp 57} \
  -variable TkzG(RootInstall) -state normal
.main.f2.mbf1.but4.men1.mormen.instmen add checkbutton -label "Force Install" -command {CheckHelp 59} \
  -variable TkzG(ForceInstall) -state normal
  }
.main.f2.mbf1.but4.men1.mormen add command -label "Change Cache Directory" -command {ChangeCacheDir} \
  -state normal
.main.f2.mbf1.but4.men1.mormen add command -label "Set GNU Tar Name" -command {NameThatTar} \
  -state normal
.main.f2.mbf1.but4.men1.mormen add checkbutton -label "Ignore Drive Errors" -command {CheckHelp 63} \
  -variable TkzG(IgnDrvErr) -state normal



# .main.f2.mbf1.but4.men1 add checkbutton -label "Preserve Absolute Pathnames" -command {} -state disabled
# .main.f2.mbf1.but4.men1 add checkbutton -label "Always Show Extract % Done" -variable ForceStat -state disabled

if {$Debugon}  {
  .main.f2.mbf1.but4.men1 add checkbutton -label "Debug Mode (undocumented)" -variable TkzG(Debug) -state normal
  menu .main.f2.mbf1.but4.men1.dbmen -bg $MainButBg -fg $MainButFg -disabledforeground $MainBg
  .main.f2.mbf1.but4.men1 add cascade -label "Debug Options" -menu .main.f2.mbf1.but4.men1.dbmen
  .main.f2.mbf1.but4.men1.dbmen add checkbutton -label "Interactive" -variable TkzG(Debugi) -state normal
  .main.f2.mbf1.but4.men1.dbmen add checkbutton -label "Logging" -variable TkzG(Debugl) -state normal
  }
.main.f2.mbf1.but4.men1 add command -label "Set Appearance" -command {SetAppearance} -state normal
.main.f2.mbf1.but4.men1 add command -label "Edit MIME Types" -command {EditMimeTypes} -state normal
.main.f2.mbf1.but4.men1 add command -label "Save Options" -command {SaveConfig} -state normal
#
#  Remove "Preserve Pathnames...?" from the general menu...
#  Add sub menu for type-specific options
#
#  On the other hand...just how many of these special options does anyone REALLY
#  need? I certainly don't need them.
#  (Shorten might be a special case, but who's gonna use it?)
#
#  menu .main.f2.mbf1.but4.men1.asopts
#  .main.f2.mbf1.but4.men1 add cascade -label "Archive Type-Specific Options" \
#    -menu .main.f2.mbf1.but4.men1.asopts

#  menu .main.f2.mbf1.but4.men1.asopts.taropts
#  menu .main.f2.mbf1.but4.men1.asopts.zipopts
#  menu .main.f2.mbf1.but4.men1.asopts.gzopts
#  menu .main.f2.mbf1.but4.men1.asopts.shnopts

#  .main.f2.mbf1.but4.men1.asopts add cascade -label "Tar Options" \
#    -menu .main.f2.mbf1.but4.men1.asopts.taropts
#  .main.f2.mbf1.but4.men1.asopts add cascade -label "Zip Options" \
#    -menu .main.f2.mbf1.but4.men1.asopts.Zipopts
#  .main.f2.mbf1.but4.men1.asopts add cascade -label "Gzip Options" \
#    -menu .main.f2.mbf1.but4.men1.asopts.gzopts
#  .main.f2.mbf1.but4.men1.asopts add cascade -label "Shorten Options" \
#    -menu .main.f2.mbf1.but4.men1.asopts.shnopts
#
#
#
#

.main.f2.mbf1.but4 configure -menu .main.f2.mbf1.but4.men1

menubutton .main.f2.but5 -text "Help" \
  -bg $MainButBg -fg $MainButFg -highlightbackground $MainBg -relief groove -bd 3 -padx 12
menu .main.f2.but5.men1 -bg $MainButBg -fg $MainButFg
.main.f2.but5.men1 add command -label "About" -command {About}
.main.f2.but5.men1 add command -label "Help Index" -command {HelpIndex}
.main.f2.but5.men1 add command -label "Help" -command {ShowHelp 1}
.main.f2.but5.men1 add command -label "Register $PgmName" -command {Register 1}
.main.f2.but5.men1 add command -label "Bug Report/Comment" -command {Register 2}
if {[file exists $readme]}  {
  .main.f2.but5.men1 add command -label "View the Current README" -command {HelpReadme}
  }
if {[file exists $faqfile]}  {
  .main.f2.but5.men1 add command -label "View the Current FAQ" -command {HelpFaq}
  }
if {[file exists $licinf]}  {
  .main.f2.but5.men1 add command -label "License Info" -command {HelpLicense}
  }
.main.f2.but5 configure -menu .main.f2.but5.men1


pack .main.f2.mbf1.but4
#pack .main.f2.s1 .main.f2.but1 .main.f2.but2 .main.f2.mbf1 .main.f2.but5 -side left
pack .main.f2.but1 .main.f2.but2 .main.f2.mbf1 .main.f2.but5 -side left

frame .main.f3 -highlightbackground $MainBg -bg $MainBg
label .main.f3.where -text "Current Directory:  " -relief flat -bg $MainBg -fg $MainFg -width 20 
entry .main.f3.s1 -text " " -relief sunken \
  -bg $WEntBg -fg $WEntFg \
  -width 42 -textvariable $cdvar \
  -font "-*-fixed-bold-*-*-*-*-*-*-*-*-*-*-1"

pack .main.f3.where .main.f3.s1 -side left -fill x -anchor center -pady 6
#pack .main.f3.where .main.f3.s1 -side left -fill x -anchor center


pack .main.f1 -fill x -anchor center
pack .main.f1a -anchor center
pack .main.f2  -anchor center
pack .main.f3 -fill x -anchor center


#  Now build a file selection list...

set stuff [BuildDirList "$mainf"]

.main.list1.dirlist configure -selectbackground $WSelBg \
  -selectforeground $WSelFg
.main.list2.arclist configure -selectbackground $WSelBg \
  -selectforeground $WSelFg

bind .main.f3.s1 <Return> {catch {set CurDir [ .main.f3.s1 get ]};  \
    UpdDirList "main" "$CurDir"; 
    }
bind .main.list1.dirlist <Double-1> { UpdMainDir "main" }
bind .main.list2.arclist <Double-1> { SetupView "main" }

bind .main.list1.dirlist <1> {MainSelect1} 
bind .main.list2.arclist <1> {MainSelect} 
bind .main.list2.arclist <3> { WhatsThis "main" }

#  New Help bindings...
#  Hmm...this doesn't work very well with menus...
bind .main.f2.but1 <3> {ShowHelp 01}
bind .main.f2.but2 <3> {ShowHelp 02a}
bind .main.f2.mbf1.but4 <3> {ShowHelp 07}
bind .main.f2.but5 <3> {ShowHelp 15}
bind .main.f2.but2.m1 <1> {UnSetHelp}
bind .main.f2.but2.m1 <3> {SetHelp}
bind .main.f2.mbf1.but4.men1 <1> {UnSetHelp}
bind .main.f2.mbf1.but4.men1 <3> {SetHelp}
bind .main.f2.mbf1.but4.men1.mormen <1> {UnSetHelp}
bind .main.f2.mbf1.but4.men1.mormen <3> {SetHelp}
bind .main.f2.mbf1.but4.men1.mormen.cmpomen <1> {UnSetHelp}
bind .main.f2.mbf1.but4.men1.mormen.cmpomen <3> {SetHelp}
bind .main.f2.mbf1.but4.men1.mormen.instmen <1> {UnSetHelp}
bind .main.f2.mbf1.but4.men1.mormen.instmen <3> {SetHelp}
bind .main.f2.but5.men1 <1> {UnSetHelp}
bind .main.f2.but5.men1 <3> {SetHelp}

UpdDirList "main" "$CurDir" 
# pack .main.list1 .main.list2 -side left -fill both -expand yes

if {$TkzG(NoMainWin)}  {
  #  If --nomain was requested, withdraw the main window before it's
  #  ever realized. (I hate this kind of hack...it tends to drive
  #  window managers bonkers.)
  #  Clean this up someday, and remove the bits of this func that are
  #  always necessary - then just don't do BuildMainFrame for --nomain.
  wm withdraw .
  }  else  {
  pack .main -fill both -expand yes
  if {$TkzG(StartIconic)}  {
    wm iconify .
    }
  }
if {$Installing || $TkzG(StartWarn)}  {
  wm deiconify .
  }
if {$UpgRel}  {
  update idletasks
  set updmsg ".updaterc1"
  catch {raise $updmsg}
  }
if {$Installing}  {
  update idletasks
  set updmsg ".listbox"
  catch {raise $updmsg}
  set updmsg ".instdone1"
  catch {raise $updmsg}
  set updmsg ".instdone2"
  catch {raise $updmsg}
  set updmsg ".instdone3"
  catch {raise $updmsg}
  set Installing 0
  }
if {$TkzG(StartWarn)}  {
  set stwarn ".smalscr1"
  catch {raise $stwarn}
  set stwarn ".smalscr2"
  catch {raise $stwarn}
  set TkzG(StartWarn) 0
  }


return 1
}

#-----------------------------------------------------------------------------
#  ConfigAllWins  -   Refresh all window configurations
#-----------------------------------------------------------------------------
proc ConfigAllWins {}  {
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global DSlidBg EntBg EntFg
global Debugon
global TkzG

set wins [winfo children .]
#puts "\nWindows:  <$wins>"
foreach win $wins  {
#puts "Trying window <$win>"
  if {$win == ".main"}  {
    ConfigMain $win
    continue
    }
  if {[string first ".conts" $win] == 0}  {
    if {[string first "Ext" $win] == -1}  {
      ConfigArcDir $win
      continue
      }  else  {
      ConfigExtWin $win
      continue
      }
    }
  if {[string first ".addmbr" $win] == 0}  {
    ConfigAddWin $win
    continue
    }
  if {[string first ".create" $win] == 0}  {
    ConfigCreateWin $win
    continue
    }
  if {[string first ".chgc000" $win] == 0}  {
    ConfigCacheWin $win
    continue
    }
  if {[string first ".sinfo" $win] == 0}  {
    ConfigSysinfo $win
    continue
    }
  if {[string first ".help" $win] == 0 || [string first ".about" $win] == 0 \
    || [string first ".readme" $win] == 0 || [string first ".license" $win] == 0
    || [string first ".hindex" $win] == 0 || [string first ".relnote" $win] == 0}  {
    ConfigHelpWin $win
    continue
    }
  if {[string first ".mimetype" $win] == 0}  {
    ConfigMimeWin $win
    continue
    }
  }

return
}


#-----------------------------------------------------------------------------
#  ConfigMain  -   Refresh Main window configuration
#-----------------------------------------------------------------------------
proc ConfigMain {win}  {
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global DSlidBg EntBg EntFg
global Debugon
global TkzG


set wno 0
set MainBg $TwBg($wno)
set MainFg $TwFg($wno)
set MainButBg $TwButBg($wno)
set MainButFg $TwButFg($wno)
set LBg $TwLBg($wno)
set LFg $TwLFg($wno)
set WEntBg $EntBg($wno)
set WEntFg $EntFg($wno)
set WSelBg $SelBg($wno)
set WSelFg $SelFg($wno)

$win configure -bg $MainBg
$win.f1 configure -highlightbackground $MainBg -bg $MainBg -bd 8
$win.f1a configure -highlightbackground $MainBg -bg $MainBg -bd 8
catch {unset tmp}
catch { set tmp [$win.f1.pad1 configure] }
if {[info exists tmp]}  {
  $win.f1.pad1 configure -relief flat -width 2 -bg $MainBg
  }
$win.f1.hdr1 configure -bg $MainBg -fg $MainFg
$win.f1.hdr2 configure -bg $MainBg -fg $MainFg
$win.f1a.hdr3 configure -bg $WEntBg -fg $WEntFg
$win.f1a.hdr4 configure -bg $WEntBg -fg $WEntFg
$win.f2 configure -highlightbackground $MainBg -bg $MainBg
$win.f2.but1 configure -bg $MainButBg -highlightbackground $MainBg -fg "$MainButFg"
$win.f2.s3 configure -highlightbackground $MainBg -bg $MainBg -fg $MainFg
$win.f2.but2 configure -bg $MainButBg -fg $MainButFg -highlightbackground $MainBg
$win.f2.but2.m1 configure -bg $MainButBg -fg $MainButFg -disabledforeground $MainBg
$win.f2.mbf1 configure -highlightbackground $MainBg -bg $MainBg
$win.f2.mbf1.but4 configure -bg $MainButBg -fg $MainButFg -highlightbackground $MainBg
$win.f2.mbf1.but4.men1 configure -bg $MainButBg -disabledforeground $MainBg -fg $MainButFg
$win.f2.mbf1.but4.men1.mormen configure -bg $MainButBg -fg $MainButFg -disabledforeground $MainBg
$win.f2.mbf1.but4.men1.mormen.cmpomen configure -bg $MainButBg -fg $MainButFg -disabledforeground $MainBg
if {$Debugon}  {
  $win.f2.mbf1.but4.men1.dbmen configure -bg $MainButBg -fg $MainButFg -disabledforeground $MainBg
  }
$win.f2.but5 configure -bg $MainButBg -fg $MainButFg -highlightbackground $MainBg
$win.f2.but5.men1 configure -bg $MainButBg -disabledforeground $MainBg -fg $MainButFg
$win.f3 configure -highlightbackground $MainBg -bg $MainBg
$win.f3.where configure -bg $MainBg -fg $MainFg
$win.f3.s1 configure -bg $WEntBg -fg $WEntFg

$win.list1 configure  -highlightbackground $MainBg -bg $MainBg
$win.list1.lab1 configure -bg $MainBg -fg $MainFg
$win.list1.dirlist configure -selectbackground $WSelBg \
  -selectforeground $WSelFg -bg $LBg -fg $LFg

$win.list2 configure  -highlightbackground $MainBg -bg $MainBg
$win.list2.lab1 configure -bg $MainBg -fg $MainFg
$win.list2.arclist configure -selectbackground $WSelBg \
  -selectforeground $WSelFg -bg $LBg -fg $LFg

ConfigureScrollbar "$win.list1.diry" 0 0
ConfigureScrollbar "$win.list1.dirx" 0 0
ConfigureScrollbar "$win.list2.diry" 0 0
ConfigureScrollbar "$win.list2.dirx" 0 0

return
}

#-----------------------------------------------------------------------------
#  ConfigArcDir  -   Refresh archive window configuration
#-----------------------------------------------------------------------------
proc ConfigArcDir {win}  {
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global DSlidBg EntBg EntFg
global Debugon
global TkzG

#puts "Refreshing $win"
set owner [string range $win 1 end]
set tmp "ArcFno$owner"
global $tmp
set wno [set $tmp]
set WBg $TwBg($wno)
set WFg $TwFg($wno)
set WButBg $TwButBg($wno)
set WButFg $TwButFg($wno)
set WLBg $TwLBg($wno)
set WLFg $TwLFg($wno)
set WEntBg $EntBg($wno)
set WEntFg $EntFg($wno)
set WSelBg $SelBg($wno)
set WSelFg $SelFg($wno)

set topf "$win.top"
set buttons "$topf.but"
set vopts "$topf.vopt"
set arcbody "$win.body"
set archdr "$win.hdr"

$topf configure  -bg $WBg -highlightbackground $WBg
$buttons configure  -bg $WButBg
$buttons.quit configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.selall configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.view configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.ext configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.add configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.del configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.uninst configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.selv configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.selv.m configure  -bg $WButBg -fg $WButFg
$vopts configure  -bg $WBg -highlightbackground $WBg
$vopts.vndsc configure -bg $WBg -highlightbackground $WBg -fg $WFg
$vopts.vname configure -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg
$vopts.vbdsc configure -bg $WBg -highlightbackground $WBg -fg $WFg
$vopts.vbin configure -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg
$vopts.stat configure -bg $WBg -fg $WFg -highlightbackground $WBg -fg red

$arcbody.alist configure  -bg $WLBg -fg $WLFg \
  -selectbackground $WSelBg -selectforeground $WSelFg
ConfigureScrollbar "$arcbody.scrolly" $wno 0
#  Unfortunately the individual dir rtns decide whether x scroll is needed...
unset tmp
catch { set tmp [$arcbody.scrollx configure] }
if [info exists tmp]  {
  ConfigureScrollbar $arcbody.scrollx $wno 0 
  }



return
}

#-----------------------------------------------------------------------------
#  ConfigExtWin  -   Refresh extract window configuration
#-----------------------------------------------------------------------------
proc ConfigExtWin {win}  {
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global DSlidBg EntBg EntFg
global Debugon
global TkzG

#puts "Refreshing $win"
set wno 0
set WBg $TwBg($wno)
set WFg $TwFg($wno)
set WButBg $TwButBg($wno)
set WButFg $TwButFg($wno)
set WLBg $TwLBg($wno)
set WLFg $TwLFg($wno)
set WEntBg $EntBg($wno)
set WEntFg $EntFg($wno)
set WSelBg $SelBg($wno)
set WSelFg $SelFg($wno)

set topf "$win.top"
set buttons "$topf.but"
set archdr "$topf.hdr"
set arcbody "$win.body"
set body "$win.body"

$topf configure -bg $WBg -highlightbackground $WBg
$buttons configure -bg $WBg
$buttons.quit configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.sel configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg

$archdr configure -bg $WBg
$archdr.l1 configure  -bg $WBg -fg $WFg
$archdr.where configure  -bg $WEntBg -fg $WEntFg

$typef2 configure -bg $WBg -highlightbackground $WBg
$typef2.apn2 configure  -bg $WBg -fg $WFg -highlightbackground $WBg
$typef2.jpn2 configure  -bg $WBg -fg $WFg -highlightbackground $WBg

$arcbody configure -bg $WBg
$arcbody.list1 configure  -highlightbackground $WBg -bg $WBg
$arcbody.list1.lab1 configure -bg $WBg -fg $WFg
$arcbody.list1.dirlist configure -bg $WLBg -fg $WLFg \
  -selectbackground $WSelBg -selectforeground $WSelFg
$arcbody.list2 configure  -highlightbackground $WBg -bg $WBg
$arcbody.list2.lab1 configure -bg $WBg -fg $WFg
$arcbody.list2.arclist configure -bg $WLBg -fg $WLFg \
  -selectbackground $WSelBg -selectforeground $WSelFg

ConfigureScrollbar "$arcbody.list1.diry" 0 0
ConfigureScrollbar "$arcbody.list1.dirx" 0 0
ConfigureScrollbar "$arcbody.list2.diry" 0 0
ConfigureScrollbar "$arcbody.list2.dirx" 0 0

return
}

#-----------------------------------------------------------------------------
#  ConfigAddWin  -   Refresh add window configuration
#-----------------------------------------------------------------------------
proc ConfigAddWin {win}  {
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global DSlidBg EntBg EntFg
global Debugon
global TkzG

#puts "Refreshing $win"
set wno 0
set WBg $TwBg($wno)
set WFg $TwFg($wno)
set WButBg $TwButBg($wno)
set WButFg $TwButFg($wno)
set WLBg $TwLBg($wno)
set WLFg $TwLFg($wno)
set WEntBg $EntBg($wno)
set WEntFg $EntFg($wno)
set WSelBg $SelBg($wno)
set WSelFg $SelFg($wno)

set topf "$win.top"
set buttons "$topf.but"
set namef "$topf.namef"
set typef "$topf.types"
set typef1 "$typef.types1"
set typef2 "$typef.types2"
set flbody "$win.body"

#---------------------
set archdr "$topf.hdr"
set arcbody "$win.body"
set body "$win.body"

$topf configure -bg $WBg -highlightbackground $WBg
$buttons configure -bg $WBg
$buttons.add2arc configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.quit configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg

$namef configure -bg $WBg -highlightbackground $WBg
$namef.where configure -bg $WBg -fg $WFg
$namef.dir configure -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg
$namef.fndsc configure  -bg $WBg -fg $WFg -highlightbackground $WBg
$namef.fname configure  -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg
$namef.pad configure  -bg $WBg -fg $WFg -highlightbackground $WBg

$typef configure -bg $WBg -highlightbackground $WBg
$typef1 configure -bg $WBg -highlightbackground $WBg
$typef1.rec configure  -bg $WBg -fg $WFg -highlightbackground $WBg

$typef2 configure -bg $WBg -highlightbackground $WBg
$typef2.apn configure  -bg $WBg -fg $WFg -highlightbackground $WBg
$typef2.rpn configure  -bg $WBg -fg $WFg -highlightbackground $WBg
$typef2.jpn configure  -bg $WBg -fg $WFg -highlightbackground $WBg
#---------------------

$flbody configure -bg $WBg
$flbody.list1 configure  -highlightbackground $WBg -bg $WBg
$flbody.list1.lab1 configure -bg $WBg -fg $WFg
$flbody.list1.dirlist configure -bg $WLBg -fg $WLFg \
  -selectbackground $WSelBg -selectforeground $WSelFg
$flbody.list2 configure  -highlightbackground $WBg -bg $WBg
$flbody.list2.lab1 configure -bg $WBg -fg $WFg
$flbody.list2.arclist configure -bg $WLBg -fg $WLFg \
  -selectbackground $WSelBg -selectforeground $WSelFg

ConfigureScrollbar "$flbody.list1.diry" 0 0
ConfigureScrollbar "$flbody.list1.dirx" 0 0
ConfigureScrollbar "$flbody.list2.diry" 0 0
ConfigureScrollbar "$flbody.list2.dirx" 0 0

return
}

#-----------------------------------------------------------------------------
#  ConfigCreateWin  -   Refresh create window configuration
#-----------------------------------------------------------------------------
proc ConfigCreateWin {win}  {
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global DSlidBg EntBg EntFg
global Debugon
global TkzG

#puts "Refreshing $win"
set wno 0
set WBg $TwBg($wno)
set WFg $TwFg($wno)
set WButBg $TwButBg($wno)
set WButFg $TwButFg($wno)
set WLBg $TwLBg($wno)
set WLFg $TwLFg($wno)
set WEntBg $EntBg($wno)
set WEntFg $EntFg($wno)
set WSelBg $SelBg($wno)
set WSelFg $SelFg($wno)

set topf "$win.top"
set buttons "$topf.but"
set namef "$topf.namef"
set typef "$topf.types"
set typef1 "$typef.types1"
set typef2 "$typef.types2"
set typef3 "$typef.types3"
set flbody "$win.body"

#---------------------
set archdr "$topf.hdr"
set arcbody "$win.body"
set body "$win.body"

$topf configure -bg $WBg -highlightbackground $WBg
$buttons configure -bg $WBg
$buttons.create configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.quit configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg

$namef configure -bg $WBg -highlightbackground $WBg
$namef.where configure -bg $WBg -fg $WFg
$namef.dir configure -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg
$namef.fndsc configure  -bg $WBg -fg $WFg -highlightbackground $WBg
$namef.fname configure  -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg
$namef.pad configure  -bg $WBg -fg $WFg -highlightbackground $WBg

$typef configure -bg $WBg -highlightbackground $WBg
$typef1 configure -bg $WBg -highlightbackground $WBg
$typef1.tar configure  -bg $WBg -fg $WFg -highlightbackground $WBg
$typef1.zip configure  -bg $WBg -fg $WFg -highlightbackground $WBg
$typef1.tgz configure  -bg $WBg -fg $WFg -highlightbackground $WBg
$typef1.taz configure  -bg $WBg -fg $WFg -highlightbackground $WBg
# $typef1.tbz configure  -bg $WBg -fg $WFg -highlightbackground $WBg
$typef1.tbz2 configure  -bg $WBg -fg $WFg -highlightbackground $WBg

$typef2 configure -bg $WBg -highlightbackground $WBg
$typef2.gzp configure  -bg $WBg -fg $WFg -highlightbackground $WBg
$typef2.cmp configure  -bg $WBg -fg $WFg -highlightbackground $WBg
$typef2.ar configure  -bg $WBg -fg $WFg -highlightbackground $WBg
# $typef2.bzp configure  -bg $WBg -fg $WFg -highlightbackground $WBg
$typef2.bzp2 configure  -bg $WBg -fg $WFg -highlightbackground $WBg
# $typef2.arj configure  -bg $WBg -fg $WFg -highlightbackground $WBg
# $typef2.rar configure  -bg $WBg -fg $WFg -highlightbackground $WBg
$typef2.shn configure  -bg $WBg -fg $WFg -highlightbackground $WBg

$typef3 configure -bg $WBg -highlightbackground $WBg
$typef3.lha configure  -bg $WBg -fg $WFg -highlightbackground $WBg
$typef3.cpio configure  -bg $WBg -fg $WFg -highlightbackground $WBg
#---------------------

$flbody configure -bg $WBg
$flbody.list1 configure  -highlightbackground $WBg -bg $WBg
$flbody.list1.lab1 configure -bg $WBg -fg $WFg
$flbody.list1.dirlist configure -bg $WLBg -fg $WLFg \
  -selectbackground $WSelBg -selectforeground $WSelFg
$flbody.list2 configure  -highlightbackground $WBg -bg $WBg
$flbody.list2.lab1 configure -bg $WBg -fg $WFg
$flbody.list2.arclist configure -bg $WLBg -fg $WLFg \
  -selectbackground $WSelBg -selectforeground $WSelFg

ConfigureScrollbar "$flbody.list1.diry" 0 0
ConfigureScrollbar "$flbody.list1.dirx" 0 0
ConfigureScrollbar "$flbody.list2.diry" 0 0
ConfigureScrollbar "$flbody.list2.dirx" 0 0

return
}

#-----------------------------------------------------------------------------
#  ConfigCacheWin  -   Refresh change cache window configuration
#-----------------------------------------------------------------------------
proc ConfigCacheWin {win}  {
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global DSlidBg EntBg EntFg
global Debugon
global TkzG

puts "Refreshing $win"
set wno 0
set WBg $TwBg($wno)
set WFg $TwFg($wno)
set WButBg $TwButBg($wno)
set WButFg $TwButFg($wno)
set WLBg $TwLBg($wno)
set WLFg $TwLFg($wno)
set WEntBg $EntBg($wno)
set WEntFg $EntFg($wno)
set WSelBg $SelBg($wno)
set WSelFg $SelFg($wno)

set topf "$win.top"
set buttons "$topf.but"
set namef "$topf.namef"
set flbody "$win.body"

#---------------------
set archdr "$topf.hdr"
set arcbody "$win.body"
set body "$win.body"

$topf configure -bg $WBg -highlightbackground $WBg
$buttons configure -bg $WBg
$buttons.add2arc configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.quit configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg

$namef configure -bg $WBg -highlightbackground $WBg
$namef.where configure -bg $WBg -fg $WFg
$namef.dir configure -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg
#---------------------

$flbody configure -bg $WBg
$flbody.list1 configure  -highlightbackground $WBg -bg $WBg
$flbody.list1.lab1 configure -bg $WBg -fg $WFg
$flbody.list1.dirlist configure -bg $WLBg -fg $WLFg \
  -selectbackground $WSelBg -selectforeground $WSelFg
$flbody.list2 configure  -highlightbackground $WBg -bg $WBg
$flbody.list2.lab1 configure -bg $WBg -fg $WFg
$flbody.list2.arclist configure -bg $WLBg -fg $WLFg \
  -selectbackground $WSelBg -selectforeground $WSelFg

ConfigureScrollbar "$flbody.list1.diry" 0 0
ConfigureScrollbar "$flbody.list1.dirx" 0 0
ConfigureScrollbar "$flbody.list2.diry" 0 0
ConfigureScrollbar "$flbody.list2.dirx" 0 0

return
}

#-----------------------------------------------------------------------------
#  ConfigMimeWin  -   Refresh edit MIME types window configuration
#-----------------------------------------------------------------------------
proc ConfigMimeWin {win}  {

global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global DSlidBg EntBg EntFg
global Debugon
global TkzG

#puts "Refreshing $win"
set wno 0
set WBg $TwBg($wno)
set WFg $TwFg($wno)
set WButBg $TwButBg($wno)
set WButFg $TwButFg($wno)
set WLBg $TwLBg($wno)
set WLFg $TwLFg($wno)
set WEntBg $EntBg($wno)
set WEntFg $EntFg($wno)
set WSelBg $SelBg($wno)
set WSelFg $SelFg($wno)
set WDisab "grey"

set topf "$win.topf"
set headf "$topf.headf"
set buttons "$topf.but"
set vbody "$topf.vbody"

$topf configure  -bg $WBg -highlightbackground $WBg

$buttons configure  -bg $WBg -highlightbackground $WBg
$buttons.quit configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.sav configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.edit configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.new configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.act configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.del configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
$buttons.reset configure  -bg $WButBg -fg $WButFg -highlightbackground $WButBg

$headf configure  -bg $WBg -highlightbackground $WBg
$headf.edf1 configure -bg $WBg -highlightbackground $WBg
$headf.edf1.mtypl configure -bg $WBg -fg $WFg
$headf.edf1.mtype configure -bg $WEntBg -highlightbackground $WEntBg -fg $WEntFg
$headf.edf1.mel configure -bg $WBg -fg $WFg
$headf.edf1.mee configure -bg $WEntBg -highlightbackground $WEntBg -fg $WEntFg

$headf.edf2 configure -bg $WBg -highlightbackground $WBg
$headf.edf2.mtagl configure -bg $WBg -fg $WFg
$headf.edf2.mtage configure -bg $WEntBg -highlightbackground $WEntBg -fg $WEntFg

$headf.edf3 configure -bg $WBg -highlightbackground $WBg
$headf.edf3.mvl configure -bg $WBg -fg $WFg
$headf.edf3.mve configure -bg $WEntBg -highlightbackground $WEntBg -fg $WEntFg

$headf.id1 configure -bg $WBg -fg $WFg
$headf.id2 configure -bg $WBg -fg $WFg

$vbody configure  -bg $WBg -highlightbackground $WBg

$vbody.vlist configure \
  -bg $WLBg -fg $WLFg \
  -selectbackground $WSelBg -selectforeground $WSelFg
ConfigureScrollbar $vbody.scrolly 0 0

return
}

#-----------------------------------------------------------------------------
#  ConfigSysinfo  -   Refresh Sysinfo window configuration
#-----------------------------------------------------------------------------
proc ConfigSysinfo {win}  {
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global DSlidBg EntBg EntFg
global Debugon
global TkzG

#puts "Refreshing $win"
set wno 101
set WBg $TwBg($wno)
set WFg $TwFg($wno)
set WButBg $TwButBg($wno)
set WButFg $TwButFg($wno)
set WLBg $TwLBg($wno)
set WLFg $TwLFg($wno)
set WEntBg $EntBg($wno)
set WEntFg $EntFg($wno)
set WSelBg $SelBg($wno)
set WSelFg $SelFg($wno)

set topf $win.topf
set gen "$topf.f2"
set tkz "$topf.f3"
set mailf "$win.f4"

set button $win.b1
set arc $win.f1
set arc2 $win.f2
set arc3 $win.f3

$win configure -bg $WBg
$topf configure -bg $WBg

$button configure -bg $WButBg -fg $WButFg

$gen configure -bg $WBg
$gen.l1 configure -bg $WBg
$gen.f1 configure -bg $WBg
$gen.f1.l2 configure -bg $WBg -fg $WFg
$gen.f1.l3 configure -bg $WBg -fg $WFg
$gen.f2 configure -bg $WBg
$gen.f2.l4 configure -bg $WBg -fg $WFg
$gen.f2.l5 configure -bg $WBg -fg $WFg
$gen.f3 configure -bg $WBg
$gen.f3.l6 configure -bg $WBg -fg $WFg
$gen.f3.l7 configure -bg $WBg -fg $WFg

$tkz configure -bg $WBg
$tkz.l1 configure -bg $WBg
$tkz.f1 configure -bg $WBg
$tkz.f1.l1 configure -bg $WBg -fg $WFg
$tkz.f1.l2 configure -bg $WBg -fg $WFg
$tkz.f2 configure -bg $WBg
$tkz.f2.l1 configure -bg $WBg -fg $WFg
$tkz.f2.l2 configure -bg $WBg -fg $WFg

$mailf configure -bg $WBg
$mailf.l1 configure -bg $WBg -fg $WFg
$mailf.l2 configure -bg $WBg -fg $WFg -highlightbackground $WBg
$mailf.l3 configure -bg $WBg -fg $WFg

$arc configure -bg $WBg
$arc.l1 configure -bg $WBg -fg $WFg
$arc.l2 configure -bg $WBg -fg $WFg -highlightbackground $WBg
set i 0
while {[lindex $TkzG(NeededPgms) $i] != ""}  {
  $arc.$i configure -bg $WBg -fg $WFg -highlightbackground $WBg
  incr i
  }

$arc2 configure -bg $WBg
set i 0
while {[lindex $TkzG(NeededPgms2) $i] != ""}  {
  $arc2.$i configure -bg $WBg -fg $WFg -highlightbackground $WBg
  incr i
  }

$arc3 configure -bg $WBg
set i 0
while {[lindex $TkzG(NeededPgms3) $i] != ""}  {
  $arc3.$i configure -bg $WBg -fg $WFg -highlightbackground $WBg
  incr i
  }




return
}

#-----------------------------------------------------------------------------
#  ConfigHelpWin  -   Refresh Help window configuration
#                     - catches Help, Help Index, and About
#-----------------------------------------------------------------------------
proc ConfigHelpWin {win}  {
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global DSlidBg EntBg EntFg
global Debugon
global TkzG

#puts "Refreshing $win"
set wno 102
set WBg $TwBg($wno)
set WFg $TwFg($wno)
set WButBg $TwButBg($wno)
set WButFg $TwButFg($wno)
set WLBg $TwLBg($wno)
set WLFg $TwLFg($wno)
set WEntBg $EntBg($wno)
set WEntFg $EntFg($wno)
set WSelBg $SelBg($wno)
set WSelFg $SelFg($wno)

if {$win == ".help"}  {
  set buttons "$win.f2.but"
  }
if {$win == ".about" || $win == ".hindex" \
  || $win == ".readme"  || $win == ".license" \
  || $win == ".relnote"}  {
  set buttons "$win.f2"
  }
set bar "$win.sby"

$win configure -bg $WBg
$win.f2 configure -bg $WBg

$buttons.hb1 configure -bg $WButBg -fg $WButFg
if {$win == ".help"}  {
  $buttons.hb2 configure  -bg $WButBg -fg $WButFg
  $buttons.hb3 configure  -bg $WButBg -fg $WButFg
  }
$win.ht1 configure -bg $WLBg -fg $WLFg

ConfigureScrollbar $win.sby $wno 0

return
}




#-----------------------------------------------------------------------------
#  UpdMainDir  -   Update the main directory list - removed from ancient 
#      inline code bound to double click - finally  
#-----------------------------------------------------------------------------
proc UpdMainDir {owner}  {
global MainSelected
global TkzG

set arcbody ".$owner"
set l1 [$arcbody.list1.dirlist curselection]
if {$l1 == ""}  {
  return 1
  }
set dirn [$arcbody.list1.dirlist get $l1]
$arcbody.f2.but2.m1 entryconfigure 3 -foreground PowderBlue
$arcbody.f2.but2.m1 entryconfigure 4 -foreground PowderBlue
set MainSelected 0
UpdDirList "$owner" "$dirn"

return 1
}

#-----------------------------------------------------------------------------
#  UpdTime  -   Update the date/time display occasionally  
#-----------------------------------------------------------------------------
proc UpdTime {}  {
global Timehdr
global TkzG

if {! $TkzG(Crippled)}  {
  if {$TkzG(Portable)}  {
    set Timehdr [clock format [clock seconds] -format "%c %Z"]
    }  else  {
    set Timehdr [exec date]
    }
  after 27000 [list UpdTime ]
  }  else  {
  set Timehdr "Can't read time"
  }

return
}


#-----------------------------------------------------------------------------
#  KillOvOpt  -  if Warn-of-overwrites, turn off Never-overwrite
#    - remember, OvOpt's on-off values are inverted
#-----------------------------------------------------------------------------
proc KillOvOpt {}  {
global MenuHelp
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  set TkzG(OvWarn) [ToggleOpt "$TkzG(OvWarn)"]
  ShowHelp 09
  return 1
  }

if {$TkzG(OvWarn)}  {
  set TkzG(OvOpt) 1
  }

return 1
}

#-----------------------------------------------------------------------------
#  KillOvWarn  -  if Never-overwrite, turn off Warn-of-overwrites
#-----------------------------------------------------------------------------
proc KillOvWarn {}  {
global MenuHelp
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  set TkzG(OvOpt) [ToggleOpt "$TkzG(OvOpt)"]
  ShowHelp 10
  return 1
  }

if {! $TkzG(OvOpt)}  {
  set TkzG(OvWarn) 0
  }

return 1
}


#-----------------------------------------------------------------------------
#  DieInPlugin  --  Can't run in the plugin yet
#-----------------------------------------------------------------------------
proc DieInPlugin {}  {
global TempDir
global PgmName
global TkzG

text .dead -bg AntiqueWhite -fg red -wrap word -width 72 -height 12
pack .dead
.dead tag configure deadfont -font -*-$TkzG(RomanFont)-bold-r-*-*-*-140-*-*-*-*-iso8859-1
.dead tag configure italic -font -*-$TkzG(RomanFont)-*-i-*-*-*-140-*-*-*-*-iso8859-1 -justify center
.dead tag configure deadhead -font -*-$TkzG(RomanFont)-bold-r-*-*-*-180-*-*-*-*-iso8859-1 \
  -justify center
.dead insert end "\n"
.dead insert end "Oops!" deadhead
.dead insert end "\n(Didn't we tell you not to try to run this under the Plugin?)\n" italic
.dead insert end "    $PgmName cannot run under the Plugin at present, because the standard\
  safeTcl security policy doesn't allow for creation of menu widgets (because\
  they're top-level windows). Well,\
  $PgmName is just full of menus. Sorry.\n    We're working on a Plugin-compatible\
  version for online demos, but it's not really a top priority. We trust that\
  most of our potential users would rather see useful function\
  than marketing fluff." deadfont
.dead configure -state disabled

return 1
exit
}


#-----------------------------------------------------------------------------
#  FinalExit  --  Clean up and get out
#-----------------------------------------------------------------------------
proc FinalExit {}  {
global TempDir StartDir
global MenuHelp Home
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 02
  return 1
  }

if {$TkzG(SavOpt)}  {
  SaveAllConfig
  }
catch {cd $StartDir}
if {! $TkzG(Crippled)}  {
  if {$TkzG(Portable)}  {
    catch {file delete -force $TempDir}
    }  else  {
    catch {exec rm -rf $TempDir}
    }
  }

exit
}


#-----------------------------------------------------------------------------
#  DelArc  --  Delete a file
#-----------------------------------------------------------------------------
proc DelArc {owner}  {
global ErrArgs MenuHelp MainSelected ADWarn
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 05
  return 1
  }
#  Fake disabled button
if {! $MainSelected}  {
  return 1
  }

set win ".$owner"
set dirn [ GetCurDir "$owner" ]
if {[$win.list2.arclist curselection] == ""}  {
  GErrMsgBox 14;
  return -1;
  }
set arcn [$win.list2.arclist get [$win.list2.arclist curselection]]; \
if {$dirn == "/dev"}  {
  GErrMsgBox 15;
  return -1;
  }

#  Do the warning thing...
if {$ADWarn}  {
  set ErrArgs [list "$dirn/$arcn"]
  set rc [GModMsgBox $owner 104]
  if {! $rc}  {
    return 1
    }
  }
if {$TkzG(Portable)}  {
  catch {file delete -force $dirn/$arcn}
  }  else  {
  catch {exec rm $dirn/$arcn}
  }
set curdir [ pwd ]
#UpdDirList $owner $curdir
#RefDirs $curdir
RefDirs $dirn

return 1
}



#-----------------------------------------------------------------------------
#  CreateArc  --  Create a new archive file
#-----------------------------------------------------------------------------
proc CreateArc {owner dirname arcname}  {
global PgmName ErrArgs MenuHelp ArcWin MainButBg MainBg MainFg WhoBg
global GotTar GotGtar GotGzip GotZip GotZcat GotCompress 
global GotAr GotArj GotRar GotShn GotBzip GotBzip2 GotLha GotCpio GotRpm 
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg
global EntBg EntFg SelBg SelFg
global TkzG

set WBg $TwBg(0)
set WButBg $TwButBg(0)
set WButFg $TwButFg(0)
set WEntBg $EntBg(0)
set WEntFg $EntFg(0)
set WSelBg $SelBg(0)
set WSelFg $SelFg(0)

set WFg $TwFg(0)
set lbg $TwLFg(0)
set lfg $TwLFg(0)

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 03
  return 1
  }
set win ".$owner"

#  OK, pop up a what'll ya have dialogue...
#-------------------------------------------------------------------
#  Make some unique names for us...
incr ArcWin
set thiswin "create$ArcWin"
set WinName ".$thiswin"
set crfunc "crfunc$thiswin"
global $crfunc
global TkzG
set $crfunc 0

if {$dirname == "dummy" && $arcname == "dummy"}  {
  set arcname ""
  set dirname [ GetCurDir "$owner" ]
  }
set arcn "arcname$thiswin"
global $arcn
set $arcn $arcname
set expn "expname$thiswin"
global $expn
set $expn $arcname

set type 0
set atype "atype$thiswin"
global $atype
set $atype 0

if [catch {toplevel $WinName}] {
  raise $WinName
  } else {
#  Build the window...
  set arctitle "$PgmName: Create Archive"
  wm title $WinName $arctitle
  set topf [frame $WinName.top -bg $WBg -highlightbackground $WBg]
  set buttons [frame $topf.but -bg $WBg -highlightbackground $WBg]
  set namef [frame $WinName.top.namef -bg $WBg -highlightbackground $WBg]
  set typef [frame $WinName.top.types -bg $WBg -highlightbackground $WBg]
  set typef1 [frame $WinName.top.types.types1 -bg $WBg -highlightbackground $WBg]
  set typef2 [frame $WinName.top.types.types2 -bg $WBg -highlightbackground $WBg]
  set typef3 [frame $WinName.top.types.types3 -bg $WBg -highlightbackground $WBg]

  set cmd "CreateArc2 $thiswin"
  button $buttons.create -text "Create" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  set cmd "KillCreate $thiswin"
  button $buttons.quit -text "Cancel" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
#  Gotta intercept wm killing the window with this command too
  wm protocol $WinName "WM_DELETE_WINDOW" $cmd
  wm protocol $WinName "WM_SAVE_YOURSELF" $cmd

  label $namef.where -text "   Directory:  " -relief flat -bg $WBg -fg $WFg
  entry $namef.dir -text " " -relief sunken -bg $WEntBg -fg $WEntFg -width 30 \
  -font "-*-fixed-bold-*-*-*-*-*-*-*-*-*-*-1"
  label $namef.fndsc -text "   Archive Name:  " -bg $WBg -fg $WFg -highlightbackground $WBg
  entry $namef.fname -textvariable $arcn -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg -width 20
  label $namef.pad -text "    " -bg $WBg -fg $WFg -highlightbackground $WBg
  radiobutton $typef1.tar -variable $atype -value 3 -text "tar" -bg $WBg -fg $WFg -highlightbackground $WBg
  radiobutton $typef1.zip -variable $atype -value 2 -text "zip" -bg $WBg -fg $WFg -highlightbackground $WBg
  radiobutton $typef1.tgz -variable $atype -value 1 -text "gzipped tar" -bg $WBg -fg $WFg -highlightbackground $WBg
  radiobutton $typef1.taz -variable $atype -value 5 -text "compressed tar" -bg $WBg -fg $WFg -highlightbackground $WBg
#  radiobutton $typef1.tbz -variable $atype -value 14 -text "bzipped tar" -bg $WBg -fg $WFg -highlightbackground $WBg
  radiobutton $typef1.tbz2 -variable $atype -value 18 -text "bzipped (v.2) tar" -bg $WBg -fg $WFg -highlightbackground $WBg

  radiobutton $typef2.gzp -variable $atype -value 4 -text "gzip" -bg $WBg -fg $WFg -highlightbackground $WBg
  radiobutton $typef2.cmp -variable $atype -value 6 -text "compress" -bg $WBg -fg $WFg -highlightbackground $WBg
  radiobutton $typef2.ar -variable $atype -value 9 -text "ar archive" -bg $WBg -fg $WFg -highlightbackground $WBg
#  radiobutton $typef2.bzp -variable $atype -value 13 -text "bzip" -bg $WBg -fg $WFg -highlightbackground $WBg
  radiobutton $typef2.bzp2 -variable $atype -value 17 -text "bzip2" -bg $WBg -fg $WFg -highlightbackground $WBg
#  radiobutton $typef2.arj -variable $atype -value 10 -text "arj" -bg $WBg -fg $WFg -highlightbackground $WBg -state disabled
#  radiobutton $typef2.rar -variable $atype -value 11 -text "rar" -bg $WBg -fg $WFg -highlightbackground $WBg -state disabled
  radiobutton $typef2.shn -variable $atype -value 12 -text "shorten" -bg $WBg -fg $WFg -highlightbackground $WBg

  radiobutton $typef3.lha -variable $atype -value 15 -text "lharc (lzh)" -bg $WBg -fg $WFg -highlightbackground $WBg
  radiobutton $typef3.cpio -variable $atype -value 16 -text "cpio" -bg $WBg -fg $WFg -highlightbackground $WBg

  if {$TkzG(Windows)}  {
    $typef1.tar configure -selectcolor $WBg
    $typef1.zip configure -selectcolor $WBg
    $typef1.tgz configure -selectcolor $WBg
    $typef1.taz configure -selectcolor $WBg
    $typef1.tbz2 configure -selectcolor $WBg
    $typef2.gzp configure -selectcolor $WBg
    $typef2.cmp configure -selectcolor $WBg
    $typef2.ar configure -selectcolor $WBg
    $typef2.bzp2 configure -selectcolor $WBg
    $typef2.shn configure -selectcolor $WBg
    $typef3.lha configure -selectcolor $WBg
    $typef3.cpio configure -selectcolor $WBg
    }


  if {! $GotTar && ! $GotGtar}  {
    $typef1.tar configure -state disabled
    $typef1.tgz configure -state disabled
    $typef1.taz configure -state disabled
    $typef1.tbz2 configure -state disabled
    }
  if {! $GotZip}  {
    $typef1.zip configure -state disabled
    }
  if {! $GotGzip}  {
    $typef1.tgz configure -state disabled
    $typef2.gzp configure -state disabled
    }
  if {! $GotCompress && ! $GotZcat}  {
    $typef1.taz configure -state disabled
    $typef2.cmp configure -state disabled
    }
  if {! $GotAr}  {
    $typef2.ar configure -state disabled
    }
#  if {! $GotBzip}  {
#    $typef1.tbz configure -state disabled
#    $typef2.bzp configure -state disabled
#    }
  if {! $GotBzip2}  {
    $typef1.tbz2 configure -state disabled
    $typef2.bzp2 configure -state disabled
    }
  if {! $GotShn}  {
    $typef2.shn configure -state disabled
    }
  if {! $GotLha}  {
    $typef3.lha configure -state disabled
    }
  if {! $GotCpio}  {
    $typef3.cpio configure -state disabled
    }

  pack $buttons.create $buttons.quit -side left
  pack $namef.where $namef.dir $namef.fndsc $namef.fname $namef.pad -side left -expand no
  pack $typef1.tar $typef1.zip $typef1.tgz $typef1.taz $typef1.tbz2 -side left 
  pack $typef2.gzp $typef2.cmp $typef2.ar $typef2.bzp2 $typef2.shn -side left
  pack $typef3.lha $typef3.cpio -side left
  pack $typef3 $typef2 $typef1 -side bottom


#  Now build a file selection list for directory to create in & filename...
  set flbody [ frame $WinName.body  -bg $WBg -highlightbackground $WBg]
  set body $thiswin.body

  set stuff [BuildDirList "$body"]

  pack $flbody -anchor w -fill x -side bottom -fill both -expand yes
  
  pack $typef -side bottom -fill both -expand yes
  pack $namef -side bottom -anchor center 
  pack $buttons -side bottom
  
  pack $topf -side bottom -anchor center -expand yes -fill x

  $flbody.list1.dirlist configure -selectbackground $WSelBg \
    -selectforeground $WSelFg
  $flbody.list2.arclist configure -selectbackground $WSelBg \
    -selectforeground $WSelFg
  set cmd "UpdCraDir $body"
  bind $flbody.list1.dirlist <Double-1> $cmd
  set cmd "CreateSel1 $thiswin"
  bind $flbody.list2.arclist <Double-1> $cmd
  $flbody.list2.arclist configure -selectmode single

  set cradir "CraDir$body"
  global $cradir
  set $cradir $dirname

  set cmd "UpdCraDir2 $thiswin"
  bind $namef.dir <Return> $cmd

  $namef.dir configure -textvariable $cradir
  set $cradir [UpdDirList "$body" "$dirname"]

  }

return 1
}

#-----------------------------------------------------------------------------
#  CreateSel1  --  What to do if one file is double-clicked -
#      set the filename, doctored with conventional extensions...?
#-----------------------------------------------------------------------------
proc CreateSel1 {owner}  {
global TkzG

set alist ".$owner.body.list2.arclist"
set fname ".$owner.top.namef.fname"
set tmp  "atype$owner"
global $tmp
set type [set $tmp]
set fname "arcname$owner"
global $fname
set expn "expname$owner"
global $expn


if {! $type}  {
  return 1
  }
set fn [$alist get [$alist curselection]]
set $expn $fn
set fn [StandardName $fn $type]
set $fname $fn

return 1
}

#-----------------------------------------------------------------------------
#  StandardName  --  Make archive name adhere to standard conventions
#-----------------------------------------------------------------------------
proc StandardName {oldname type}  {
global TkzG

switch $type      {
    1          {
        if {! $TkzG(GnuLin)}  {
          set ext ".tar.gz"
          set ext2 ".tgz"
          }  else  {
          set ext ".tgz"
          set ext2 ".tar.gz"
          }

        }
    2          {
        set ext ".zip"
        }
    3          {
        set ext ".tar"
        }
    4          {
        set ext ".gz"
        }
    5          {
        set ext ".tar.Z"
        }
    6          {
        set ext ".Z"
        }
    9          {
        set ext ".a"
        }
    10         {
        set ext ".arj"
        }
    11         {
        set ext ".rar"
        }
    12         {
        set ext ".shn"
        }
    13         {
        set ext ".bz"
        }
    14         {
        set ext ".tar.bz"
        }
    15         {
        set ext ".lzh"
        }
    17         {
        set ext ".bz2"
        }
    18         {
        set ext ".tar.bz2"
        }
    default    {
        return $oldname
        }
    }

set newname $oldname
set l1 [string length $oldname]
set l2 [string length $ext]
set l3 [expr $l1 - $l2]
if {$l3 == -1}  {
  incr l3 -1
  }
set l4 [string last $ext $oldname]
if {$l3 != $l4}  {
  if {$type == 1}  {
    set l2 [string length $ext2]
    set l3 [expr $l1 - $l2]
    set l4 [string last $ext2 $oldname]
    if {$l3 != $l4}  {
      set newname "$oldname$ext"
      }
    }  else  {
    set newname "$oldname$ext"
    }
  }

return $newname
}

#-----------------------------------------------------------------------------
#  KillCreate  --  Kill the CreateArc window
#-----------------------------------------------------------------------------
proc KillCreate {owner}  {
global TkzG

set body "$owner.body"
set tmp "CraDir$body"
global $tmp
set dirname [set $tmp]
set tmp "arcname$owner"
global $tmp
set arcname [set $tmp]

PluckFromList $owner "FLList"
set WinName ".$owner"
destroy $WinName

return 1
}

#-----------------------------------------------------------------------------
#  CreateArc2  --  part 2 - name has been selected
#-----------------------------------------------------------------------------
proc CreateArc2 {owner}  {
global ErrArgs TmpNo TempDir
global TkzG

set body "$owner.body"
set tmp "CraDir$body"
global $tmp
set dirname [set $tmp]
set tmp "arcname$owner"
global $tmp
set arcname [set $tmp]
set tmp "atype$owner"
global $tmp
set type [set $tmp]
set WinName ".$owner"
set expn "expname$owner"
global $expn
set expname [set $expn]
incr TmpNo
set tno $TmpNo
set lstf "$TempDir/TkzLst$tno"
set errf "$TempDir/TkzErr$tno"
set flist "$TempDir/TkzFlst$tno"



if {$arcname == "" || $type == "" || $type == 0}  {
  return -1
  }
if {$dirname == "/dev"}  {
  GErrMsgBox 15;
  return -1;
  }
#  Dammit! -- we have to check filename against programs that will
#  force a DOS-style type "extension" - even if we are not using the
#  standard names option.

if {$TkzG(StdNames)}  {
  set arcname [StandardName $arcname $type]
  }  else  {
  switch  $type  {
      2    {
        set ext [string length $arcname]
        incr ext -4
        if {[string range $arcname $ext end ] != ".zip"}  {
          set arcname "$arcname.zip"
          set tmp "arcname$owner"
          set $tmp $arcname
          }
        }
      10    {
        set ext [string length $arcname]
        incr ext -4
        if {[string range $arcname $ext end ] != ".arj"}  {
          set arcname "$arcname.rar"
          set tmp "arcname$owner"
          set $tmp $arcname
          }
        }
      11    {
        set ext [string length $arcname]
        incr ext -4
        if {[string range $arcname $ext end ] != ".rar"}  {
          set arcname "$arcname.rar"
          set tmp "arcname$owner"
          set $tmp $arcname
          }
        }
      13    {
        set ext [string length $arcname]
        incr ext -3
        if {[string range $arcname $ext end ] != ".bz"}  {
          set arcname "$arcname.bz"
          set tmp "arcname$owner"
          set $tmp $arcname
          }
        }
      15    {
        set ext [string length $arcname]
        incr ext -4
        if {[string range $arcname $ext end ] != ".lzh"}  {
          set arcname "$arcname.bz"
          set tmp "arcname$owner"
          set $tmp $arcname
          }
        }
      17    {
        set ext [string length $arcname]
        incr ext -3
        if {[string range $arcname $ext end ] != ".bz2"}  {
          set arcname "$arcname.bz2"
          set tmp "arcname$owner"
          set $tmp $arcname
          }
        }
      default  {
        }
      }
  }

if { [file exists $dirname/$arcname] }  {
  set ErrArgs [list "$dirname/$arcname"]
  set action [GModMsgBox $owner 105]
  if {! $action}  {
    return -1
    }  else  {
    #  We really need to move this closer to where the action is...
    if {$TkzG(Portable)}  {
      catch { [file delete -force $dirname/$arcname] }
      }  else  {
      catch { [exec rm $dirname/$arcname] }
      }
    RefDirs $dirname
    }
  }

SetArcVars $owner $type

#  Express compress...
switch  $type        {
    4      -
    6      -
    12     -
    13     -
    17     {
      if {$expname != ""}  {
        if {$expname != $arcname}  {
          set ErrArgs [list "$expname" "$arcname"]
          set doit [GModMsgBox $owner 106]
          if {! $doit}  {
            return -1
            }  else  {
            #  Set all the parent & owner vars needed by the compress rtns & fake it...
            set ff [open $flist w]
            puts $ff "$dirname/$expname"
            catch {[close $ff]}
            set tmp "ArcFno$owner"
            global $tmp
            set $tmp $type
            #  Call the appropriate Add routine...
            switch $type        {
                4        {
                    set rc [AddGzp $owner $owner $dirname $arcname $flist $lstf $errf]
                    }
                6        {
                    set rc [AddCmp $owner $owner $dirname $arcname $flist $lstf $errf]
                    }
                12       {
                    set rc [AddShn $owner $owner $dirname $arcname $flist $lstf $errf]
                    }
                13       -
                17       {
                    set rc [AddBzip $owner $owner $dirname $arcname $flist $lstf $errf]
                    }
                }
            KillCreate $owner
            RefDirs $dirname
            DispArc $dirname $arcname 0 0
            return $rc
            }


          }  else  {
          #  No can do...
          set ErrArgs [list $expname]
          GErrMsgBox 83
          return -1
          }
        }

      }

    }


# Now open up a dir window on an empty archive, and let 'em use the add button

KillCreate $owner
DispArc $dirname $arcname 1 $type


return 1
}



#-----------------------------------------------------------------------------
#  MainSelect  --  What to do when main listbox gets an item selected
#-----------------------------------------------------------------------------
proc MainSelect {}  {
global MainSelected
global TkzG

.main.f2.but2.m1 entryconfigure 3 -state normal \
   -foreground black
.main.f2.but2.m1 entryconfigure 4 -state normal \
   -foreground black
set MainSelected 1
KillViewButtons

return 1
}



#-----------------------------------------------------------------------------
#  MainSelect1  --  What to do when main listbox gets an item selected
#-----------------------------------------------------------------------------
proc MainSelect1 {}  {
global TkzG

KillViewButtons

return 1
}



#-----------------------------------------------------------------------------------
#  KillViewButtons  --  obnoxious little hack to account for Tk's indefensible habit
#      of deselecting everything in all the other windows when you select anything. 
#      (In other words, it's just using the current X selection, nuttin' fancy.)
#-----------------------------------------------------------------------------------
proc KillViewButtons {}  {
global ViewButtons
global TkzG
set thisproc "KillViewButtons"

foreach buttons "$ViewButtons"  {
  $buttons.view configure -state disabled
  $buttons.ext configure -state disabled
  $buttons.del configure -state disabled
  $buttons.uninst configure -state disabled
  }

return 1
}




#-----------------------------------------------------------------------------------
#  KillOtherButtons  --  as above, but don't mess with mine. 
#-----------------------------------------------------------------------------------
proc KillOtherButtons {MyButton}  {
global ViewButtons
global TkzG

foreach buttons "$ViewButtons"  {
  if {$buttons != $MyButton}  {
    $buttons.view configure -state disabled
    $buttons.ext configure -state disabled
    $buttons.del configure -state disabled
    $buttons.uninst configure -state disabled
    }
  }

return 1
}


#-----------------------------------------------------------------------------------
#  KillMyButtons  --  Ok, mess with mine, big time. Called before I destroy myself. 
#-----------------------------------------------------------------------------------
proc KillMyButtons {MyButton}  {
global ViewButtons
global TkzG

set tmpbut ""
foreach buttons "$ViewButtons"  {
  if {$buttons != $MyButton}  {
    set tmpbut "$tmpbut $buttons"
    }
set ViewButtons $tmpbut
  }

return 1
}



#-----------------------------------------------------------------------------
#  SetupView  --  Open a selected archive file...
#-----------------------------------------------------------------------------
proc SetupView {owner}  {
global ErrArgs MenuHelp MainSelected ChgCache
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 04
  return 1
  }

if {! $MainSelected}  {
  return 1
  }
if {$ChgCache}  {
  GErrMsgBox 64
  return 1
  }

set win ".$owner"

set dirn [ GetCurDir "$owner" ]
if {[$win.list2.arclist curselection] == ""}  {
  GErrMsgBox 8;
  return -1;
  }
set arcn [$win.list2.arclist get [$win.list2.arclist curselection]]; \
DispArc $dirn $arcn 0 0;

return 1
}



#-----------------------------------------------------------------------------
#  GetCurDir  --  Returns the current directory variable for the owning window
#-----------------------------------------------------------------------------
proc GetCurDir {owner}  {
global TkzG

if {$TkzG(Debug)}  {
#  puts "GetCurDir entered with arg $owner"
  }
set cdvar CurDir$owner
set curdir [ pwd ]
global set $cdvar
if [info exists $cdvar]  {
  if {$TkzG(Debug)}  {
#    puts "cdvar found - $cdvar = [set $cdvar]"
    }
  set curdir [set $cdvar]
  } else  {
  set $cdvar $curdir
  }

return $curdir
}



#---------------------------------------------------------------------- 
#  UpdDirList  --  Display the current directory in a pair of listboxes 
#---------------------------------------------------------------------- 
proc UpdDirList {WinName NewDir} {
global WhoBg MainButBg MainBg MainFg PgmName ErrArgs
global TgzLstFlags CurDir FTypes RTypes RawDev
global MainWhere2 Home
global TkzG

set thisproc "UpdDirList"

set owner ".$WinName"
set cdvar "CurDir$WinName"
global $cdvar
set where [set $cdvar]
set savewhere $where
#if {$TkzG(Debug)}  {
#  puts "$thisproc called from $WinName: change from <$where> to <$NewDir>"
#  }
if {$where == "" && [string first ".." $NewDir] == 0}  {
  set where [pwd]
  }

# Temp for Win testing...
# puts "$thisproc:  Entered from $where looking for $NewDir"
#  If the directory is /proc, don't go there
#  If it's .TkZip..., don't go there either
#  If the dir is /dev, only show selected devices

if {$NewDir == "proc/"} {
  # Tell 'em we don't go there...
  GErrMsgBox 2
  return $where
  }

if {! $TkzG(Windows)}  {
  set Tkzprivate ".$PgmName"
  }  else  {
  set Tkzprivate "$PgmName"
  }
if {[string first "$Tkzprivate" $NewDir] == 0} {
  # Aww, let 'em do  it if in debug mode...
  if {! $TkzG(Debug)}  {
    set ErrArgs [list $NewDir]
    GErrMsgBox 16
    return $where
    }
  }

if {$TkzG(Windows)}  {
  if {[string length $where] == 3 && $NewDir == ".."}  {
#puts "A-ha!  We're at the top of a drive - let's fake a device list."
    set rc [GetDirInfo $owner $NewDir]
    return $where
    }
  }

if {! $TkzG(Windows)}  {
  if {[string first "/" $NewDir] != 0}  {
    if {$where != "/"}  {
      set where2 "$where/"
      }  else  {
      set where2 $where
      }
    }  else  {
    set where2 ""
    }
  }  else  {
  if {[string first "/" $NewDir] == 0 || [string first ":/" $NewDir] == 1}  {
    set where2 ""
    }  else  {
    set i [string length $where]
    incr i -1
    if {[string range $where $i $i] != "/"} {
      set where2 "$where/"
      }  else  {
      set where2 $where
      }
    }
  }

# RBW- bug here...
# Temp for Win testing...
#if {! [file isdirectory $where2$NewDir]} {
#}

set tmp ""
if [file exists $where2$NewDir]  {
  set tmp [file type $where2$NewDir]
  }
if {$tmp != "directory" && $tmp != "link"}  {
  # Tell 'em we don't make directories...
  set ErrArgs [list $NewDir]
  GErrMsgBox 17
  if {$owner == ".main"}  {
    global CurDirmain
    set CurDirmain $MainWhere2
    }
  return $where
  }

#  Parse the dir path in case we're following symlinks.
set tdir $NewDir
set i [string length $tdir]
incr i -1
if {[string range $tdir $i $i] == "/"}  {
  incr i -1
  set tdir [string range $tdir 0 $i]
  }
if {$tdir == ".."}  {
  set tdir $where
  set i [string length $tdir]
  incr i -1
  if {[string range $where $i $i] == "/"}  {
    incr i -1
    set tdir [string range $tdir 0 $i]
    }
  set i [string last "/" $tdir]
  if {$i > 0}  {
    incr i -1
    set tdir [string range $tdir 0 $i]
    }  else  {
    set tdir "/"
    }
  }  else  {
  set tdir $where2$tdir
  }
if {$tdir == ""}  {
  set tdir "/"
  }

set tmp [set $cdvar]
catch {cd [set $cdvar]}
#  To follow symlinks or not...
if {$TkzG(NavLinks)}  {
  if {$tdir == "/proc"}  {
    # Tell 'em we don't go there...
    GErrMsgBox 2
    catch {cd $where}
    set tdir "/"
    }
  if {[string first "$Tkzprivate" $tdir] == 0} {
    # Aww, let 'em do  it if in debug mode...
    if {! $TkzG(Debug)}  {
      set ErrArgs [list $tdir]
      GErrMsgBox 16
      set tdir $Home
      }
    }
  catch {cd $tdir}
  set rc [catch {cd $tdir} tmp]
  if {$rc}  {
    set ErrArgs [list $tdir "enter" $tmp]
    GErrMsgBox 67
    return $savewhere
    }
  set where $tdir
  }  else  {
  catch {cd $NewDir}
  set where [ pwd ]
  }

set $cdvar $where
set CurDir $where
if {$owner == ".main"}  {
  set MainWhere2 $where
  }

set rc [GetDirInfo $owner $where]
#  Need to handle a -1 return here - couldn't read dir...
#  revert to the old dir.
if {$rc == -1}  {
  set where $savewhere
  if {$where == ""}  {
    set where "/"
    }
#  catch [cd $where]
  set rc [catch {cd $where} tmp]
  set $cdvar $where
  set CurDir $where
  if {$owner == ".main"}  {
    set MainWhere2 $where
    }
  set rc [GetDirInfo $owner $where]
  }

return $where
}


#----------------------------------------------------------
#  PluckFromList  --  Remove a window from a global list 
#----------------------------------------------------------
proc PluckFromList {owner listname} {
global TkzG

global $listname

set list [set $listname]

set tlist ""
set i 0
set lnum [llength $list]
while {$i < $lnum}  {
  if {[string first $owner [lindex $list $i]] != 0}  {
    lappend tlist [lindex $list $i]
    }
  incr i
  }


set $listname $tlist
catch {unset list tlist}

}


#----------------------------------------------------------
#  AddToList  --  Add a window to a global list 
#----------------------------------------------------------
proc AddToList {owner listname} {
global TkzG

global $listname
set list [set $listname]
lappend list $owner
set $listname $list
catch {unset list}

return
}


#---------------------------------------------------------
#  RefDirs  --  Refresh all active file lists 
#---------------------------------------------------------
proc RefDirs {rdir} {
global FLList
global TkzG
set thisproc "RefDirs"

#puts "RefDirs:  rdir = $rdir"
#puts "       :  FLList = <$FLList>"

set wins [winfo children .]
set i2 0
set lnum [llength $FLList]
while {$i2 < $lnum}  {
  set owner [lindex $FLList $i2]
  #--------------
  #  Sanity check - insure window exists.
  set i [string first "." $owner]
  if {$i == -1}  {
    set i [string length $owner]
    }
  incr i -1
  set ownbase [string range $owner 0 $i]
  if {[string first $ownbase $wins] == -1}  {
    incr i2
    continue
    }
  set tmp "CurDir$owner"
  global $tmp
  set dir [set $tmp]
  #  If this guy's dir is the one updated, or a descendant...
  if {$rdir != ""}  {
    if {[string first "$rdir" "$dir"] == 0}  {
      UpdDirList "$owner" "$dir"
      }
    }  else  {
      UpdDirList "$owner" "$dir"
    }
  #--------------
  incr i2
  }

}


#---------------------------------------------------------
#  GetDirInfo  --  fill in the directory & file lists 
#---------------------------------------------------------
proc GetDirInfo {owner dir} {
global RTypes FTypes ErrArgs
global TkzG
set thisproc "GetDirInfo"

#puts "$\n$thisproc:  dir = $dir;  in dir [pwd]"
if {$dir == "/dev"} {
  set RawDev 1
  } else {
  set RawDev 0
  }
#  New, better way... 
#  Slowly weeding out all that needless directory changing...
#set flist [glob .* *]
#  RBW -  This is the way we should do it, but it gives us the filenames
#  with the directory prepended...dir has to be stripped from each
#  item in the list. We need to do it this way for proper Windoze support.
if {$TkzG(Windows)}  {
  if {$dir == ".."}  {
    BuildDrvList $owner
    return 1
    }
  }

set endsl 0
set dl [string length $dir]
incr dl -1
if {[string range $dir $dl end] == "/"}  {
  set endsl 1
  set rc [catch {set flist [glob $dir.* $dir*]} tmp ]
  }  else  {
  set rc [catch {set flist [glob $dir/.* $dir/*]} tmp ]
  }
#if {! $TkzG(Windows)}  {
#  if {$dir != "/"}  {
#    set rc [catch {set flist [glob $dir/.* $dir/*]} tmp ]
#    }  else  {
#    set rc [catch {set flist [glob $dir.* $dir*]} tmp ]
#    }
#  }  else  {
#  #  For Windows, we have to account for that stupid drive letter.
#  if {$dir != "/"}  {
#    set rc [catch {set flist [glob $dir.* $dir*]} tmp ]
#    }  else  {
#    set rc [catch {set flist [glob $dir.* $dir*]} tmp ]
#    }
#  }

#set rc [catch {set flist [glob .* *]} tmp]
if {$rc}  {
  set ErrArgs [list $dir "read" $tmp]
  GErrMsgBox 67
  return -1
  }
$owner.list1.dirlist delete 0 end
$owner.list2.arclist delete 0 end
set flist [lsort $flist]
if {$RawDev}  {
  $owner.list1.dirlist insert end "../"
  }
set stripl [string length $dir]

if {! $endsl}  {
  incr stripl
  }

#if {! $TkzG(Windows)}  {
#  if {$dir != "/"}  {
#    incr stripl
#    }
#  }  else  {
#  if {[string first ":/" $dir] == 1}  {
##    incr stripl 3
#    }
#  }

#  Windows reports this as the end of the road...so fake a higher
#  level to force the drive list hack.
if {$TkzG(Windows) && $endsl}  {
  $owner.list1.dirlist insert end ".."
  }

foreach file "$flist"  {
  set file [string range $file $stripl end]
#puts "Looking at file $file"
  set checkdir 1
  if {$file != "."}  {
    # Hack for those damned programs that think "~MyBackupCopyOfYourFile" is
    # a nifty name for a temp file. It is not. Tcl's file query functions
    # certainly don't think so, so don't ask.
    if {[string range $file 0 0] == "~" && [string range $file 1 1] != "/"}  {
      set checkdir 0
      }
    if {$checkdir && [file isdirectory $file] && ! $RawDev}  {
      set file "$file/"
      $owner.list1.dirlist insert end $file
      }  else  {
      if {$RawDev}  {
#--------
        set gotit 0
        foreach f $RTypes {
            if { [string first $f $file] == 0 && ! $gotit } {
	    set gotit 1
            $owner.list2.arclist insert end $file
	    }
	  }
#--------
        }  else  {
	if {$TkzG(ArcOnly)}  {
#--------
          set gotit 0
	  set llen [string length $file]
          foreach f $FTypes {
	    set tlen1 [string length $f]
	    set tloc2 [expr $llen - $tlen1]
	    set typeloc [string last $f $file]
            if { $typeloc > 0 && $typeloc == $tloc2 && ! $gotit } {
	      set gotit 1
              $owner.list2.arclist insert end $file
	      }
	    }
#--------
	  }  else  {
	  $owner.list2.arclist insert end $file
	  }
	}
      }
    }
  }



return 1
}


#--------------------------------------------------------------
#  GetDrvList  --  for MS Windows, get a list of the drive
#    letters. Unfortunately, we need to run through this each
#    time we back up to the top of the hierarchy, because some
#    new removable medium may have been mounted. There's not
#    a clean way to get a static list of devices.
#--------------------------------------------------------------
proc GetDrvList {} {
global TkzG ErrArgs
set thisproc "GetDrvList"

#  NOTE:
#  In some cases we'll get an error like the following (in $tmp) on a
#  network drive with a weird configuration:
#    couldn't read volume information for "P:": permission denied
#  The normal response for a nonexistent drive is
#    no files matched glob patterns "R:.* R:*"
#  In both cases, $rc is set to 1.
#  In the former case, we should pop up a msg box; and there should
#  be an option to suppress the message.
#
#

set drvlst ""
scan "Z" %c lastdrv
scan "A" %c i
while {$i <= $lastdrv}  {
  set drv [format %c $i]
  set rc [catch {set flist [glob $drv:.* $drv:*]} tmp]
  if {! $rc}  {
    lappend drvlst "$drv:/"
#    set drvlst "$drvlst $drv:/"
    }  else  {
    if {! $TkzG(IgnDrvErr)}  {
      if {[string first "no files matched glob" $tmp] == -1}  {
        # Pop up an error message box.
        set ErrArgs [list $drv: "read" $tmp]
        GErrMsgBox 63
        }
      }
    }

  incr i
  }

# puts "Drive list = $drvlst"
set TkzG(DrvLst) $drvlst
return
}


#---------------------------------------------------------
#  BuildDrvList  --  for Windows, build a fake directory
#    list of all the available drives.
#---------------------------------------------------------
proc BuildDrvList {owner}  {
global TkzG

$owner.list1.dirlist delete 0 end
$owner.list2.arclist delete 0 end

GetDrvList
foreach drv $TkzG(DrvLst)  {
  $owner.list1.dirlist insert end "$drv"
  }


return
}


#---------------------------------------------------------
#  BuildDirList  --  build a scrolling directory/file list
#       associated with a specific window frame
#---------------------------------------------------------
proc BuildDirList {wname} {
global WhoBg MainButBg MainBg MainFg PgmName DirWin FLList 
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg DSlidBg
global EntBg EntFg
global TkzG

set owner $wname
set cdvar "CurDir$wname"
global $cdvar
set $cdvar ""
#set FLList [string trim "$FLList $owner"]
AddToList $owner "FLList"
#  Properties from main win...
set wno 0

set WBg $TwBg(0)
set WButBg $TwButBg(0)
set WButFg $TwButFg(0)
set WEntBg $EntBg(0)
set WEntFg $EntFg(0)

set WFg $TwFg(0)
set lbg $TwLBg(0)
set lfg $TwLFg(0)
set sbg $SlidBg($wno)
set tcol $TrCol($wno)

frame .$wname.list1 -highlightbackground $WBg -bg $WBg
label .$wname.list1.lab1 -text "Directories" -relief flat -bg $WBg -fg $WFg -width 20
set cmd ".$wname.list1.dirlist yview"  
scrollbar .$wname.list1.diry -command $cmd 
set cmd ".$wname.list1.dirlist xview"
scrollbar .$wname.list1.dirx -orient horizontal -command $cmd 
set ycmd ".$wname.list1.diry set"
set xcmd ".$wname.list1.dirx set"
listbox .$wname.list1.dirlist -relief sunken -bg $lbg -width 40 \
    -fg $lfg \
    -selectforeground $lbg \
    -selectbackground $WButBg \
    -yscroll $ycmd \
    -xscroll $xcmd \
    -height 15  -font "-*-fixed-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
pack .$wname.list1.lab1
pack .$wname.list1.diry -side right -fill y
pack .$wname.list1.dirx -side bottom -fill x
pack .$wname.list1.dirlist -side left -fill both -expand yes

frame .$wname.list2 -highlightbackground $WBg -bg $WBg
label .$wname.list2.lab1 -text "Files" -relief flat -bg $WBg -fg $WFg -width 20
set cmd ".$wname.list2.arclist yview"  
scrollbar .$wname.list2.diry -command $cmd 
set cmd ".$wname.list2.arclist xview"
scrollbar .$wname.list2.dirx -orient horizontal -command $cmd 
set ycmd ".$wname.list2.diry set"
set xcmd ".$wname.list2.dirx set"
listbox .$wname.list2.arclist -relief sunken -bg $lbg -width 40 \
    -fg $lfg \
    -selectforeground $lbg \
    -selectbackground $WButBg \
    -yscroll $ycmd \
    -xscroll $xcmd \
    -height 15  -font "-*-fixed-bold-*-*-*-*-*-*-*-*-*-iso8859-1"

ConfigureScrollbar ".$wname.list1.diry" 0 0
ConfigureScrollbar ".$wname.list1.dirx" 0 0
ConfigureScrollbar ".$wname.list2.diry" 0 0
ConfigureScrollbar ".$wname.list2.dirx" 0 0

pack .$wname.list2.lab1
pack .$wname.list2.diry -side right -fill y
pack .$wname.list2.dirx -side bottom -fill x
pack .$wname.list2.arclist -side left -fill both -expand yes

pack .$wname.list1 .$wname.list2 -side left -fill both -expand yes


if {$TkzG(Debug)}  {
  #puts "Built .$wname.list1.dirlist"
  }
return 1
}



#--------------------------------------------------------
#  ToggleArcOpt  --  toggle all-files/archive-only option
#--------------------------------------------------------
proc ToggleArcOpt {owner} {
global CurDir MenuHelp
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  set TkzG(ArcOnly) [ToggleOpt "$TkzG(ArcOnly)"]
  ShowHelp 08
  return 1
  }

UpdDirList "$owner" "$CurDir"
}

#--------------------------------
#  ToggleOpt  --  toggle a flag
#--------------------------------
proc ToggleOpt {opt} {

if {$opt == 0} {
  set opt 1
  } else {
  set opt 0
  }
return $opt
}



#--------------------------------------------------------
#  DispArc  --  Display the Archive contents in a listbox
#
#  - To Do:  Everything.
#            Lose the attempt to create one template command line,
#            it's gotten too unwieldy.
#            - Make a separate func for each type
#              - Note that most magic files will likely NOT know about shorten or bzip
#                files, and possibly not rar or arj files (though ours does recognize 
#                the latter two). Then again, the one on my ISP's SunOS system doesn't
#                even recognize a tar. Go figure.
#
#--------------------------------------------------------
proc DispArc {dirname arcname creating crtype} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg
global CurDir ArcWin ErrArgs WinList
global VNames VBins Vnum GotPgm TempDir MimeViewers 
global TkzG
# global ATypes 

set thisproc "DispArc"
if {$TkzG(Debug)}  {
#  puts "$thisproc  entered with args '$dirname' '$arcname' $creating $crtype."
  }

#  First, see whether this file is already open...just raise if so.

set lnum [llength $WinList]
set i 0
while {$i < $lnum}  {
  set wn [lindex $WinList $i]
  set floc [string first "$dirname/$arcname" $wn]
  if {$floc != -1}  {
    set wfn [string range $wn $floc end]
    if {$wfn == "$dirname/$arcname"}  {
      incr floc -2
      set oloc [string wordstart $wn $floc]
      set owner [string range $wn $oloc $floc]
      raise .$owner
      return 1
      }
    }
  incr i
  }

#  Make some unique names for us...
incr ArcWin
set thiswin "conts$ArcWin"
set WinName ".$thiswin"
set viewer "vnam$thiswin"
set viewbin "vbin$thiswin"
set viewnum "vnum$thiswin"
#  We're our own owner...
set owner $thiswin

set tmp "spacey$thiswin"
global $tmp
set $tmp 0
# set tf "tmparc$owner"
# global $tf
# set $tf "$TempDir/TkzTArc"
set tmp "creating$thiswin"
global $tmp
set $tmp $creating
if {! $creating && ! [file exists $dirname/$arcname] }  {
  if [file exists $dirname]  {
    set creating 1
    }  else  {
    return 1
    }
  }

set tmp "creating$owner"
global $tmp
set $tmp $creating
if {$creating && ! $crtype}  {
  CreateArc $owner $dirname $arcname
  return 1
  }


#  OK, now what...? Time for a new func...  It should just set the type,
#  not try to construct a "common" command line. Then we'll do a switch on the
#  type, calling the appropriate directory read routine for each type.
#  Call the new guy...
set arctype [ArcType2 "$thiswin" "$dirname" "$arcname" "$creating" "$crtype"]
  if {$TkzG(Debug)} {
      set dbmsg "             Archive type is set to:  <$arctype>\n"
      DeBug $owner $dbmsg
    }

if {$arctype == " "}  {
  return -1
  }
set spacey 0
if {[string first " " $arcname] != -1}  {
  set spacey 1
  }
#  RBW - 1.0.15 - prevent a double-slash in the root directory.
set tdir $dirname
set lsl [string last "/" $tdir]
set lsl2 [string length $tdir]
incr lsl2 -1
if {$lsl == $lsl2}  {
  incr lsl -1
  set tdir [string range $tdir 0 $lsl]
  }
if {$arctype == "Unknown File Type"}  {
  #  Pop up err msg here...
  #  unless user wants MIME viewing for all files.
  if {$TkzG(Mime4All) || $TkzG(DV4All)}  {
    if {$TkzG(Mime4All)}  {
      set vftype [CheckMime $dirname $arcname]
      }  else  {
      set vftype -1
      }
    if {$vftype != -1}  {
      #  ----------
      set mimev $MimeViewers($vftype)
      set cmd $mimev
#      set tfl [list "$dirname/$arcname"]
      set tfl [list "$tdir/$arcname"]
#      set dummy [SpawnViewer $spacey "$mimev" "$dirname/$arcname"]
      set dummy [SpawnViewer $spacey "$mimev" $tfl]
      return $dummy
      #  ----------
      }  else  {
      if {$TkzG(DV4All)}  {
        #  Do they want to use the default viewer?
        set mimev $VBins(1)
#        set tfl [list "$dirname/$arcname"]
        set tfl [list "$tdir/$arcname"]
#        set dummy [SpawnViewer $spacey "$mimev" "$dirname/$arcname"]
        set dummy [SpawnViewer $spacey "$mimev" $tfl]
        return $dummy
        }  else  {
        set ErrArgs [list $arcname]
        GErrMsgBox 1
        return -1
        }
      }
    }  else  {
    set ErrArgs [list $arcname]
    GErrMsgBox 1
    return -1
    }
  }

    #  Access some globals new guy set...
#-------------------------------------
    set at "ArcType$thiswin"
    global $viewer $viewbin $viewnum $at
    set $viewnum 1
    set $viewer $VNames([set $viewnum])
    set $viewbin $VBins([set $viewnum])
    set $at $arctype
#-------------------------------------


#  OK, build the directory list.

set cc [BuildArcDir2 $thiswin $arcname $dirname $creating]
if {$cc != 1}  {
  if {$cc != -5}  {
    set ErrArgs [list $arcname]
    GErrMsgBox 1
    return -1
    }
  }

#  If we're in our temp dir, this was an internal call & a temp file...
set tname ""
set l1 [string last "/" $dirname]
if {$l1 != -1}  {
  incr l1 -1
  set tname [string range $dirname 0 $l1]
  }
if {$tname == $TempDir}  {
  set killist "Kill$owner"
  global $killist
  set $killist [lappend $killist $dirname/$arcname]
  }

return 1
}



#------------------------------------------------------------
#  ArcType2  --  decide what type of archive we think this is
#    - 03/29/1997 - if file doesn't exist, we came from the
#      create dialogue, use the type set there...
#------------------------------------------------------------
proc ArcType2 { owner dirname arcname creating ArcFno} {
global ArcPgm UnarcPgm ArcFlags ListFlags ExtFlags FTypes RawDev
global CurDir ArcWin ErrArgs TempDir TmpNo MyPid GotTar GotGtar
global TkzG

set thisproc "ArcType2"
set thiswin $owner
set WinName ".$owner"


incr TmpNo
set tno $TmpNo
set tmpdxf "$TempDir/TkzDTmp1$tno"
set errdxf "$TempDir/TkzDErr$tno"

set tmparc "$TempDir/TkzTArc$tno"
set tmp "tmparc$thiswin"
global $tmp
set $tmp $tmparc
set tmp "sdirl$owner"
global $tmp
set $tmp ""

set temptar "TmpTar$owner"
global $temptar
set $temptar ""
set tmp "TmpBz$owner"
global $tmp
set $tmp ""
set tmp "TmpRar$owner"
global $tmp
set $tmp ""
set tmp "TmpArj$owner"
global $tmp
set $tmp ""
set tmp "TmpCpio$owner"
global $tmp
set $tmp ""

set RawDev 0
set cc ""
set rc 0
set fpos 1
#set creating 0
#if { ! [file exists $dirname/$arcname] }  {
#  # Have to get the type here...how?
#  set creating 1
#  }
set simple 0


if {$dirname == "/dev"}  {
  set RawDev 1
  if {$creating} {
    GErrMsgBox 15
    return " "
    }
  }

if { ! $creating }  {
#--------------------------------------------==================================================
if {$RawDev} {
    #    - if it's a device, copy a bit of the file from the the raw dev to a temp file
    if { [string first "n" $arcname] == 0 }  {
      set TheFile $tmparc
      #  If it's a non-rewinding tape, go ahead and copy the whole thing now...
      #  Caveat emptor, it needs major testing and, probably, cleanup.
#  
#  Insert Non-Rewinding tape positioning logic here...
#-----------------------------------------------------------------
      set fpos 0
      set prc [catch { set dummy [exec mt -f $dirname/$arcname status]} cc]
      set fp [string first "ile number =" $cc]
      set fpinc 12
      if {$fp == -1}  {
        set fp [string first "ile number=" $cc]
        set fpinc 11
        }
      #  If there's an mt that speaks our dialect, ask the user which
      #  file, and try to position the tape.
      #  This test will bear some refinement...
      if {$fp != -1}  {
        incr fp $fpinc
        set fpos [lindex [string range $cc $fp end] 0]
        #  Now call new func to set pos...
        set fpos [GetTapePos1 $owner $arcname $dirname]
        }  else  {
        if {$TkzG(Debug)} {
            set dbmsg "Tkz-0002:    mt response for $dirname/$arcname is: \
              \n             <$cc>"
            DeBug $owner $dbmsg
          }
        set ErrArgs [list $dirname/$arcname]
        GErrMsgBox 78
        return " "
        }

#-----------------------------------------------------------------
      if {$fpos}  {
        #  Non-portable...
        catch {exec cat $dirname/$arcname >$tmparc}
        catch { exec mt -f $dirname/$arcname bsf 1}
        }  else  {
        return " "
        }
      }  else  {
      #  OK, floppy or rewinding tape, get a few bytes...
      set TheFile "$dirname/$arcname"
      #  Non-portable...
      catch {exec dd if=$dirname/$arcname of=$tmparc ibs=4096 count=1}
#      catch [exec cat $dirname/$arcname >$tmparc]
      }
    if {$fpos}  {
      set rc [catch {set dummy [exec file $tmparc ]} cc]
      }
  }  else  {
  #  Try to identify the real file...
  set TheFile "$dirname/$arcname"
  set rc [catch {set dummy [exec file $dirname/$arcname ]} cc]
  if {$TkzG(Debug)} {
      set dbmsg "Tkz-0001:    file response for $dirname/$arcname is: \
        \n             <$cc>"
      DeBug $owner $dbmsg
    }
  }

set fno 0

#  catch {puts "\n================\nfile probe response:\n    $cc\n================\n"}
  if { $cc == "$dirname/$arcname: archive" || [string first " ar " $cc] != -1 || [string first " Debian " $cc] != -1 }  {
    set fno 9
    }
  if {$fno == 0}  {
    if { [string first "ARJ" $cc] != -1 }  {
      set fno 10
      }
    }
  if {$fno == 0}  {
    if { [string first "RAR" $cc] != -1 }  {
      set fno 11
      }
    }
  if {$fno == 0}  {
    if { [string first "Zip " $cc] != -1 || [string first "ip archive" $cc] != -1 || [string first "ZIP " $cc] != -1}  {
      set fno 2
      }
    }
  if {$fno == 0}  {
    if { [string first "tar " $cc] != -1 }  {
      set fno 3
      }
    }
  if {$fno == 0}  {
    if { [string first "gzip " $cc] != -1 }  {
      set fno 4
      set simple 1
      }
    }
  if {$fno == 0}  {
    #  Bzips have "BZ" at position 0, version at pos.2...
    #  V1 identifies version as "0", v2 as "h" (For Huffman)
# RBW temp note -- GNU file v. 3.27 is screwed up again. It now says
#  v1 - "bzip compressed  data, version: 0"
#  v2 - "bzip2 compressed data"
#  Why do they keep doing this silly crap...?
#  - also need to add a new type for "Debian Pkg file"...
#
    if { [string first "bzip" $cc] != -1 }  {
      if {[string first "v. h" $cc] != -1 || [string first "bzip2" $cc] != -1}  {
        set fno 17
        set simple 1
        }  else  {
        if {[string first "v. 0" $cc] != -1 || [string first "version: 0" $cc] != -1}  {
          set fno 13
          set simple 1
          }
        }
      }
    }
  if {$fno == 0}  {
    #  Newer versions of GPL'ed file have "bzip2 compressed data" - dumb change!
    if { [string first "bzip2" $cc] != -1 }  {
      set fno 17
      set simple 1
      }
    }
  if {$fno == 0}  {
    #  Shorten magic string is "ajkg" at position 1...
    #  (or sometimes at 0...?)
    if { [string first "shorten " $cc] != -1 }  {
      set fno 12
      set simple 1
      }
    }
  if {$fno == 0}  {
    #  This depends on the fact that we've already screened out gzips and bzips...
    #  Note: GPL'ed file still says "compress'd" - Irix 6.3 is reported to say "compressed"
    #  - old test would trip up on "compressed image file"
    if { [string first "compress'd data" $cc] != -1 || [string first "compressed data" $cc] != -1}  {
      set fno 6
      set simple 1
      }
    }
  if {$fno == 0}  {
    if { [string first "executable " $cc] != -1 }  {
      set fno 7
      }
    }
  if {$fno == 0}  {
    if { [string first "LHa" $cc] != -1 }  {
      set fno 15
      }
    }
  if {$fno == 0}  {
    if { [string first "cpio " $cc] != -1 }  {
      set fno 16
      }
    }
  if {$fno == 0}  {
    if { [string first "RPM " $cc] != -1 }  {
      set fno 19
      }
    }


#  Special hack for those pgms that don't like to read devices...
#  copy the damned thing to a temp disk file if it's not tar, gzip, or compress.
if {$RawDev && $fno != 0}  {
  if { [string first "n" $arcname] != 0 }  {
    if {$fno != 3 && $fno != 4 && $fno != 6}  {
      #  Non-portable...
      catch {exec cat $dirname/$arcname >$tmparc}
      }
    }
  }


#  The problem here is that it's not all that uncommon to find a "portably challenged" system
#  on which the file command doesn't recognize a plain tar - so, if Desperation mode is set,
#  we will have to do the brute force thing if we haven't identified the file yet...
#
#  Note - on my system, a multipart zip that has been artificially "sewn back together"
#  by concatenating the parts wasn't recognized by file, even though unzip would handle it.
#  Had to tweak magic - the files start with a string of PK\007\010PK - rather than make 
#  another "Desperation" hack...
#  Had to add another spacey file hack here...
#  Fix this when we get the info on Solaris tar...
#
## old...
## if $fpos && $fno == 0 
## && $TkzG(Desperation) 
## && [string first " " $TheFile] == -1
if {$fpos && $fno == 0 && $TkzG(Desperation)}  {
  #  Kluge time...
  if {$TkzG(GotGtar2) && $TkzG(PreferGtar)}  {
    set tarpgm $TkzG(GtarName)
    }  else  {
    if {! $GotTar && $TkzG(GotGtar2)}  {
      set tarpgm $TkzG(GtarName)
      }  else  {
      set tarpgm "tar"
      }
    }
  if {$GotGtar}  {
    set theflags "-tvf"
    }  else  {
    set theflags "tvf"
    }
  set cmd [list "exec" "$tarpgm" $theflags $TheFile]
  set rc [catch {set trc [eval $cmd]} cc]
#  set trc [catch {set dummy [exec tar -tvf $TheFile ]} cc]
  if {$rc == 0 && $cc != "" && [string first "oesn't" $cc] < 0 \
    && [string first "kipping to" $cc] < 0 && [string first "nly read" $cc] < 0 \
    && [string first "unknown file" $cc] < 0 && [string first "error" $cc] < 0}  {
    set fno 3
    }
  }

set ArcFno $fno
#--------------------------------------------==================================================
  }



set arctype [SetArcVars $owner $ArcFno]

set fv "ArcFno$owner"
global $fv
set $fv $ArcFno
#  Gotta rmember to change this if we find a complex arc...
set tmp "SimpleCmp$owner"
global $tmp
set $tmp $simple

#  Gotta add logic to set this...
set rdv "RawDev$owner"
global $rdv
set $rdv $RawDev


return $arctype
}


#------------------------------------------------------------
#  GetTapePos1  --  Find out what file the user wants from
#                   a non-rewinding tape...
#                   -----------------------------------------
#                   Gotta work up some nicer looking widgets,
#                   but the code works.
#------------------------------------------------------------
proc GetTapePos1 {owner arcname dirname}  {
global PgmName whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg
global TargFile MaxTapeFiles TapeSelected
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg DSlidBg
global EntBg EntFg
global TkzG

set thiswin ".tapeno$owner"
set WBg $TwBg(0)
set WButBg $TwButBg(0)
set WButFg $TwButFg(0)
set WFg $TwFg(0)
set TargFile 1
set MaxTapeFiles 99
set TapeSelected 0

#----------------------------------------
if [catch {toplevel $thiswin}] {
  raise $thiswin
  } else {
  set arctitle "$PgmName: Select File No. for:  $dirname/$arcname"
  wm title $thiswin $arctitle
  set topf [frame $thiswin.top -bg $WBg -highlightbackground $WBg]
  set buttons [frame $topf.but -bg $WBg]

  set cmd "destroy $thiswin"
  button $buttons.quit -text "Cancel" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  set cmd "SelectTape $thiswin"
  button $buttons.ok -text "OK" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  set tapef [frame $topf.tf -bg $WBg]
  label $tapef.fnotag -bg $WBg -fg $WFg -text "    Select file number to extract from $dirname/$arcname:      "
  label $tapef.fno -bg bisque -fg $WFg -relief sunken -width 3 -height 1 -textvariable TargFile \
    -font "-*-$TkzG(NonameFont)-bold-r-*-*-*-160-*-*-*-*-iso8859-1"  
  label $tapef.pad1 -width 2 -bg $WBg -fg $WFg
  set tfbuttons [frame $tapef.ud -bg $WBg]

  set cmd "IncrTapePos"
  button $tfbuttons.up -text "+" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WBg \
    -relief groove -bd 3
  set cmd "DecrTapePos"
  button $tfbuttons.down -text "-" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WBg \
    -relief groove -bd 3

  label $tapef.pad2 -width 2 -bg $WBg -fg $WFg
  set tfbpad [frame $topf.padb]
  label $tfbpad.pad1 -height 1 -bg $WBg -fg $WFg

  pack $buttons.quit $buttons.ok -side left -anchor w -expand no 
  pack $buttons -side top -anchor n
  pack $tfbpad.pad1 -fill x -expand yes
  pack $tfbpad -side bottom -anchor w -fill x

  pack $tfbuttons.up -side top
  pack $tfbuttons.down -side bottom
  pack $tapef.fnotag $tapef.fno $tapef.pad1 $tfbuttons $tapef.pad2 -side left -anchor w -expand no
#  pack $tapef.pad2 -side left -anchor w -expand no
  pack $tapef -side bottom
  pack $topf -anchor w -fill x

  tkwait window $thiswin
  }
#----------------------------------------

if {! $TapeSelected}  {
  return 0
  }

set curfile 1
set count [expr $TargFile - $curfile]
catch { exec mt -f $dirname/$arcname rewind}

if {$count > 0}  {
  #  Linux mt has no problem with fsf 0 - can't say for some others...
  catch { exec mt -f $dirname/$arcname fsf $count}
  }

return $TargFile
}


#-----------------------------------------------------------
#  IncrTapePos  --  Increment the tape file position
#
#-----------------------------------------------------------
proc IncrTapePos {}  {
global TargFile MaxTapeFiles
global TkzG

if {$TargFile < $MaxTapeFiles}  {
  incr TargFile
  }
return 1
}


#-----------------------------------------------------------
#  DecrTapePos  --  Decrement the tape file position
#
#-----------------------------------------------------------
proc DecrTapePos {}  {
global TargFile MaxTapeFiles
global TkzG

if {$TargFile > 1}  {
  incr TargFile -1
  }
return 1
}


#-----------------------------------------------------------
#  SelectTape  --  Indicate tape file position is selected
#
#-----------------------------------------------------------
proc SelectTape {owner}  {
global TapeSelected
global TkzG

set TapeSelected 1
destroy $owner
return 1
}






#-----------------------------------------------------------
#  BuildArcDir2  --  Read the archive directory list into a
#                  listbox
#-----------------------------------------------------------
proc BuildArcDir2 {owner arcname dirname creating}  {
global PgmName whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg
global CurDir ArcWin ErrArgs TempDir TmpNo MyPid Home
global VNames VBins VNum GotPgm
global ViewButtons WinList 
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg DSlidBg
global EntBg EntFg SelBg SelFg Button3VD
global TkzG

set thisproc "BuildArcDir2"

set thiswin $owner
set WinName ".$owner"

set killist "Kill$owner"
global $killist
set $killist ""
incr TmpNo
set tno $TmpNo
set tmpf "$TempDir/TkzTmp$tno"
set errf "$TempDir/TkzErr$tno"
set $killist [lappend $killist $tmpf $errf]
set at "ArcType$owner"
set fv "ArcFno$owner"
set ap "ArcPgm$thiswin"
set lf "ListFlags$thiswin"
set gp "GotPgm$thiswin"
set rdv "RawDev$owner"
global $at $fv $ap $lf $gp $rdv
set arctype [set $at]
set ArcFno [set $fv]
set arcpgm [set $ap]
set listflags [set $lf]
set gotpgm [set $gp]
set RawDev [set $rdv]
set an "ArcName$owner"
set dn "DirName$owner"
global $an $dn
set $an $arcname
set $dn $dirname
##  RBW - 08/31/1999 - Insure this is never undefined.
#set tmp "CurDir$owner"
#global $tmp
#set $tmp $dirname

set tmp "TmpTar$owner"
global $tmp
set $tmp ""
set addwin ""
set tmp "Addwin$owner"
global $tmp
set $tmp $addwin

set vdp "VDPending$owner"
global $vdp
set $vdp 0
set tmp "creating$owner"
global $tmp
set creating [set $tmp]

if {! $gotpgm}  {
# Don't just say oops, tell 'em what pgm is missing...
  # "zcat" really means we couldn't find either...
  if {$arcpgm == "zcat"}  {
    set ErrArgs [list "zcat/uncompress"]
    }  else  {
    set ErrArgs [list $arcpgm]
    }
  GErrMsgBox 3
  return 1
  }


#    set WBg [lindex $TBg $ArcFno]
#    set WButBg [lindex $TButBg $ArcFno]
#    set WFg [lindex $TFg $ArcFno]
    set wno $ArcFno
    set WBg $TwBg($ArcFno)
    set WButBg $TwButBg($ArcFno)
    set WButFg $TwButFg($ArcFno)
    set WFg $TwFg($ArcFno)
    set lbg $TwLBg($ArcFno)
    set lfg $TwLFg($ArcFno)
    set WEntBg $EntBg($ArcFno)
    set WEntFg $EntFg($ArcFno)
    set WSelBg $SelBg($ArcFno)
    set WSelFg $SelFg($ArcFno)
    set sbg $SlidBg($ArcFno)
    set tcol $TrCol($ArcFno)
    set viewer "vnam$thiswin"
    set viewbin "vbin$thiswin"
    set viewnum "vnum$thiswin"
    global $viewer $viewbin $viewnum
    set $viewnum 1
    set $viewer $VNames([set $viewnum])
    set $viewbin $VBins([set $viewnum])

set partial 0


#  Check whether all those old vars are needed...
#  Now get down to doing it the new way...
#    so do it right this time.

    if [catch {toplevel $WinName}] {
	raise $WinName
        } else {
#  Common part, just like the old stuff...
#
        set arctitle "$arctype:  $arcname"
        if {$creating}  {
          set arctitle "* New File *  $arctitle"
          }
        set arctitle "$PgmName:  $arctitle"
	wm title $WinName $arctitle
	set topf [frame $WinName.top -bg $WBg -highlightbackground $WBg]
	set buttons [frame $topf.but]
	$buttons configure -bg $WButBg
#--------
#        set buttons2 [frame $topf.but2]
#	$buttons2 configure -bg $WButBg
#	set cmd "FindFunc $thiswin"
#	button $buttons2.find -text "Find" -command $cmd \
#	  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
#--------
	set ViewButtons "$ViewButtons $buttons"
#	set WinList [string trim "$WinList $owner-$dirname/$arcname"]
        AddToList [string trim "$owner-$dirname/$arcname"] "WinList"
	set vopts [frame $topf.vopt]
	set arcbody [frame $WinName.body]
#	set archdr [frame $topf.hdr]
        set archdr [frame $WinName.hdr] 
	set cmd "KillArc $thiswin 1"
	button $buttons.quit -text "Close" -command $cmd \
	  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
      #  Gotta intercept wm killing the window with this command too
        wm protocol $WinName "WM_DELETE_WINDOW" $cmd
        wm protocol $WinName "WM_SAVE_YOURSELF" $cmd

	#
        set cmd [list "SelectAll" $thiswin $arcname $dirname]
	button $buttons.selall -text "Select All  " -width 12 -command $cmd \
	  -bg $WButBg -fg $WButFg -highlightbackground $WButBg
        set cmd [list "ViewItem" $thiswin $arcname $dirname]
	button $buttons.view -text "View" -command $cmd \
	  -bg $WButBg -fg $WButFg -highlightbackground $WButBg -state disabled
        set cmd [list "ExtractItems" $thiswin $arcname $dirname]
	button $buttons.ext -text "Extract" -command $cmd \
	  -bg $WButBg -fg $WButFg -highlightbackground $WButBg -state disabled
	#  Placeholders...
	set cmd [list "AddItem" $thiswin $arcname $dirname]
	button $buttons.add -text "Add" -bg $WButBg -fg $WButFg -highlightbackground $WButBg -command $cmd -state normal
	set cmd [list "DelItem" $thiswin $arcname $dirname]
	button $buttons.del -text "Delete" -bg $WButBg -fg $WButFg -highlightbackground $WButBg -command $cmd -state disabled
	set cmd [list "Uninstall" $thiswin $arcname $dirname]
	button $buttons.uninst -text "Uninstall" -bg $WButBg -fg $WButFg -highlightbackground $WButBg -command $cmd -state disabled
	set cmd [list "SetViewer" $thiswin $arcname $dirname]
        menubutton $buttons.selv -text "Select Viewer" -bg $WButBg -fg $WButFg -highlightbackground $WButBg \
	  -menu $buttons.selv.m -relief groove -bd 3 -pady 6
	menu $buttons.selv.m -bg $WButBg -fg $WButFg -tearoff yes

	set cmd [list "SetViewer" $thiswin $arcname $dirname]
	set vi 1
        while {$vi <= $VNum}  {
	  set vn $VNames($vi)
	  $buttons.selv.m add radiobutton -label "$vn" -command "$cmd $vi" -indicatoron 0
	  incr vi
          }

#	pack $buttons.quit $buttons.selall $buttons.view $buttons.ext $buttons.add $buttons.del 
	pack $buttons.quit $buttons.selall $buttons.view $buttons.ext $buttons.add $buttons.del $buttons.uninst \
	  -side left -anchor center -fill both -expand yes
	pack $buttons.selv -anchor center -fill both -expand no 
	pack $buttons -side top -anchor n -fill both -expand yes -pady 20
#--------
#        pack $buttons2.find -side top -fill none -anchor center -expand no
#	pack $buttons2 -side top -anchor n -fill none -expand yes -pady 0
#--------

        $buttons.view configure -state disabled

        bind $buttons.quit <3> {ShowHelp 20}
        bind $buttons.selall <3> {ShowHelp 21}
        bind $buttons.view <3> {ShowHelp 22}
        bind $buttons.ext <3> {ShowHelp 23}
        bind $buttons.add <3> {ShowHelp 24}
        bind $buttons.del <3> {ShowHelp 25}
        bind $buttons.uninst <3> {ShowHelp 53}
        bind $buttons.selv <3> {ShowHelp 26}
        set cmd "SetViewerDelete $thiswin"
        bind $buttons.selv.m <2> $cmd
        if {$Button3VD}  {
          bind $buttons.selv.m <3> $cmd
          }
	label $vopts.vndsc -text "   Viewer:  " -bg $WBg -highlightbackground $WBg -fg $WFg 
	entry $vopts.vname -textvariable $viewer -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg -width 20
	label $vopts.vbdsc -text "   Executable:  " -bg $WBg -highlightbackground $WBg -fg $WFg
	entry $vopts.vbin -textvar $viewbin -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg -width 20 -relief sunken
        set cmd "AddViewer $thiswin $arcname $dirname"
	bind $vopts.vbin <Key-Return> $cmd
	label $vopts.stat -text "          " -bg $WBg -fg $WFg -highlightbackground $WBg -fg red

	pack $vopts.vndsc $vopts.vname $vopts.vbdsc $vopts.vbin $vopts.stat -side left -anchor center -fill both -expand no
	$vopts configure -bg $WBg -highlightbackground $WBg
	$vopts.vname configure -state disabled
	$vopts.vbin configure -state disabled 
	pack $vopts -anchor center -fill both -expand no -pady 8

#  Now display the archive contents in a listbox
        scrollbar $arcbody.scrolly -command "$arcbody.alist yview"
        pack $arcbody.scrolly -side right -fill y
        listbox $arcbody.alist -relief sunken -bg $lbg -width 80 \
           -fg $lfg \
           -selectbackground $WSelBg \
           -selectforeground $WSelFg \
	   -yscroll "$arcbody.scrolly set" \
	   -selectmode extended \
	   -height 15  -font "-*-$TkzG(FixFont)-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
	set cmd "$buttons.view configure -state normal"
	set cmd "SelectOne $thiswin"
	bind $arcbody.alist <1> $cmd


        if {$creating}  {
          $buttons.selall configure -state disabled
          $buttons.view configure -state disabled
          $buttons.ext configure -state disabled
          $buttons.add configure -state normal
          $buttons.selv configure -state disabled
          }  else  {
          set tmp "SimpleCmp$owner"
          global $tmp
          set simple [set $tmp]
          if {$simple || $ArcFno == 10 || $ArcFno == 11 || $ArcFno == 19}  {
            $buttons.add configure -state disabled
            }
          }

	# Set up headings and data lines...this is where we depart from the old logic.
        set rc  [GetArcDir $owner $dirname $arcname $errf]
        if {$rc < 0}  {
          #  'cause switch syntax gets its knickers in a twist if you have a
          #  negative number. Grrr...
          set fakerc $rc
          set fakerc [expr 0 - $rc]
          #  Say something...
          #  puts "$thisproc:  Ah...merde! GetArcDir failed with rc = $rc    fakerc = $fakerc."

          switch  $fakerc      {
            1      -
            3      {
                #  Open error (-1) ...?
                #  Bad data (-3) ...?  (Zip does this.)
	        KillArc $thiswin 1
	        return -1
                }
            2      -
            4      {
                #  No data (-2) ...?  (Zip does this.)
                #  Premature eof (-4) ...?  Tell 'em and display what we've got.
                set partial 1
                }
            5      {
	        KillArc $thiswin 0
	        return -5
                }
            default    {
                #  Just say we don't recognize it.
                return -1
                }
            }
          }
#  Does directory have any filenames with imbedded spaces?
#  If so, insure only one thing can ever be selected at a time. It's the
#  only way, without a total rewrite of all the old list/string parsing.
#  Oops, no can do, that'll effectively cripple extract, which works.
#set tmp "spacey$thiswin"
#global $tmp
#set spacey [set $tmp]
#if {$spacey}  {
#  $arcbody.alist configure -selectmode single
#  $buttons.selall configure -state disabled
#  }
#  Now configure the scrollbars
set ArcFno [set $fv]
set wno $ArcFno

ConfigureScrollbar $arcbody.scrolly $wno 0 

##  Unfortunately the individual dir rtns decide whether x scroll is needed...
#unset tmp
#catch { set tmp [$arcbody.scrollx configure] }
#if [info exists tmp]  {
#  ConfigureScrollbar $arcbody.scrollx $wno 0 
#  }

	pack $topf -anchor w -fill x
	pack $archdr -anchor w -fill x
	pack $arcbody -anchor w -side bottom -fill both -expand yes
        set cmd [list "ViewItem" $thiswin $arcname $dirname]
	bind $arcbody.alist <Double-1> $cmd

#  End of common part

        }

if {$partial}  {
#  Premature eof, but we may have some data. The user may be able to extract something 
#  useful, even though the file is corrupted.
#  Wait for the dir window to appear, then pop up error message on top of it.
  update idletasks
  set ErrArgs [list $arcname $errf]
  incr TmpNo
  set tno $TmpNo
  if {!$TkzG(DseFlag)}  {
    if {$TkzG(Portable)}  {
      catch {file copy -force $errf $Home/TkzErr$MyPid-$tno}
      }  else  {
      catch {exec cp $errf $Home/TkzErr$MyPid-$tno}
      }
    }
  if {$TkzG(IgnITG)}  {
    #  Non-portable...
    set dummy ""
    if {$TkzG(Portable)}  {
      if {[file size $errf] > 0}  {
        set ef ""
        catch {set ef [open $errf r]}     
        if {$ef != ""}  {
          while {[ gets $ef efline ] > -1}  {
            set dummy "$dummy$efline"
            }
          }
        catch {close $ef}
        }
      }  else  {
      set dummy [exec cat $errf]
      }
    if {[string first "trailing garbage" $dummy] != -1}  {
      return 1
      }
    }
  GErrMsgBox 12
  }

#  End of the new arc dir builder
#--------
set cmd "FindFunc $thiswin"
bind $topf <2> $cmd
#bind $buttons <2> $cmd
#bind $archdr <2> $cmd
#bind $vopts <2> $cmd
bind $arcbody.alist <2> $cmd
#  Since most Windows users never even heard of a 3-button mouse...
if {$TkzG(Windows)}  {
  bind $topf <3> $cmd
  bind $buttons <3> $cmd
  bind $archdr <3> $cmd
  bind $vopts <3> $cmd
  }
set cmd [list "WhatsThis2" $thiswin $dirname $arcname]
bind $arcbody.alist <3> $cmd
#--------

return 1
}




#--------------------------------------------------------
#  GetArcDir  --  Get the Archive Directory list data
#
#--------------------------------------------------------
proc GetArcDir {owner dirname arcname errf} {

set thisproc "GetArcDir"
set thiswin $owner
set WinName ".$owner"
set fv "ArcFno$thiswin"
global $fv
set ArcFno [set $fv]
set wno [set $fv]

set rc 1

set tmp "creating$owner"
global $tmp
set creating [set $tmp]
#  If it's brand new, fake an empty directory...
if {$creating}  {
  return 1
  }
#  Experimental...
set thelist ".$owner.body.alist"
$thelist delete 0 end
if {$ArcFno == 1}  {
  set ArcFno 4
  set $fv $ArcFno
  set arctype [SetArcVars $owner $ArcFno]
  }
if {$ArcFno == 5}  {
  set ArcFno 6
  set $fv $ArcFno
  set arctype [SetArcVars $owner $ArcFno]
  }
if {$ArcFno == 18}  {
  set ArcFno 17
  set $fv $ArcFno
  set arctype [SetArcVars $owner $ArcFno]
  }
if {$ArcFno == 14}  {
  set ArcFno 13
  set $fv $ArcFno
  set arctype [SetArcVars $owner $ArcFno]
  }


switch  $ArcFno  {
  2         -
  7         {
    set rc [GetDirZip $owner $dirname $arcname "dummy" $errf]
    }
  3         {
    set rc [GetDirTar $owner $dirname $arcname "dummy" $errf]
    }
  4         {
    set rc [GetDirGzp $owner $dirname $arcname "dummy" $errf]
    }
  6         {
    set rc [GetDirCmp $owner $dirname $arcname "dummy" $errf]
    }
  9         {
    set rc [GetDirAr $owner $dirname $arcname "dummy" $errf]
    }
  10         {
    set rc [GetDirArj $owner $dirname $arcname "dummy" $errf]
    }
  11         {
    set rc [GetDirRar $owner $dirname $arcname "dummy" $errf]
    }
  12         {
    set rc [GetDirShn $owner $dirname $arcname "dummy" $errf]
    }
  13         -
  17         {
    set rc [GetDirBzip $owner $dirname $arcname "dummy" $errf]
    }
  15         {
    set rc [GetDirLha $owner $dirname $arcname "dummy" $errf]
    }
  16         -
  19         {
    set rc [GetDirCpio $owner $dirname $arcname "dummy" $errf]
    }
  default         {
    set rc 0
    }

  }

# 1.0.3 - moved this here, scrollbar was no longer configured on create.
#  Unfortunately the individual dir rtns decide whether x scroll is needed...
set wno [set $fv]
set arcbody ".$owner.body"
unset tmp
catch { set tmp [$arcbody.scrollx configure] }
if [info exists tmp]  {
  ConfigureScrollbar $arcbody.scrollx $wno 0 
  }


return $rc
}



#--------------------------------------------------------------
#  The Ar Handling Routines --  Handle AR archive/library files
#
#--------------------------------------------------------------

#--------------------------------------------------------------
#  GetDirAr  --  Get the Archive Directory list data for an AR
#
#--------------------------------------------------------------
proc GetDirAr {owner dirname arcname dummyname errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TwButBg TwButFg
global TkzG

set thisproc "GetDirAr"
set thiswin $owner
set WinName ".$owner"
set topf "$WinName.top"
set archdr "$WinName.hdr"
set arcbody "$WinName.body"
set fv "ArcFno$thiswin"
global $fv
set ArcFno [set $fv]
set WButBg $TwButBg($ArcFno)
set WButFg $TwButFg($ArcFno)
# incr TmpNo
set tno $TmpNo
set tmpf "$TempDir/TkzTmp$tno"
# set errf "$TempDir/TkzErr$tno"
set dirfile "$TempDir/TkzDir$tno"
set killist "Kill$owner"
global $killist
set $killist [lappend $killist $dirfile $tmpf]

set ap "ArcPgm$thiswin"
set lf "ListFlags$thiswin"
global $ap $lf
set arcpgm [set $ap]
set listflags [set $lf]

set tmp "spacey$thiswin"
global $tmp
set spacey [set $tmp]
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }


# set arcpgm "ar"
# set listflags "-t"

#  AR listing is a no-brainer...no heading, no info but member names
#  set hdrflds 1
if {[info commands $archdr.h1] == ""}  {
  label $archdr.h1 -relief groove
  }

pack $archdr.h1 -anchor w -side left -fill x -expand yes
$archdr.h1 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "           Name        "
# Now read the list...
        set rc [catch {exec $arcpgm $listflags $TheArcFile >$dirfile 2>$errf} tmp]
        if [ catch {set in [open $dirfile r]} ]  {
          #  The caller needs to take the appropriate action here...
          #  just tell him nfg...
	  return -1
	  }

	set lineno 0
        while  { [ gets $in line ] > -1 } {
	  incr lineno
          $arcbody.alist insert end $line
          #  Hack to deal with spacey Win95 style filenames...
          #  If one is found in the archive, force selectmode single.
          set tmpfn [string trim [lrange $line 0 end]]  
          if {[string first " " $tmpfn] != -1}  {
            set spacey 1
            set tmp "spacey$thiswin"
            global $tmp
            set $tmp $spacey
            }
          }
        catch { close $in }
#  I think this should be about it for the data....
#  Now, what about error checking and window size configure...?
#  Well, only Zip needs some special checking at this point.

#  Window size - don't need xscrollbar...
        $arcbody.alist configure -width 80
#  Do we want to do this here...?
        pack $arcbody.alist  -side left -fill both -expand yes



return 1
}

#--------------------------------------------------------------
#  GetVAr  --  Get a member to view from an AR
#
#--------------------------------------------------------------
proc GetVAr {owner dirname arcname flist tmpd errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "GetVAr"

set tmp "spacey$owner"
global $tmp
set spacey [set $tmp]
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }

#  Can't extract to stdout or to a specific name - put in tmp dir & copy...
#set where [pwd]
#cd $TempDir
#set rc [catch {exec ar -x $TheArcFile $fname >$errf 2>$errf} cc]
#cd $where
#catch [exec cp $TempDir/$fname $tmpf]
#catch [exec rm $TempDir/$fname]
set rc 0
set errc 0
set where [pwd]
catch {unset xlist}
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

cd $tmpd
cd $tmpd
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
    set tmpf "$tmpd/$fn"
    set rc [catch {exec ar -x $TheArcFile $fn >$errf 2>>$errf} cc]
#    catch [exec cp $fn $tmpf]
#    set l1 [string first "/" $fn]
#    if {$l1 != -1}  {
#      incr l1 -1
#      set fdir [string range $fn 0 $l1]
#      catch [exec rm -rf $fdir]
#      }  else  {
#      catch [exec rm -f $fn]
#      }
  if {$rc != 0}  {
    cd $where
    return $rc
    }
  incr ll2
  }
  cd $where



return $rc
}


#--------------------------------------------------------------
#  ExtAr  --  Extract member(s) from an AR
#
#--------------------------------------------------------------
proc ExtAr {owner dirname arcname whereto fname flist lstf errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "ExtAr"

set statw ".$owner.top.vopt.stat"
set stat "Stat$owner"
global $stat
set $stat "          "
$statw configure -textvariable $stat -fg red

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }


#  Pay no attention to fname, we may have a lotta files to extract...
#  gotta access the list of member names to extract.
#  Build list to pass on command line, and do that,,,

set $stat "Extracting"
$statw configure -fg red
update idletasks
catch {unset xlist}
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}
set rc 0


set where [pwd]
cd $whereto

set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1 && $rc == 0}  {
  set fn [lindex $xlist $ll2]
  set rc [catch {exec ar -x $TheArcFile $fn >$lstf 2>$errf} cc]
  incr ll2
  }

$statw configure -fg black
set $stat "   Done   "
#  Now done in common error check func
#if {$TkzG(Portable)}  {
#  catch { [file delete -force $lstf $errf $flist] }
#  }  else  {
#  catch { [exec rm $lstf $errf $flist] }
#  }

cd $where
return $rc
}

#--------------------------------------------------------------
#  AddAr  --  "Add" member(s) to an ar archive
#
#    Options supported:
#        None at present...  
#--------------------------------------------------------------
proc AddAr {parent owner dirname arcname flist lstf errf} {
set thisproc "AddAr"
global ErrArgs
global TkzG


set tmp "creating$parent"
global $tmp
set creating [set $tmp]
set tmp "apn$owner"
global $tmp
set apn [set $tmp]
#set tmp "recurs$owner"
#global $tmp
#set recurs [set $tmp]
set tmp "ArcFno$parent"
global $tmp
set type [set $tmp]
set rc 0
set TheArcFile $dirname/$arcname
catch {unset xlist}

if [ catch {set fl [open $flist r]} ]  {
#  puts "$thisproc:    open failure"
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

set flags ""
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
#    ****  gotta check what the options are...
    set rc [catch {exec ar -r $TheArcFile $fn >$lstf 2>$errf} cc]
#  puts "$thisproc:  got rc = $rc compressing $fn as $TheArcFile"
#  puts "$thisproc:      cc = $cc\n"
  if {$rc != 0}  {
    break
    }
  incr ll2
  }
#  Temp...put up a message box here...
if {$rc != 0}  {
#  puts "Error adding $fn  $TheArcFile!"
  set ErrArgs [list $lstf $errf $TheArcFile]
  GErrMsgBox 88
  return $rc
  }

return $rc
}

#--------------------------------------------------------------
#  DelAr  --  Delete member(s) from an AR Archive
#
#--------------------------------------------------------------
proc DelAr {owner dirname arcname flist lstf errf} {
set thisproc "DelAr"
global ErrArgs
global TkzG

set rc 0
set TheArcFile $dirname/$arcname
catch {unset xlist}
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  set rc [catch {exec ar -d $TheArcFile $fn >$lstf 2>$errf} cc]
#  puts "$thisproc:  got rc = $rc deleting $fn"
  if {$rc != 0}  {
    break
    }
  incr ll2
  }

if {$rc != 0}  {
  set ErrArgs [list $lstf $errf $TheArcFile]
  GErrMsgBox 87
  return $rc
  }

return $rc
}



#--------------------------------------------------------------
#  The Arj Handling Routines --  Handle ARJ archive files
#
#--------------------------------------------------------------

#---------------------------------------------------------------
#  GetDirArj  --  Get the Archive Directory list data for an ARJ
#
#---------------------------------------------------------------
proc GetDirArj {owner dirname arcname dummyname errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TwButBg TwButFg
global TkzG

set thisproc "GetDirArj"
set thiswin $owner
set WinName ".$owner"
set topf "$WinName.top"
set archdr "$WinName.hdr"
set arcbody "$WinName.body"
set fv "ArcFno$thiswin"
global $fv
set ArcFno [set $fv]
set WButBg $TwButBg($ArcFno)
set WButFg $TwButFg($ArcFno)
# incr TmpNo
set tno $TmpNo
set tmpf "$TempDir/TkzTmp$tno"
# set errf "$TempDir/TkzErr$tno"
set dirfile "$TempDir/TkzDir$tno"
set killist "Kill$owner"
global $killist
set $killist [lappend $killist $dirfile $tmpf]

#  Grumble! unarj insists on a ".arj" extension...the DOS legacy lives on...and on...
set temparj "TmpArj$owner"
global $temparj
set temparjfile "$TempDir/Tarj$tno.arj"
set $temparj $temparjfile
set tmp "spacey$thiswin"
global $tmp
set spacey [set $tmp]

set ap "ArcPgm$thiswin"
set lf "ListFlags$thiswin"
global $ap $lf
set arcpgm [set $ap]
set listflags [set $lf]

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }


# set arcpgm "unarj"
# set listflags "-l"

# Now read the list...
#	set rc [ catch { set in [ open [ concat "|$arcpgm $listflags $dirname/$arcname 2>$errf" ] r ] } cc]
        #  So if it doesn't end in .arj, make it so, or unarj will bitch.
        set tmp [string length $arcname]
        incr tmp -4
        set tmp2 [string last ".arj" $arcname]
        if {$tmp != $tmp2}  {
          if {$TkzG(Portable)}  {
            set rc [ catch { file copy -force $TheArcFile $temparjfile } cc ]
            }  else  {
            set rc [ catch { exec cp $TheArcFile $temparjfile } cc ]
            }
        set rc [catch {exec unarj l $temparjfile >$dirfile 2>$errf} tmp]
          }  else  {
        set rc [catch {exec unarj l $TheArcFile >$dirfile 2>$errf} tmp]
          }
        if [ catch {set in [open $dirfile r]} ]  {
          #  The caller needs to take the appropriate action here...
          #  just tell him nfg...
	  return -1
	  }

        set dfltwidth 80
        set hdrwidth 0
        set hdrflds 7
        set llen 0
        set ll1 0
	set lineno 0
	set ignline 1
	set startdata 0

        while  { [ gets $in line ] > -1 } {
          set ll1 [expr [string length $line] ]
	  #  Customize the column headings for the archive type from listing data in this loop...
	  incr lineno
	  if { [string first "Filename" $line] == 0 }  {
	    #  Dammit, we have to doctor one of the column headings...
	    set bldash [expr [string first "modified" $line] ]
	    incr bldash -2
	    set templ1 [string range $line 0 $bldash]
	    incr bldash 2
	    set templ1 "$templ1-[string range $line $bldash end]"
	    set line $templ1
	    set hf1 1
	    set hf1a 0
	    while {$hf1a < $hdrflds}  {
	      set fname "$archdr.h$hf1"
	      if {[info commands $fname] == ""}  {
	        label $fname -relief groove
	        }
	      $fname configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text [ lindex $line $hf1a ]
              incr hf1
              incr hf1a
	      }
	    pack $archdr.h1 $archdr.h2 $archdr.h3 $archdr.h4 $archdr.h5 $archdr.h6 -side left  
	    pack $archdr.h7 -anchor w -side left -fill x -expand yes

            }
          if { [string first "--------" $line] == 0 }  {
            #  Adjust the column heading widths, and stop or resume ignoring data...
            if {$ignline}  {
              set startdata 1
              set hf1 1
              set hf1a 0
              while {$hf1a < $hdrflds}  {
                set fname "$archdr.h$hf1"
                set flen [expr [string length [lindex $line $hf1a] ] ]
                #  Heavy-handed kluge - oughta go to fixed font, but they're so dammned ugly!
                if {$hf1 == 1 || $hf1 == 4 || $hf1 == 6}  {
                  incr flen
                  }
                if {$hf1 == $hdrflds}  {
                  incr flen 4
                  }
	        $fname configure -width $flen
                incr hf1
                incr hf1a
                incr hdrwidth $flen
                }
              }  else  {
              set ignline 1
              set startdata 0
              }
            }
          if {! $ignline}  {
            $arcbody.alist insert end $line
            #  Hack to deal with spacey Win95 style filenames...
            #  If one is found in the archive, force selectmode single, so we
            #  might have a chance of getting viewing to work.
            set tmpfn [string trim [lrange $line 0 0]]  
            if {[string first " " $tmpfn] != -1}  {
              set spacey 1
              set tmp "spacey$thiswin"
              global $tmp
              set $tmp $spacey
              }
            #  Keep track of widest line...
            if { $ll1 > $llen } {
              set llen $ll1
              }
            }
           if { $startdata }  {
             set ignline 0
             }
          }
        catch { close $in }
#  I think this should be about it for the data....
#  Now, what about error checking and window size configure...?
#  Well, only Zip needs some special checking at this point.

#  Window size - may need xscrollbar...
        if {$hdrwidth > $dfltwidth}  {
          set dfltwidth $hdrwidth
          }
	if { $llen > $dfltwidth } {
	  set ll1 $llen
	  set llen $dfltwidth
	  if {[info commands $arcbody.scrollx] == ""}  {
            scrollbar $arcbody.scrollx -orient horizontal -command "$arcbody.alist xview"
            }
          $arcbody.alist configure -xscroll "$arcbody.scrollx set"
	  }

        $arcbody.alist configure -width $llen
        if { $ll1 > $llen } {
          if {[info commands $arcbody.scrollx] != ""}  {
	    pack $arcbody.scrollx -fill x -side bottom
	    }
	  } 
#  Do we want to do this here...?
        pack $arcbody.alist  -side left -fill both -expand yes



return 1
}

#--------------------------------------------------------------
#  GetVArj  --  Get a member to view from an ARJ
#
#--------------------------------------------------------------
proc GetVArj {owner dirname arcname flist tmpd errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "GetVArj"

set temparj "TmpArj$owner"
global $temparj
set temparjfile [set $temparj]

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }

#  Make sure unarj will like the filename...
set tmp [string length $arcname]
incr tmp -4
set tmp2 [string last ".arj" $arcname]
if {$tmp != $tmp2}  {
  set TheFile $temparjfile
  }  else  {
  set TheFile $TheArcFile
  }

set errc 0
set rc 0
set where [pwd]
set xlist ""
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

# unarj extracts all, no selective extract or redirect - gotta extract all to
# a new temp dir, copy selected file, and delete all the junk. Ug-lee!
set where [pwd]
incr TmpNo
set tmpno $TmpNo
set VTempDir "$tmpd/VArj$tmpno"
cd $tmpd
if {$TkzG(Portable)}  {
  catch {file mkdir $VTempDir}
  }  else  {
  catch {exec mkdir $VTempDir}
  }

cd $VTempDir
set rc [catch {exec unarj x $TheFile >$errf 2>$errf} cc]

cd $tmpd
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  if { ! [file exists $VTempDir/$fn] }  {
    set nfname [string tolower $fn]
    if {$TkzG(Portable)}  {
      catch {file copy -force $VTempDir/$nfname $VTempDir/$fn}
      }  else  {
      catch {exec cp $VTempDir/$nfname $VTempDir/$fn}
      }
    }
  if {$TkzG(Portable)}  {
    catch {file copy -force $VTempDir/$fn $fn}
    }  else  {
    catch {exec cp $VTempDir/$fn $fn}
    }
  incr ll2
  }

if {$TkzG(Portable)}  {
  catch {file delete -force $VTempDir}
  }  else  {
  catch {exec rm -rf $VTempDir}
  }

return $rc
}

#-----------------------------------------------------------------
#  ExtArj  --  Extract member(s) from an ARJ
#     -- I don't know whether arj will store directory entries --
#        for now, we don't support extracting such entries if they
#        do exist.
#-----------------------------------------------------------------
proc ExtArj {owner dirname arcname whereto fname flist lstf errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "ExtArj"

set statw ".$owner.top.vopt.stat"
set stat "Stat$owner"
global $stat
set $stat "          "
$statw configure -textvariable $stat -fg red

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }

set temparj "TmpArj$owner"
global $temparj
set temparjfile [set $temparj]
set rc 0

#  Make sure unarj will like the filename...
set tmp [string length $arcname]
incr tmp -4
set tmp2 [string last ".arj" $arcname]
if {$tmp != $tmp2}  {
  set TheFile $temparjfile
  }  else  {
  set TheFile $TheArcFile
  }


#  Pay no attention to fname, we may have a lotta files to extract...
#  gotta access the list of member names to extract.
#  Extract to temp dir, then for each item in list file, copy to target,,,

set $stat "Extracting"
$statw configure -fg red
update idletasks
set xlist ""
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

#
set where [pwd]
set XTempDir "$TempDir/VArj"
  if {$TkzG(Portable)}  {
  catch {file mkdir $XTempDir}
  }  else  {
  catch {exec mkdir $XTempDir}
  }
cd $XTempDir
set rc [catch {exec unarj x $TheFile >$lstf 2>$errf} cc]
#puts "ExtArj:  rc = $rc  cc = $cc"
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
if { ! [file exists $fn] }  {
  set fn [string tolower $fn]
  }
  if {$TkzG(Portable)}  {
    catch {file copy -force $XTempDir/$fn $whereto}
    catch {file delete -force $XTempDir/$fn}
    }  else  {
    catch {exec cp $XTempDir/$fn $whereto}
    catch {exec rm $XTempDir/$fn}
    }
  incr ll2
  }
$statw configure -fg black
set $stat "   Done   "
#  Now done in common error check func
#if {$TkzG(Portable)}  {
#  catch { [file delete -force $lstf $errf $flist] }
#  }  else  {
#  catch { [exec rm $lstf $errf $flist] }
#  }

cd $where
return $rc
}




#--------------------------------------------------------------
#  The Rar Handling Routines --  Handle RAR archive files
#
#--------------------------------------------------------------

#--------------------------------------------------------------
#  GetDirRar  --  Get the Archive Directory list data for a RAR
#
#--------------------------------------------------------------
proc GetDirRar {owner dirname arcname dummyname errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global RarVer
global TwButBg TwButFg
global TkzG

set thisproc "GetDirRar"
set thiswin $owner
set WinName ".$owner"
set topf "$WinName.top"
set archdr "$WinName.hdr"
set arcbody "$WinName.body"
set fv "ArcFno$thiswin"
global $fv
set ArcFno [set $fv]
set WButBg $TwButBg($ArcFno)
set WButFg $TwButFg($ArcFno)
# incr TmpNo
set tno $TmpNo
set tmpf "$TempDir/TkzTmp$tno"
# set errf "$TempDir/TkzErr$tno"

#  Oh, bother! unrar is another dumb old DOS-style pgm that insists on a ".rar" extension...
set temprar "TmpRar$owner"
global $temprar
set temprarfile "$TempDir/Trar$tno.rar"
set $temprar $temprarfile
set dirfile "$TempDir/TkzDir$tno"
set killist "Kill$owner"
global $killist
set $killist [lappend $killist $dirfile $temprarfile]


set tmp "spacey$thiswin"
global $tmp
set spacey [set $tmp]
set ap "ArcPgm$thiswin"
set lf "ListFlags$thiswin"
global $ap $lf
set arcpgm [set $ap]
set listflags [set $lf]

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev"}  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }


# set arcpgm "unrar"
# set listflags "l"

#--------------------
# Now read the list...
##	set rc [ catch { set in [ open [ concat "|$arcpgm $listflags $dirname/$arcname 2>$errf" ] r ] } cc]
#	set rc [ catch { set in [ open [ concat "|unrar l $dirname/$arcfile 2>$errf" ] r ] } cc]
        #  So if it doesn't end in .rar, make it so, or unrar will whine.
        set tmp [string length $arcname]
        incr tmp -4
        set tmp2 [string last ".rar" $arcname]
        if {$tmp != $tmp2}  {
          if {$TkzG(Portable)}  {
            set rc [ catch { file copy -force $TheArcFile $temprarfile } cc ]
            }  else  {
            set rc [ catch { exec cp $TheArcFile $temprarfile } cc ]
            }
          set rc [catch {exec unrar l $temptarfile >$dirfile 2>$errf} tmp]
          }  else  {
          set rc [catch {exec unrar l $TheArcFile >$dirfile 2>$errf} tmp]
          }
        if [ catch {set in [open $dirfile r]} ]  {
          #  The caller needs to take the appropriate action here...
          #  just tell him nfg...
	  return -1
	  }

        set dfltwidth 80
        set hdrwidth 0
        set hdrflds 10
        set llen 0
        set ll1 0
        set fl1 0
	set lineno 0
	set ignline 1
	set startdata 0
        while  { [ gets $in line ] > -1 } {
          set ll1 [expr [string length $line] ]
	  #  Customize the column headings for the archive type from listing data in this loop...
	  incr lineno
          set tempfl1 [ string length [lindex $line 1] ]
          if {$tempfl1 > $fl1 && ! $ignline}  {
            set fl1 $tempfl1
            }
	  if { [string first "Name" $line] == 1 }  {
            if {$tempfl1 > $fl1}  {
              set fl1 $tempfl1
              }
	    set hf1 1
	    set hf1a 0

	    while {$hf1a < $hdrflds}  {
	      set fname "$archdr.h$hf1"
	      if {[info commands $fname] == ""}  {
	        label $fname -relief groove
	        }
	      $fname configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text [ lindex $line $hf1a ]
              incr hf1
              incr hf1a
	      }

#  Gotta fiddle with these for v1 & v2 - at least for v2.02 --
#  spacing is different - this is a temp kluge, we have to do the
#  field by field analysis thing later. Bzzt!
            incr fl1 10
            $archdr.h1 configure -width $fl1
            $archdr.h2 configure -width 8
            $archdr.h3 configure -width 8
            $archdr.h4 configure -width 6
            $archdr.h5 configure -width 8
            $archdr.h6 configure -width 6
            $archdr.h7 configure -width 6
            $archdr.h8 configure -width 8
            $archdr.h9 configure -width 5
            $archdr.h10 configure -width 4
            if {$RarVer > 1}  {
              $archdr.h4 configure -width 4
              $archdr.h7 configure -width 9
              $archdr.h8 configure -width 9
              $archdr.h9 configure -width 4
# Test...
# $archdr.h3 configure -width 7
# $archdr.h5 configure -width 7
# $archdr.h7 configure -width 8
              }

	    pack $archdr.h1 $archdr.h2 $archdr.h3 $archdr.h4 $archdr.h5 $archdr.h6 $archdr.h7 $archdr.h8 $archdr.h9 -side left  
	    pack $archdr.h10 -anchor w -side left -fill x -expand yes

            }
          if { [string first "--------" $line] == 0 }  {
            #  Stop or resume ignoring data lines...
            if {$ignline}  {
              set startdata 1
              }  else  {
              set ignline 1
              set startdata 0
              }
            }
          if {! $ignline}  {
            #  Ignore broken rar msg - it will always happen if we've copied from a device)
            if {[string first "Program aborted" $line] < 0 && [string first "Broken archive" $line] < 0}  {
              set line [string trimleft $line]
              $arcbody.alist insert end $line
            #  Hack to deal with spacey Win95 style filenames...
            #  If one is found in the archive, force selectmode single, so we
            #  might have a chance of getting viewing to work.
            set tmpfn [string trim [lrange $line 0 0]]  
            if {[string first " " $tmpfn] != -1}  {
              set spacey 1
              set tmp "spacey$thiswin"
              global $tmp
              set $tmp $spacey
              }
              #  Keep track of widest line...
              if { $ll1 > $llen } {
                set llen $ll1
                }
              }
            }
           if { $startdata }  {
             set ignline 0
             }
          }
        catch { close $in }
#  I think this should be about it for the data....
#  Now, what about error checking and window size configure...?
#  Well, only Zip needs some special checking at this point.

#  Window size - may need xscrollbar...
        if {$hdrwidth > $dfltwidth}  {
          set dfltwidth $hdrwidth
          }
	if { $llen > $dfltwidth } {
	  set ll1 $llen
	  set llen $dfltwidth
	  if {[info commands $arcbody.scrollx] == ""}  {
            scrollbar $arcbody.scrollx -orient horizontal -command "$arcbody.alist xview"
            }
          $arcbody.alist configure -xscroll "$arcbody.scrollx set"
	  }

        $arcbody.alist configure -width $llen
        if { $ll1 > $llen } {
	  pack $arcbody.scrollx -fill x -side bottom
	  } 
#  Do we want to do this here...?
        pack $arcbody.alist  -side left -fill both -expand yes
#--------------------


return 1
}

#--------------------------------------------------------------
#  GetVRar  --  Get a member to view from a RAR
#
#--------------------------------------------------------------
proc GetVRar {owner dirname arcname flist tmpd errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "GetVRar"

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev"}  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }

set temprar "TmpRar$owner"
global $temprar
set temprarfile [set $temprar]

#  Make sure unrar will like the filename...
set tmp [string length $arcname]
incr tmp -4
set tmp2 [string last ".rar" $arcname]
if {$tmp != $tmp2}  {
  set TheFile $temprarfile
  }  else  {
  set TheFile $TheArcFile
  }

#  Can't extract to stdout or to a specific name - put in tmp dir & copy...
#set where [pwd]
#cd $TempDir
#set rc [catch {exec unrar x $TheFile $fname >$errf 2>$errf} cc]
#cd $where
#set crc [catch {exec cp $TempDir/$fname $tmpf} cc]
#catch [exec rm $TempDir/$fname]
#if {$rc > 0}  {
#  set rc 0
#  }
set errc 0
set rc 0
set where [pwd]
set xlist ""
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

cd $tmpd
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  set rc [catch {exec unrar x $TheFile $fn >$errf 2>$errf} cc]
  if {$rc != 0}  {
    cd $where
    return $rc
    }
  incr ll2
  }
cd $where

return $rc
}

#-----------------------------------------------------------------
#  ExtRar  --  Extract member(s) from a RAR
#     -- I don't know whether rar will store directory entries --
#        for now, we don't support extracting such entries if they
#        do exist.
#-----------------------------------------------------------------
proc ExtRar {owner dirname arcname whereto fname flist lstf errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG Home MyPid ErrArgs
set thisproc "ExtRar"

set statw ".$owner.top.vopt.stat"
set stat "Stat$owner"
global $stat
set $stat "          "
$statw configure -textvariable $stat -fg red

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev"}  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }

set temprar "TmpRar$owner"
global $temprar
set temprarfile [set $temprar]
set rc 0

#  Make sure unrar will like the filename...
set tmp [string length $arcname]
incr tmp -4
set tmp2 [string last ".rar" $arcname]
if {$tmp != $tmp2}  {
  set TheFile $temprarfile
  }  else  {
  set TheFile $TheArcFile
  }

#  Pay no attention to fname, we may have a lotta files to extract...
#  gotta access the list of member names to extract.
#  For each file in list, just extract in the target dir.

set $stat "Extracting"
$statw configure -fg red
update idletasks
set xlist ""
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

set where [pwd]
cd $whereto
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1 && $rc == 0}  {
  set fn [lindex $xlist $ll2]
  set rc [catch {exec unrar x $TheFile $fn >$lstf 2>$errf} cc]
#puts "ExtRar:  rc = $rc  cc = $cc"

#  Special handling needed for common error check func...
  set errfltxt ""
  if {$TkzG(Portable)}  {
    if {[file size $lstf] > 0}  {
      set ef ""
      catch {set ef [open $lstf r]}     
      if {$ef != ""}  {
        while {[ gets $ef line ] > -1}  {
          set errfltxt "$errfltxt$line"
          }
        }
      catch {close $ef}
      }
    }  else  {
    set errfltxt [exec cat $lstf]
    }
  if {[string first "Total errors" $errfltxt] != -1}  {
# puts $errfltxt
    incr TmpNo
    set tno $TmpNo
    if {! $TkzG(DseFlag)}  {
      if {$TkzG(Portable)}  {
        catch {file copy -force $lstf $Home/TkzLst$MyPid-$tno}
        catch {file copy -force $errf $Home/TkzErr$MyPid-$tno}
        }  else  {
        catch {exec cp $lstf $Home/TkzLst$MyPid-$tno}
        catch {exec cp $errf $Home/TkzErr$MyPid-$tno}
        }
      }
    set ErrArgs [ list "$Home/TkzLst$MyPid-$tno" "$Home/TkzErr$MyPid-$tno" $lstf $errf]
    $statw configure -bg black
    set $stat "Done"
    GErrMsgBox 93
    return -1
    }


  incr ll2
  }

$statw configure -fg black
set $stat "   Done   "
#  Now done in common error check func
#if {$TkzG(Portable)}  {
#  catch { [file delete -force $lstf $errf $flist] }
#  }  else  {
#  catch { [exec rm $lstf $errf $flist] }
#  }

cd $where
return $rc
}



#--------------------------------------------------------------
#  The Shorten Handling Routines --  Handle Shorten files
#
#--------------------------------------------------------------

#--------------------------------------------------------------
#  GetDirShn  --  Get the Archive Directory list data for a SHN
#
#--------------------------------------------------------------
proc GetDirShn {owner dirname arcname dummyname errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TwButBg TwButFg
global TkzG

set thisproc "GetDirShn"
set thiswin $owner
set WinName ".$owner"
set topf "$WinName.top"
set archdr "$WinName.hdr"
set arcbody "$WinName.body"
set fv "ArcFno$thiswin"
global $fv
set ArcFno [set $fv]
set WButBg $TwButBg($ArcFno)
set WButFg $TwButFg($ArcFno)
# incr TmpNo
set tno $TmpNo
set tmpf "$TempDir/TkzTmp$tno"
# set errf "$TempDir/TkzErr$tno"
#set killist "Kill$owner"
#global $killist
#set $killist [lappend $killist $dirfile]

set ap "ArcPgm$thiswin"
set lf "ListFlags$thiswin"
global $ap $lf
set arcpgm [set $ap]
set listflags [set $lf]


set arcpgm "shorten"
set listflags "-x"

#  Shorten is even more of a no-brainer than ar.... 
#  There is no listing, no info, not even the original file name. We don't even 
#  need to read the file. Shorten is fairly primitive, so...
#


set nlen [expr [string length $arcname] ]
incr nlen -4
if {[string range $arcname $nlen end] == ".shn"}  {
  incr nlen -1
  set line [string range $arcname 0 $nlen]
  }  else {
  set line $arcname
  }

if {[info commands $archdr.h1] == ""}  {
  label $archdr.h1 -relief groove
  }
pack $archdr.h1 -anchor w -side left -fill x -expand yes
$archdr.h1 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "           Name        "
$archdr.h1 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg \
  -text "  Name       (Possibly lossy algorithm: uncompressed file may not match original.)"
$arcbody.alist insert end $line
#  Thatz all, folks....
#  Now, what about error checking and window size configure...?

#  Window size - don't need xscrollbar...
        $arcbody.alist configure -width 80
#  Do we want to do this here...?
        pack $arcbody.alist  -side left -fill both -expand yes



return 1
}

#--------------------------------------------------------------
#  GetVShn  --  Get a member to view from a SHN
#
#--------------------------------------------------------------
proc GetVShn {owner dirname arcname flist tmpd errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "GetVShn"

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }


#  Can't extract to stdout or to a specific name - put in tmp dir & copy...

#set where [pwd]
#cd $TempDir
#
#set rc [catch {exec shorten -x $TheArcFile $fname 2>$errf} cc]
#cd $where
#catch [exec cp $TempDir/$fname $tmpf]
#catch [exec rm $TempDir/$fname]
set errc 0
set rc 0
set where [pwd]
set xlist ""
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

cd $tmpd
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  set tmpf "$tmpd/$fn"
  set rc [catch {exec shorten -x $TheArcFile $tmpf 2>$errf} cc]

  if {$rc > 0}  {
    set rc 0
    }
  if {$rc != 0}  {
    cd $where
    return $rc
    }
  incr ll2
  }

cd $where
return $rc
}

#--------------------------------------------------------------
#  ExtShn  --  Extract member(s) from a SHN
#
#--------------------------------------------------------------
proc ExtShn {owner dirname arcname whereto fname flist lstf errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG

set thisproc "ExtShn"
set statw ".$owner.top.vopt.stat"
set stat "Stat$owner"
global $stat
set $stat "          "
$statw configure -textvariable $stat -fg red

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev"  }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }
set rc 0

#  Just go to the target dir and extract...
#  Pay no attention to flist, there's only one file to extract...
set where [pwd]
cd $whereto
set $stat "Extracting"
$statw configure -fg red
update idletasks
set rc [catch {exec shorten -x $TheArcFile $fname >$lstf 2>$errf} cc]
$statw configure -fg black
set $stat "   Done   "
#  Now done in common error check func
#if {$TkzG(Portable)}  {
#  catch { [file delete -force $lstf $errf $flist] }
#  }  else  {
#  catch { [exec rm $lstf $errf $flist] }
#  }

cd $where
return $rc
}

#--------------------------------------------------------------
#  AddShn  --  "Add" to a shorten File
#    Called Add for consistency, it's really just Compress.
#    It gets a filelist with one member.
#
#    Options supported:
#        None at present...  
#--------------------------------------------------------------
proc AddShn {parent owner dirname arcname flist lstf errf} {
set thisproc "AddShn"
global PgmName ErrArgs
global TkzG


#set tmp "creating$parent"
#global $tmp
#set creating [set $tmp]
#set tmp "apn$owner"
#global $tmp
#set apn [set $tmp]
#set tmp "recurs$owner"
#global $tmp
#set recurs [set $tmp]
set tmp "ArcFno$parent"
global $tmp
set type [set $tmp]
set rc 0
set TheArcFile $dirname/$arcname
set xlist ""

if [ catch {set fl [open $flist r]} ]  {
  puts "$thisproc:    open failure"
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

set align ""
set flags ""
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  set rc [catch {exec shorten $fn $TheArcFile >$lstf 2>$errf} cc]
  if {$rc != 0}  {
    break
    }
  incr ll2
  }

if {$rc != 0}  {
  if {$TkzG(ShnHeur)}  {
    #  If at first you don't succeed...
    #  Non-portable...
    set errtxt ""
    if {$TkzG(Portable)}  {
      if {[file size $errf] > 0}  {
        set ef ""
        catch {set ef [open $errf r]}     
        if {$ef != ""}  {
          while {[ gets $ef efline ] > -1}  {
            set errtxt "$errtxt$efline"
            }
          }
        catch {close $ef}
        }
      }  else  {
      set errtxt [exec cat $errf]
      }
    set o1 [string first " extra bytes" $errtxt]
    if {$o1 != -1}  {
      set o2 $o1
      while {[string index $errtxt $o2] == " "}  {
        incr o2 -1
        }
      set o1 $o2
      while {[string index $errtxt $o1] != " "}  {
        incr o1 -1
        }
      incr o1
      set align [string range $errtxt $o1 $o2]
      set line "\n#--------\n$PgmName will heuristically try an option of -a$align\n#--------\n"
      #  Non-portable...?
      catch {exec echo "$line" >>$errf}
      set rc [catch {exec shorten -a$align $fn $TheArcFile >>$lstf 2>>$errf} cc]
      if {$rc == 0}  {
        set ErrArgs [list $TheArcFile "-a$align"]
        GErrMsgBox 86
        }
      }
    }
  if {$rc != 0}  {
    set ErrArgs [list $lstf $errf $TheArcFile]
    GErrMsgBox 89
    return $rc
    }
  }


return $rc
}




#----------------------------------
#  The next ones to do...
#----------------------------------



#--------------------------------------------------------------
#  The Zip Handling Routines --  Handle Zip files
#
#--------------------------------------------------------------

#--------------------------------------------------------------
#  GetDirZip  --  Get the Archive Directory list data for a ZIP
#
#--------------------------------------------------------------
proc GetDirZip {owner dirname arcname dummyname errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TwButBg TwButFg
global TkzG

set thisproc "GetDirZip"
set thiswin $owner
set WinName ".$owner"
set topf "$WinName.top"
set archdr "$WinName.hdr"
set arcbody "$WinName.body"
set fv "ArcFno$thiswin"
global $fv
set ArcFno [set $fv]
set WButBg [lindex $TButBg $ArcFno]
set WButBg $TwButBg($ArcFno)
set WButFg $TwButFg($ArcFno)
# incr TmpNo
set tno $TmpNo
set tmpf "$TempDir/TkzTmp$tno"
set dirfile "$TempDir/TkzDir$tno"
set killist "Kill$owner"
global $killist
set $killist [lappend $killist $dirfile $tmpf]

set ap "ArcPgm$thiswin"
set lf "ListFlags$thiswin"
global $ap $lf
set arcpgm [set $ap]
set listflags [set $lf]

set tmp "spacey$thiswin"
global $tmp
set spacey [set $tmp]
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
#  Zip doesn't like to read from devices at all...
if { $dirname == "/dev" }  {
    set TheArcFile $tmparc
  }


# set arcpgm "unzip"
# set listflags "-v"

#--------------------
# Now read the list...
#	set rc [ catch { set in [ open [ concat "|$arcpgm $listflags $dirname/$arcname 2>$errf" ] r ] } cc]
        set rc [catch {exec unzip -v $TheArcFile >$dirfile 2>$errf} tmp]
        if [ catch {set in [open $dirfile r]} ]  {
          #  The caller needs to take the appropriate action here...
          #  just tell him nfg...
	  return -1
	  }

        set dfltwidth 80
        set hdrwidth 0
        set hdrflds 8
        set llen 0
        set ll1 0
        set fl1 0
	set lineno 0
	set ignline 1
        set prepdata 0
	set startdata 0
        while  { [ gets $in line ] > -1 } {
          set ll1 [expr [string length $line] ]
	  #  Customize the column headings for the archive type from listing data in this loop...
	  incr lineno
          set tempfl1 [ string length [lindex $line 1] ]
          if {$tempfl1 > $fl1}  {
            set fl1 $tempfl1
            }
	  if { [string first "Length" $line] == 1 }  {
            set prepdata 1
	    set hf1 1
	    set hf1a 0

	    while {$hf1a < $hdrflds}  {
	      set fname "$archdr.h$hf1"
              if {[info commands $fname] == ""}  {
	      label $fname -relief groove
                }
	      $fname configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text [ lindex $line $hf1a ]
              incr hf1
              incr hf1a
	      }


            }
#          if { [string first "------" $line] == 0 || [string first "------" $line] == 1 }  {
#            }
#          if { [string first "-------" $line] != -1 }  {
#            }
#  Some versions have fewer dashes...try a short sequence. This should work
#  with relatively recent versions.
          if { [string first "----" $line] != -1 }  {
            #  Stop or resume ignoring data lines...
            if {$prepdata}  {
              if {$ignline}  {
                set startdata 1
              $archdr.h1 configure -width 8 \
                -font "-*-$TkzG(DirHdFont)-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
              $archdr.h2 configure -width 7 \
                -font "-*-$TkzG(DirHdFont)-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
              $archdr.h3 configure -width 8 \
                -font "-*-$TkzG(DirHdFont)-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
              $archdr.h4 configure -width 5 \
                -font "-*-$TkzG(DirHdFont)-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
              $archdr.h5 configure -width 8 \
                -font "-*-$TkzG(DirHdFont)-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
              $archdr.h6 configure -width 7 \
                -font "-*-$TkzG(DirHdFont)-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
              $archdr.h7 configure -width 10 \
                -font "-*-$TkzG(DirHdFont)-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
              $archdr.h8 configure -width 8 \
                -font "-*-$TkzG(DirHdFont)-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
	      pack $archdr.h1 $archdr.h2 $archdr.h3 $archdr.h4 $archdr.h5 $archdr.h6 $archdr.h7 -side left  
	      pack $archdr.h$hdrflds -anchor w -side left -fill x -expand yes
                }  else  {
                set ignline 1
                set startdata 0
                }
              }
            }
          if {! $ignline}  {
            $arcbody.alist insert end $line
            #  Hack to deal with spacey Win95 style filenames...
            #  If one is found in the archive, force selectmode single, so we
            #  might have a chance of getting viewing to work.
            set tmpfn [string trim [lrange $line 7 end]]  
            if {[string first " " $tmpfn] != -1}  {
              set spacey 1
              set tmp "spacey$thiswin"
              global $tmp
              set $tmp $spacey
              }
            #  Keep track of widest line...
            if { $ll1 > $llen } {
              set llen $ll1
              }
            }
           if { $startdata }  {
             set ignline 0
             }
          }
        catch { close $in }
#  I think this should be about it for the data....
#  Now, what about error checking and window size configure...?
#  Well, Zip needs some special checking at this point.
if {$lineno < 2}  {
  return -2
  }

#  Window size - may need xscrollbar...
        if {$hdrwidth > $dfltwidth}  {
          set dfltwidth $hdrwidth
          }
#	if { $llen > $dfltwidth } {
#	  set ll1 $llen
#	  set llen $dfltwidth
          if {[info commands $arcbody.scrollx] == ""}  {
            scrollbar $arcbody.scrollx -orient horizontal -command "$arcbody.alist xview"
            }
          $arcbody.alist configure -xscroll "$arcbody.scrollx set"
#	  }

        $arcbody.alist configure -width $llen
#        if { $ll1 > $llen } {
	  pack $arcbody.scrollx -fill x -side bottom
#	  } 
#  Do we want to do this here...?
        pack $arcbody.alist  -side left -fill both -expand yes
##--------------------


return 1
}

#--------------------------------------------------------------
#  GetVZip  --  Get a member to view from a ZIP
#
#--------------------------------------------------------------
proc GetVZip {owner dirname arcname flist tmpd errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "GetVZip"

set thiswin $owner
set tmp "spacey$owner"
global $tmp
set spacey [set $tmp]
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" }  {
  set TheArcFile $tmparc
  }

#  Extract to stdout as tmp file...
#-------------
set errc 0
set rc 0
set where [pwd]
set xlist ""
catch {unset xlist}
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
cd $tmpd
while {[ gets $fl line ] > -1}  {
## Temp test code...
#  set fn [string trim $line]
#  if {[string first " " $fn]}  {
#    #  Gotta add error check one of these days...
#    puts "Trying to view '$fn'..."
#    set rc [catch {exec unzip -o $TheArcFile $fn >$lstf 2>$errf} cc]
#    }  else  {
#    set xlist "$xlist $line"
#    }
  lappend xlist [string trim $line]
  }
catch {close $fl}

cd $tmpd
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  set tmpf "$tmpd/$fn"
    set l1 [string last "/" $fn]
    if {$l1 != -1}  {
      incr l1
      set sfn [string range $fn $l1 end]
      }  else  {
      set sfn $fn
      }
  set rc [catch {exec unzip -pj $TheArcFile $fn >$sfn  2>$errf} cc]
  #  Zip is a nice program - no more dorking around needed!
  if {$rc != 0}  {
    cd $where
    return $rc
    }
  incr ll2
  }
#------------

if {$rc > 0}  {
  set rc 0
  }
cd $where
return $rc
}

#--------------------------------------------------------------
#  ExtZip  --  Extract member(s) from a ZIP
#
#--------------------------------------------------------------
proc ExtZip {owner dirname arcname whereto fname flist lstf errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "ExtZip"

set statw ".$owner.top.vopt.stat"
set stat "Stat$owner"
global $stat
set $stat "          "
set fv "ArcFno$owner"
global $fv
set ArcFno [set $fv]
if {$ArcFno == 2}  {
  set vred "red"
  }  else  {
  #  Because the background on that one is also red...
  #  so call this virtual red.
  set vred "green"
  }

set tmp "apn2$owner"
global $tmp
set apn2 [set $tmp]
set tmp "jpn2$owner"
global $tmp
set jpn2 [set $tmp]
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" }  {
  set TheArcFile $tmparc
  }
set tmp "sdirl$owner"
global $tmp
set flist3 [set $tmp]
if {$jpn2}  {
  set theflags "-oj"
  }  else  {
  set theflags "-o"
  }
set rc 0


$statw configure -textvariable $stat -fg $vred

#  Pay no attention to fname, we may have a lotta files to extract...
#  gotta access the list of member names to extract.
#  For each file in list, just extract in the target dir.
set $stat "Extracting"
$statw configure -fg $vred

update idletasks
set xlist ""
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  set fn [string trim $line]
  #  Gotta add error check one of these days...
  lappend xlist [string trim $line]
  }
catch {close $fl}

##  TEMP...
#puts "xlist = $xlist"
#puts "flist3 = $flist3"
#puts "lstf = <$lstf>  errf = <$errf>"
set where [pwd]
cd $whereto
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1 && $rc == 0}  {
  set fn [lindex $xlist $ll2]
#  set rc [catch {exec unzip -o $TheArcFile $fn >$lstf 2>$errf} cc]
  set cmd [list "exec" "unzip" "$theflags" "$TheArcFile" "$fn" ">$lstf" "2>$errf"]
  set rc [catch {set trc [eval $cmd]} cc]
#puts "Loop1 - rc = $rc"
  incr ll2
  }
if {$rc != 0}  {

  }

#------------
set ll1 0
set ll2 0
catch {set ll1 [llength $flist3]}
if {! $rc && $ll1 != 0}  {
  while {$ll2 < $ll1 && $rc == 0}  {
    set fn [lindex $flist3 $ll2]
#    set rc [catch {exec unzip -o $TheArcFile $fn >>$lstf 2>>$errf} cc]
    set cmd [list "exec" "unzip" "$theflags" "$TheArcFile" "$fn" ">$lstf" "2>$errf"]
    set rc [catch {set trc [eval $cmd]} cc]
#puts "Loop2 - rc = $rc"
    incr ll2
    }
  }
#------------

$statw configure -fg black
set $stat "   Done   "
#  Now done in common error check func
#if {$TkzG(Portable)}  {
#  catch { [file delete -force $lstf $errf $flist] }
#  }  else  {
#  catch { [exec rm $lstf $errf $flist] }
#  }

cd $where
#puts "ExtZip returning rc = $rc"
return $rc
}

#--------------------------------------------------------------
#  DelZip  --  Delete member(s) from a ZIP
#
#--------------------------------------------------------------
proc DelZip {owner dirname arcname flist lstf errf} {
set thisproc "DelZip"
global ErrArgs
global TkzG

set TheArcFile $dirname/$arcname
catch {unset xlist}
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  set rc [catch {exec zip -d $TheArcFile $fn >$lstf 2>$errf} cc]
  if {$rc != 0}  {
    break
    }
  incr ll2
  }

if {$rc != 0}  {
  set ErrArgs [list $lstf $errf $TheArcFile]
  GErrMsgBox 87
  return $rc
  }

return $rc
}

#--------------------------------------------------------------
#  AddZip  --  Add member(s) to a ZIP
#
#    Options supported:
#        Loose or keep pathnames  --  default: keep pathnames
#        Recurse subdirectories?  --  default: no
#--------------------------------------------------------------
proc AddZip {parent owner dirname arcname flist lstf errf} {
set thisproc "AddZip"
global ErrArgs TkzG

set tmp "creating$parent"
global $tmp
set creating [set $tmp]
set tmp "jpn$owner"
global $tmp
set jpn [set $tmp]
set tmp "apn$owner"
global $tmp
set apn [set $tmp]
set tmp "rpn$owner"
global $tmp
set rpn [set $tmp]
set tmp "recurs$owner"
global $tmp
set recurs [set $tmp]

set TheArcFile $dirname/$arcname
catch {unset xlist}
set body "$owner.body"
set cdvar "CraDir$body"
global $cdvar
set where [set $cdvar]

if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

set flags ""
#  Zip doesn't seem to allow absolute pathnames anyway...
#  unless it has a compile option to cause it to.
if {! $apn && ! $jpn && ! $rpn}  {
  cd "/"
  }

#puts "where = $where"
#set tmpshit [pwd]
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
#puts "Adding $fn to $TheArcFile from $tmpshit"
  if {! $jpn}  {
    if {! $apn}  {
      if {$rpn}  {
        if {[string first $where $fn] == 0}  {
          set fn [string range $fn [string length $where] end]
          if {[string range $fn 0 0]  == "/"}  {
            set fn [string range $fn 1 end]
            }
          }
        }  else  {
        set fn [string range $fn 1 end]
        }
      }
    if {! $recurs}  {
      if {$TkzG(CompOpt) != 0}  {
        set cmd [list "exec" "zip" "-$TkzG(CompOpt)" $TheArcFile $fn ">$lstf" "2>$errf"]
        }  else  {
        set cmd [list "exec" "zip" $TheArcFile $fn ">$lstf" "2>$errf"]
        }
      set rc [catch {set rc [eval $cmd]} cc]
      }  else  {
      if {$TkzG(CompOpt) != 0}  {
        set cmd [list "exec" "zip" "-$TkzG(CompOpt)" "-r" $TheArcFile $fn ">$lstf" "2>$errf"]
        }  else  {
        set cmd [list "exec" "zip" "-r" $TheArcFile $fn ">$lstf" "2>$errf"]
        }
      set rc [catch {set rc [eval $cmd]} cc]
      }
    }  else  {
    if {! $recurs}  {
      if {$TkzG(CompOpt) != 0}  {
        set cmd [list "exec" "zip" "-$TkzG(CompOpt)" "-j" $TheArcFile $fn ">$lstf" "2>$errf"]
        }  else  {
        set cmd [list "exec" "zip" "-j" $TheArcFile $fn ">$lstf" "2>$errf"]
        }
      set rc [catch {set rc [eval $cmd]} cc]
      }  else  {
      if {$TkzG(CompOpt) != 0}  {
        set cmd [list "exec" "zip" "-$TkzG(CompOpt)" "-j" "-r" $TheArcFile $fn ">$lstf" "2>$errf"]
        }  else  {
        set cmd [list "exec" "zip" "-j" "-r" $TheArcFile $fn ">$lstf" "2>$errf"]
        }
      set rc [catch {set rc [eval $cmd]} cc]
      }
    }
  if {$rc != 0}  {
    break
    }
  incr ll2
  }


cd $where
if {$rc != 0}  {
  set ErrArgs [list $lstf $errf $TheArcFile]
  GErrMsgBox 88
  return $rc
  }

return $rc
}




#--------------------------------------------------------------
#  The Tar Handling Routines --  Handle Tar files
#    - new structure will make it much cleaner to deal with
#      different styles of tar
#
#--------------------------------------------------------------

#--------------------------------------------------------------
#  GetDirTar  --  Get the Archive Directory list data for a TAR
#
#--------------------------------------------------------------
proc GetDirTar {owner dirname arcname dummyname errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg 
global DSlidBg EntBg EntFg SelBg SelFg
global GotGtar GotTar
global TkzG

set thisproc "GetDirTar"
set thiswin $owner
set WinName ".$owner"
set tmp "spacey$owner"
global $tmp
set spacey [set $tmp]
set topf "$WinName.top"
set archdr "$WinName.hdr"
set arcbody "$WinName.body"
set fv "ArcFno$thiswin"
global $fv
set ArcFno [set $fv]
set bar ".main.list1.diry"
    set WBg [lindex $TBg $ArcFno]
set WButBg [lindex $TButBg $ArcFno]
    set WFg [lindex $TFg $ArcFno]
set WBg $TwBg($ArcFno)
set WFg $TwFg($ArcFno)
set WButBg $TwButBg($ArcFno)
set WButFg $TwButFg($ArcFno)
set WLBg $TwLBg($ArcFno)
set WLFg $TwLFg($ArcFno)
set WEntBg $EntBg($ArcFno)
set WEntFg $EntFg($ArcFno)
set WSelBg $SelBg($ArcFno)
set WSelFg $SelFg($ArcFno)
set WSBg $SlidBg($ArcFno)
set WTCol $TrCol($ArcFno)
if {$WSBg != "UseTk"}  {
  if {$WSBg == "UseDefault"}  {
    set WSBg $DSlidBg
    }  else  {
    set WSBg $SlidBg($ArcFno)
    }
  }  else  {
  set tmp [$bar configure -bg]
  set WSBg [lindex $tmp 3]
  }
if {$WTCol != "UseTk"}  {
  if {$WTCol == "UseBg"}  {
    set WTCol $WBg
    }  else  {
    set WTCol $TrCol($ArcFno)
    }
  }  else  {
  set tmp [$bar configure -troughcolor]
  set WTCol [lindex $tmp 3]
  }


set rc 0
set trc 0
# incr TmpNo
set tno $TmpNo
set tmpf "$TempDir/TkzTmp$tno"
# set errf "$TempDir/TkzErr$tno"
set dirfile "$TempDir/TkzDir$tno"
set killist "Kill$owner"
global $killist
set $killist [lappend $killist $dirfile $tmpf $errf]

set ap "ArcPgm$thiswin"
set lf "ListFlags$thiswin"
global $ap $lf
set arcpgm [set $ap]
set listflags [set $lf]
set tmp "SimpleCmp$thiswin"
global $tmp
set simple [set $tmp]


set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" && [string first "n" $arcname] == 0 }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }


#  Oh, pain...
#  Gotta reset these because we may have come in from the Gzip or Compress routines
if {$dummyname != "dummy"}  {
  $topf configure -bg $WBg -highlightbackground $WBg
  set buttons "$topf.but"
  set vopts "$topf.vopt"

  $buttons configure -bg $WButBg
  $buttons.quit configure -bg $WButBg -highlightbackground $WButBg -fg $WButFg
  $buttons.selall configure -bg $WButBg -highlightbackground $WButBg -fg $WButFg
  $buttons.view configure -bg $WButBg -highlightbackground $WButBg -fg $WButFg
  $buttons.ext configure -bg $WButBg -highlightbackground $WButBg -fg $WButFg
  $buttons.add configure -bg $WButBg -highlightbackground $WButBg -fg $WButFg
  $buttons.del configure -bg $WButBg -highlightbackground $WButBg -fg $WButFg
  $buttons.uninst configure -bg $WButBg -highlightbackground $WButBg -fg $WButFg
  $buttons.selv configure -bg $WButBg -highlightbackground $WButBg -fg $WButFg
  $buttons.selv.m configure -bg $WButBg -fg $WButFg

  $vopts.vname configure -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg
  $vopts.vbin configure -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg

  $vopts configure -bg $WBg -highlightbackground $WBg
  $vopts.vndsc configure -bg $WBg -highlightbackground $WBg -fg $WFg
  $vopts.vbdsc configure -bg $WBg -highlightbackground $WBg -fg $WFg
  $vopts.stat configure -bg $WBg -highlightbackground $WBg -fg $WFg
  $arcbody.alist configure -bg $WLBg -fg $WLFg
  $arcbody.alist configure -selectbackground $WSelBg -selectforeground $WSelFg
  $arcbody.scrolly configure -bg $WSBg -troughcolor $WTCol
#  Damn!  the slider colors...what to do?
  #  If this is a complex archive, so indicate...
#  if {$simple}  {
    set tmp "SimpleCmp$thiswin"
    $buttons.add configure -state normal
    set simple 0
    set $tmp $simple
#    }
  }

#  Temp location...
if {$TkzG(GotGtar2) && $TkzG(PreferGtar)}  {
  set arcpgm $TkzG(GtarName)
  }  else  {
  if {! $GotTar && $TkzG(GotGtar2)}  {
    set arcpgm $TkzG(GtarName)
    }  else  {
    set arcpgm "tar"
    }
  }
if {$GotGtar && $TkzG(UseGtar)}  {
  if {$arcpgm != "tar" || $TkzG(TarIsGtar)}  {
    set listflags "-tvf"
    }  else  {
    set listflags "tvf"
    }
  }  else  {
  set listflags "tvf"
  }

#--------------------
# Now read the list...
        if {$dummyname == "dummy"}  {
          set cmd [list "exec" $arcpgm $listflags $TheArcFile ">$dirfile" "2>$errf"]
          set rc [catch {set trc [eval $cmd]} cc]
          if {$TkzG(Debug)} {
              set dbmsg "Tkz-0003:    tar dirlist for $TheArcFile (rc $rc): \
                \n    command = <$cmd>\
                \n    response: <$cc>"
              DeBug $owner $dbmsg
            }
          }  else  {
          set cmd [list "exec" $arcpgm $listflags $dummyname ">$dirfile" "2>$errf"]
          set rc [catch {set trc [eval $cmd]} cc]
          if {$TkzG(Debug)} {
              set dbmsg "Tkz-0003:    inner tar dirlist for $dummyname (rc $rc): \
                \n    command = <$cmd>\
                \n    response: <$cc>"
              DeBug $owner $dbmsg
            }
          }

        if [ catch {set in [open $dirfile r]} ]  {
          #  The caller needs to take the appropriate action here...
          #  just tell him nfg...
	  return -1
	  }

        set dfltwidth 80
        set hdrwidth 0
        set hdrflds 5
        set llen 0
        set ll1 0
        set fl1 0
#--------------------------
        set fl1 11
        set fl2 11
        set fl3 8
        set fl4 8
        set fl5 8
#--------------------------
	set lineno 0
	set ignline 1
	set startdata 0
	# Heading for tar...
	if {[info commands $archdr.h1] == ""}  {
          label $archdr.h1 -relief groove
          }
	if {[info commands $archdr.h2] == ""}  {
          label $archdr.h2 -relief groove
          }
	if {[info commands $archdr.h3] == ""}  {
          label $archdr.h3 -relief groove
          }
	if {[info commands $archdr.h4] == ""}  {
          label $archdr.h4 -relief groove
          }
	if {[info commands $archdr.h5] == ""}  {
          label $archdr.h5 -relief groove
          }
        pack $archdr.h1 $archdr.h2 $archdr.h3 $archdr.h4 -side left  
	pack $archdr.h5 -anchor w -side left -fill x -expand yes
	$archdr.h1 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "   Perm       " \
              -font "-*-$TkzG(DirHdFont)-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
	$archdr.h2 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "  Owner/Grp  " \
              -font "-*-$TkzG(DirHdFont)-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
	$archdr.h3 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "  Size    " \
              -font "-*-$TkzG(DirHdFont)-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
	$archdr.h4 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "      Date        " \
              -font "-*-$TkzG(DirHdFont)-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
	$archdr.h5 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "           Name        " \
              -font "-*-$TkzG(DirHdFont)-bold-*-*-*-*-*-*-*-*-*-iso8859-1"
	# End tar heading...
        while  { [ gets $in line ] > -1 } {
          #  Adapt column widths to actual data found...
          set fc 0
          while {$fc < $hdrflds}  {
            set fld [lindex $line $fc]
            set fl [string length [lindex $line $fc]]
            incr fc
            set fln "fl$fc"
            if {$fl > [set $fln]}  {
               set $fln $fl
               }
            }
          $arcbody.alist insert end $line
          #  Hack to deal with spacey Win95 style filenames...
          #  If one is found in the archive, force selectmode single.
          set tmpfn [string trim [lrange $line 7 end]]  
          if {[string first " " $tmpfn] != -1}  {
            set spacey 1
            set tmp "spacey$thiswin"
            global $tmp
            set $tmp $spacey
            }
          }
        catch { close $in }
#  I think this should be about it for the data....
#  Now, what about error checking and window size configure...?
#  Well, only Zip needs some special checking at this point.

#----------------------------
#  Temp stuff -- get all the columns of data reasonably aligned with headings
#  This needs to be cleaned up, then generalized for all the directory functions...
set fc 0
while {$fc < 3}  {
  incr fc
  set fln "fl$fc"
  set fl [set $fln]
  $archdr.h$fc configure -width $fl
#  puts "$thisproc:    Field $fc length should be $fl "  
  }
#  ToDo --
#    - read the whole goddam listbox, reformatting every entry...tar isn't
#      too finicky about field alignment.
#      - fields 2 (owner) and 3 (size) are the problem ones...
#        fld2 needs to be left justified, fld3 right justified
#
#    - Problem:  some tars don't have a size field, and the date presentation
#      varies wildly. Generalized parsing for this is going to be a major pain
#      in the ol' hemorrhoids.
#
set lsize [$arcbody.alist size]
set lineno 0
while {$lineno < $lsize}  {
  set line [$arcbody.alist get 0]
  #-----------------
  #  New (1.0.5) - try to determine which type of tar listing this is...
  #  Type 5 - has size, date fmt is 1900-01-01 00:00 (GNU 1.12)
  #  Type 6 - has no size, date fmt is Jan 1 00:00 1900
  #  Type 7 - has size, date fmt is Jan 1 00:00 1900
  #
  if {$lineno == 0}  {
    set tartype 7
    set dummy ""
    scan [lindex $line 2] "%d" dummy
    if {$dummy == ""}  {
      set tartype 6
      }  else  {
      set dummy ""
      scan [lindex $line 3] "%d" dummy
      if {$dummy == ""}  {
        set tartype 7
        }  else  {
        set tartype 5
        }
      }
      set tmp "tartype$owner"
      global $tmp
      set $tmp $tartype
    }
  #-----------------
  set fp 0
  set fld1 [lindex $line 0]
  set fpincr [string length $fld1]
  set fp [string first $fld1 [string range $line $fp end]]
  incr fp $fpincr

  set fld2 "[lindex $line 1]                    "
  set fpincr [string length [lindex $line 1]]
  set tfp [string first [lindex $line 1] [string range $line $fp end]]
  incr fp $tfp
  incr fp $fpincr

  set fld2 [string range $fld2 0 $fl2]
  set fld3 [lindex $line 2]
  set fpincr [string length $fld3]
  set tfp [string first $fld3 [string range $line $fp end]]
  incr fp $tfp
  incr fp $fpincr

  set tmpl [string length $fld3]
  set tmp2 "                "
  set tmpl2 [string length $tmp2]
  set tmpl2 [expr $fl3 - $tmpl]
  incr tmpl2 -2
  set tmp2 [string range $tmp2 0 $tmpl2]
  set fld3 "$tmp2$fld3"

  #  Get rest of line...
  set fld4 [string range $line $fp end]
  set line "$fld1 $fld2 $fld3 $fld4   "
  #  and replace the current listbox entry...
  $arcbody.alist delete 0
  $arcbody.alist insert end $line

  set tmp [string length $line]
  if {$tmp > $hdrwidth}  {
    set hdrwidth $tmp
    }
  incr lineno
  }

#----------------------------

#  Window size - may need xscrollbar...
        if {$hdrwidth > $dfltwidth}  {
           set dfltwidth $hdrwidth
#          $arcbody.alist configure -width $dfltwidth
          }
#	if { $llen > $dfltwidth } {
#	  set ll1 $llen
#	  set llen $dfltwidth
          if {[info commands $arcbody.scrollx] == ""}  {
            scrollbar $arcbody.scrollx -orient horizontal -command "$arcbody.alist xview"
            }
          $arcbody.alist configure -xscroll "$arcbody.scrollx set"
#	  }

#        $arcbody.alist configure -width $llen
#        if { $ll1 > $llen } {
	  pack $arcbody.scrollx -fill x -side bottom
#	  } 
#  Do we want to do this here...?
        pack $arcbody.alist  -side left -fill both -expand yes

#--------------------


return 1
}

#--------------------------------------------------------------
#  GetVTar  --  Get a member to view from a TAR
#
#--------------------------------------------------------------
proc GetVTar {owner dirname arcname flist tmpd errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global GotGtar GotTar
global TkzG
set thisproc "GetVTar"

set tmp "spacey$owner"
global $tmp
set spacey [set $tmp]
set tmp "tartype$owner"
global $tmp
set tartype [set $tmp]
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" && [string first "n" $arcname] == 0 }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }

#  If this was a gzipped or compressed tar, then we already have an uncompressed
#  copy lying around, so use it...
set temptar "TmpTar$owner"
global $temptar

set temptarfile [set $temptar]

#  Extract to stdout as tmp file...
#set where [pwd]
#cd $TempDir
#if {$temptarfile == ""}  {
#  set rc [catch {exec tar -xOf $TheArcFile $fname >$tmpf 2>$errf} cc]
#  }  else  {
#  set rc [catch {exec tar -xOf $temptarfile $fname >$tmpf 2>$errf} cc]
#  }
#  Temp location...
if {$TkzG(GotGtar2) && $TkzG(PreferGtar)}  {
  set arcpgm $TkzG(GtarName)
  }  else  {
  if {! $GotTar && $TkzG(GotGtar2)}  {
    set arcpgm $TkzG(GtarName)
    }  else  {
    set arcpgm "tar"
    }
  }
if {$GotGtar && $TkzG(UseGtar)}  {
#  -O is buggy under WinDog...
  if {! $TkzG(Windows)}  {
    if {$arcpgm != "tar" || $TkzG(TarIsGtar)}  {
      set theflags "-xOf"
      }  else  {
      set theflags "xf"
      }
    }  else  {
    set theflags "xf"
    }
  }  else  {
  set theflags "xf"
  }

#-------------------
set errc 0
set rc 0
set trc 0
set where [pwd]
catch {unset xlist}
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

cd $tmpd
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
    set tmpf "$tmpd/$fn"
    set l1 [string last "/" $fn]
    if {$l1 != -1}  {
      incr l1
      set sfn [string range $fn $l1 end]
      }  else  {
      set sfn $fn
      }
#   For the brain-dead tars, we have to extract the full pathname (sans leading
#   slash) then copy the damned thing to where we want it and delete the
#   original. There really ought to be a law against vendors propagating this
#   sort of nonsense.
#   1.0.5 - -O seems buggy in my version of the Windows port - force non-GNU handling
#   for now.
    if {$GotGtar && $TkzG(UseGtar) && ! $TkzG(Windows)}  {
      if {$temptarfile == ""}  {
        set cmd [list "exec" $arcpgm $theflags $TheArcFile $fn ">$sfn" "2>$errf"]
        set rc [catch {set trc [eval $cmd]} cc]
        if {$TkzG(Debug)} {
            set dbmsg "Tkz-0004:    GNU tar extract-view for $TheArcFile (rc $rc): \
              \n    command = <$cmd>\
              \n    response: <$cc>"
            DeBug $owner $dbmsg
          }
        }  else  {
        set cmd [list "exec" $arcpgm $theflags $temptarfile $fn ">$sfn" "2>$errf"]
        set rc [catch {set trc [eval $cmd]} cc]
        if {$TkzG(Debug)} {
            set dbmsg "Tkz-0004:    GNU tar extract-view for $temptarfile (rc $rc): \
              \n    command = <$cmd>\
              \n    response: <$cc>"
            DeBug $owner $dbmsg
          }
        }
      }  else  {
      if {$temptarfile == ""}  {
        set cmd [list "exec" $arcpgm $theflags $TheArcFile $fn ">$errf" "2>$errf"]
        set rc [catch {set trc [eval $cmd]} cc]
        if {$TkzG(Debug)} {
            set dbmsg "Tkz-0004:    tar extract-view for $temptarfile (rc $rc): \
              \n    command = <$cmd>\
              \n    response: <$cc>"
            DeBug $owner $dbmsg
          }
        }  else  {
        set cmd [list "exec" $arcpgm $theflags $temptarfile $fn ">$errf" "2>$errf"]
        set rc [catch {set trc [eval $cmd]} cc]
        if {$TkzG(Debug)} {
            set dbmsg "Tkz-0004:    tar extract-view for $temptarfile (rc $rc): \
              \n    command = <$cmd>\
              \n    response: <$cc>"
            DeBug $owner $dbmsg
          }
        }
      if {$fn != $sfn}  {
        if {[string range $fn 0 0] == "/"}  {
          set tlfn [string range $fn 1 end]
          }  else  {
          set tlfn $fn
          }
        if {$TkzG(Portable)}  {
          catch {file copy -force $tlfn $sfn}
          }  else  {
          catch {exec cp $tlfn $sfn}
          }
        set sloc [string first "/" $tlfn]
        if {$sloc != -1}  {
          set tlfn [string range $tlfn 0 $sloc]
          if {$TkzG(Portable)}  {
            catch {[file delete -force $tmpd/$tlfn]}
            }  else  {
            catch {exec rm -rf $tmpd/$tlfn}
            }
          }  else  {
          if {$TkzG(Portable)}  {
            catch {[file delete -force $tlfn]}
            }  else  {
            catch {[exec rm -f $tlfn]}
            }
          }
        }
      }

  if {$rc != 0}  {
    cd $where
    return $rc
    }
  incr ll2
  }
  cd $where
#-------------------

cd $where
if {$rc > 0}  {
  set rc 0
  }
return $rc
}

#--------------------------------------------------------------
#  ExtTar  --  Extract member(s) from a TAR
#
#--------------------------------------------------------------
proc ExtTar {owner dirname arcname whereto fname flist lstf errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global GotTar GotGtar MyPid Home ErrArgs ExtDirs OsName
global TkzG
set thisproc "ExtTar"

set statw ".$owner.top.vopt.stat"
set stat "Stat$owner"
global $stat
set $stat "          "
$statw configure -textvariable $stat -fg red
set tmp "sdirl$owner"
global $tmp
set flist3 [set $tmp]
set tmp "apn2$owner"
global $tmp
set apn2 [set $tmp]
set tmp "jpn2$owner"
global $tmp
set jpn2 [set $tmp]
set arcpgm "tar"
set rc 0
set trc 0

#  In case we already copied the file from a tape...
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" && [string first "n" $arcname] == 0 }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }

#  If this was a gzipped or compressed tar, then we already have an uncompressed
#  copy lying around, so use it...
set temptar "TmpTar$owner"
global $temptar
set temptarfile [set $temptar]
if {$temptarfile == ""}  {
  set thefile "$TheArcFile"
  }  else  {
  set thefile $temptarfile
  }
if {$TkzG(GotGtar2) && $TkzG(PreferGtar)}  {
  set arcpgm $TkzG(GtarName)
  }  else  {
  if {! $GotTar && $TkzG(GotGtar2)}  {
    set arcpgm $TkzG(GtarName)
    }  else  {
    set arcpgm "tar"
    }
  }

set usinggtar 0
if {$GotGtar && $TkzG(UseGtar)}  {
  if {$arcpgm != "tar" || $TkzG(TarIsGtar)}  {
    set usinggtar 1
    }
  }

if {$usinggtar}  {
  if {$jpn2}  {
    set theflags "-xvf"
    }  else  {
    if {$apn2}  {
      set theflags "-xvPf"
      }  else  {
      set theflags "-xvf"
      }
    }
  }  else  {
#  May have to do a switch here in future...
#  switch  $OsName  {
#    default        {
          if {$jpn2}  {
            set theflags "xvf"
            }  else  {
            if {$apn2}  {
              set theflags "xvPf"
              }  else  {
              set theflags "xvf"
              }
            }
#          }
#    }
  }

#  Pay no attention to fname, we may have a lotta files to extract...
#  gotta access the list of member names to extract.
#  For each file in list, just extract in the target dir.

set $stat "Extracting"
$statw configure -fg red
update idletasks
set where [pwd]
cd $whereto

if {$GotGtar && $TkzG(UseGtar)}  {
  #  This is the thing to do for Gnu tar...
  #  for others we may have to do 'em one at a time.
  #  (If we extract directory entries, we have to avoid confusing GNU tar, so
  #  we do directories in a separate pass.)
#  set rc [catch {exec tar -xvf $thefile -T $flist >$lstf 2>$errf} cc]
  set cmd [list "exec" $arcpgm $theflags $thefile "-T" $flist ">$lstf" "2>$errf"]
  set rc [catch {set trc [eval $cmd]} cc]
  if {$TkzG(Debug)} {
      set dbmsg "Tkz-0005:    GNU tar file extract for $thefile (rc $rc): \
        \n    command = <$cmd>\
        \n    response: <$cc>"
      DeBug $owner $dbmsg
    }

#------------
  set ll1 0
  set ll2 0
  catch {set ll1 [llength $flist3]}
  if {! $rc && $ll1 != 0}  {
    if [ catch {set fl [open $flist w]} ]  {
      return -1
      }
    while {$ll2 < $ll1}  {
      set fn [lindex $flist3 $ll2]
      puts $fl "$fn"
      incr ll2
      }
    catch {close $fl}
##    set rc [catch {exec tar -xvf $thefile -T $flist >>$lstf 2>>$errf} cc]
    set cmd [list "exec" $arcpgm $theflags $thefile "-T" $flist ">$lstf" "2>$errf"]
    set rc [catch {set trc [eval $cmd]} cc]
    if {$TkzG(Debug)} {
        set dbmsg "Tkz-0005:    GNU tar directory extract for $thefile (rc $rc): \
          \n    command = <$cmd>\
          \n    response: <$cc>"
        DeBug $owner $dbmsg
      }
    }

#------------

#----------------------------------
#  Archetypal error check...
#----------------------------------
#puts "ExtTar1 - rc = $rc"
  if {$rc != 0} {
    set ignerr 0
    if {$TkzG(IgnITG)}  {
      #  Non-portable...
      set dummy ""
      if {$TkzG(Portable)}  {
        if {[file size $errf] > 0}  {
          set ef ""
          catch {set ef [open $errf r]}     
          if {$ef != ""}  {
            while {[ gets $ef efline ] > -1}  {
              set dummy "$dummy$efline"
              }
            }
          catch {close $ef}
          }
        }  else  {
        set dummy [exec cat $errf]
        }
      if {[string first "trailing garbage" $dummy] != -1}  {
        set ignerr 1
        }
      }
    if {! $ignerr}  {
#  This stuff is now done in the common error check func.
#      incr TmpNo
#      set tno $TmpNo
#      if {! $TkzG(DseFlag)}  {
#        if {$TkzG(Portable)}  {
#          catch {file copy -force $lstf $Home/TkzLst$MyPid-$tno}
#          catch {file copy -force $errf $Home/TkzErr$MyPid-$tno}
#          }  else  {
#          catch {exec cp $lstf $Home/TkzLst$MyPid-$tno}
#          catch {exec cp $errf $Home/TkzErr$MyPid-$tno}
#          }
#        }
#      set ErrArgs [ list "$Home/TkzLst$MyPid-$tno" "$Home/TkzErr$MyPid-$tno" $lstf $errf]
#      $statw configure -bg black
#      set $stat "Done"
#      GErrMsgBox 91
#      return -1
      return $rc
      }
    }
#----------------------------------
  }  else  {
  #  The problem children (non-GNU)...
  #  If we find any other tars that accept a list in a file, we'll
  #  change this...
  catch {unset xlist}
  if [ catch {set fl [open $flist r]} ]  {
    return -1
    }
  while {[ gets $fl line ] > -1}  {
    lappend xlist [string trim $line]
    }
  catch {close $fl}
  
  set ll1 0
  set ll2 0
  catch {set ll1 [llength $xlist]}
  while {$ll2 < $ll1 && $rc == 0}  {
    set fn [lindex $xlist $ll2]
#    set rc [catch {exec tar -xvf $thefile $fn >>$lstf 2>>$errf} cc]
#    set cmd "exec tar -xvf $thefile $fn >>$lstf 2>>$errf"
#    set rc [catch {set rc [eval $cmd]} cc]
    set cmd [list "exec" $arcpgm $theflags $thefile $fn ">$lstf" "2>$errf"]
    set rc [catch {set trc [eval $cmd]} cc]
    if {$TkzG(Debug)} {
        set dbmsg "Tkz-0005:    tar file extract for $thefile (rc $rc): \
          \n    command = <$cmd>\
          \n    response: <$cc>"
        DeBug $owner $dbmsg
      }
#----------------------------------
#  Archetypal error check...
#----------------------------------
    if {$rc != 0} {
      set ignerr 0
      if {$TkzG(IgnITG)}  {
        #  Non-portable...
        set dummy ""
        if {$TkzG(Portable)}  {
          if {[file size $errf] > 0}  {
            set ef ""
            catch {set ef [open $errf r]}     
            if {$ef != ""}  {
              while {[ gets $ef efline ] > -1}  {
                set dummy "$dummy$efline"
                }
              }
            catch {close $ef}
            }
          }  else  {
          set dummy [exec cat $errf]
          }
        if {[string first "trailing garbage" $dummy] != -1}  {
          set ignerr 1
          }
        }
      if {! $ignerr}  {
#  This stuff is now done in the common error check func.
#        incr TmpNo
#        set tno $TmpNo
#        if {! $TkzG(DseFlag)}  {
#          if {$TkzG(Portable)}  {
#            catch {file copy -force $lstf $Home/TkzLst$MyPid-$tno}
#            catch {file copy -force $errf $Home/TkzErr$MyPid-$tno}
#            }  else  {
#            }
#          }
#        set ErrArgs [list "$Home/TkzLst$MyPid-$tno" "$Home/TkzErr$MyPid-$tno" $lstf $errf]
#        $statw configure -bg black
#        set $stat "Done"
#        GErrMsgBox 91
#        return -1
        return $rc
        }
      }
#----------------------------------
    incr ll2
    }
#------------
  set ll1 0
  set ll2 0
  catch {set ll1 [llength $flist3]}
  if {! $rc && $ll1 != 0}  {
    while {$ll2 < $ll1 && $rc == 0}  {
      set fn [lindex $flist3 $ll2]
#      set rc [catch {exec tar -xvf $thefile $fn >>$lstf 2>>$errf} cc]
      set cmd [list "exec" $arcpgm $theflags $thefile $fn ">$lstf" "2>$errf"]
      set rc [catch {set trc [eval $cmd]} cc]
      if {$TkzG(Debug)} {
          set dbmsg "Tkz-0005:    tar directory extract for $thefile (rc $rc): \
            \n    command = <$cmd>\
            \n    response: <$cc>"
          DeBug $owner $dbmsg
        }
#----------------------------------
#  Archetypal error check...
#----------------------------------
      if {$rc != 0} {
        set ignerr 0
        if {$TkzG(IgnITG)}  {
          #  Non-portable...
          set dummy ""
          if {$TkzG(Portable)}  {
            if {[file size $errf] > 0}  {
              set ef ""
              catch {set ef [open $errf r]}     
              if {$ef != ""}  {
                while {[ gets $ef efline ] > -1}  {
                  set dummy "$dummy$efline"
                  }
                }
              catch {close $ef}
              }
            }  else  {
            set dummy [exec cat $errf]
            }
          if {[string first "trailing garbage" $dummy] != -1}  {
            set ignerr 1
            }
          }
        if {! $ignerr}  {
#  This stuff is now done in the common error check func.
#          incr TmpNo
#          set tno $TmpNo
#          if {! $TkzG(DseFlag)}  {
#            if {$TkzG(Portable)}  {
#              catch {file copy -force $lstf $Home/TkzLst$MyPid-$tno}
#              catch {file copy -force $errf $Home/TkzErr$MyPid-$tno}
#              }  else  {
#              catch {exec cp $lstf $Home/TkzLst$MyPid-$tno}
#              catch {exec cp $errf $Home/TkzErr$MyPid-$tno}
#              }
#            }
#          set ErrArgs [list "$Home/TkzLst$MyPid-$tno" "$Home/TkzErr$MyPid-$tno" $lstf $errf]
#          $statw configure -bg black
#          set $stat "Done"
#          GErrMsgBox 91
#          return -1
          return $rc
          }
        }
#----------------------------------
      incr ll2
      }
    }
#------------
  }

$statw configure -fg black
set $stat "   Done   "
#  Now done in common error check func
#if {$TkzG(Portable)}  {
#  catch { [file delete -force $lstf $errf $flist] }
#  }  else  {
#  catch { [exec rm $lstf $errf $flist] }
#  }

cd $where
return $rc
}

#--------------------------------------------------------------
#  DelTar  --  Delete member(s) from a TAR
#     - this function is currently disabled, even for GNU tar
#
#--------------------------------------------------------------
proc DelTar {owner dirname arcname flist lstf errf} {
set thisproc "DelTar"
global TempDir TmpNo ErrArgs GotTar GotGtar
global TkzG

set tno $TmpNo
set tmp "creating$owner"
global $tmp
set creating [set $tmp]
#set tmp "apn$owner"
#global $tmp
#set apn [set $tmp]
#set tmp "recurs$owner"
#global $tmp
#set recurs [set $tmp]
set tmp "ArcFno$owner"
global $tmp
set type [set $tmp]


if {$TkzG(GotGtar2) && $TkzG(PreferGtar)}  {
  set arcpgm $TkzG(GtarName)
  }  else  {
  if {! $GotTar && $TkzG(GotGtar2)}  {
    set arcpgm $TkzG(GtarName)
    }  else  {
    set arcpgm "tar"
    }
  }
set TheArcFile $dirname/$arcname
#  If compressed tar, there's a temp file to use...
set temptar "TmpTar$owner"
global $temptar
set temptarfile [set $temptar]
if {$temptarfile == ""}  {
  set thefile "$TheArcFile"
  }  else  {
  set thefile $temptarfile
  }

catch {unset xlist}
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
#  Since tar delete is most likely to work from the end of the
#  archive, reverse the list to improve our chances...
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

#  NOTE:  gotta check syntax for non-GNU tars, if any support it...
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
#  set rc [catch {exec tar --delete -f $thefile $fn >$lstf 2>$errf} cc]
  set cmd "exec $arcpgm --delete -f $thefile $fn >$lstf 2>$errf"
#if {$TkzG(Debug)}  {
#  set dbmsg "Deleting... cmd: \n  $cmd"
#  DeBug $owner $dbmsg
#  }
  set rc [catch {set rc [eval $cmd]} cc]
#  Non-portable...
set junk ""
if {$TkzG(Portable)}  {
  if {[file size $errf] > 0}  {
    set ef ""
    catch {set ef [open $errf r]}     
    if {$ef != ""}  {
      while {[ gets $ef efline ] > -1}  {
        set junk "$junk$efline"
        }
      }
    catch {close $ef}
    }
  }  else  {
  set junk [exec cat $errf]
  }
if {$junk != ""}  {
  set rc 87
  }
  if {$rc != 0}  {
    break
    }
 incr ll2
 }


if {$rc != 0}  {
  set ErrArgs [list $lstf $errf $TheArcFile]
  GErrMsgBox 87
  return $rc
  }

#------------------
switch $type      {
    1           -
    5           -
    14          -
    18          {
        if {$temptarfile == ""}  {
          set temptarfile "$TempDir/TkzTtar$tno"
          set $temptar $temptarfile
          }
        if {$thefile == $TheArcFile}  {
          if {$TkzG(Portable)}  {
            set rc [ catch {file copy -force $thefile $temptarfile}]
            }  else  {
            set rc [ catch {exec cp $thefile $temptarfile}]
            }
          }
        if [ catch {set fl [open $flist w]} ]  {
          return -1
          }
        puts $fl "$temptarfile"
        catch {[close $fl]}
        #  Play a little fast and loose with the calling args here...
        switch $type      {
            1      {
               set rc [AddGzp $owner $owner $dirname $arcname $flist $lstf $errf]
               }
            5      {
               set rc [AddCmp $owner $owner $dirname $arcname $flist $lstf $errf]
               }
            14     -
            18     {
               set rc [AddBzip $owner $owner $dirname $arcname $flist $lstf $errf]
               }
            }

        return $rc
        }
    3          {
        }
    default    {
        return $rc
        }
    }
#------------------

return $rc
}

#--------------------------------------------------------------
#  AddTar  --  Add member(s) to a TAR
#
#    Options supported:
#        Absolute or relative pathnames  --  default: relative
#--------------------------------------------------------------
proc AddTar {parent owner dirname arcname flist lstf errf} {
set thisproc "AddTar"
global TempDir TmpNo ErrArgs OsName GotTar GotGtar
global TkzG

set tno $TmpNo
set tmp "creating$parent"
global $tmp
set creating [set $tmp]
set tmp "apn$owner"
global $tmp
set apn [set $tmp]
set tmp "rpn$owner"
global $tmp
set rpn [set $tmp]
set tmp "jpn$owner"
global $tmp
set jpn [set $tmp]
#set tmp "recurs$owner"
#global $tmp
#set recurs [set $tmp]
set tmp "ArcFno$parent"
global $tmp
set type [set $tmp]
set arcpgm "tar"

set TheArcFile $dirname/$arcname
#  If compressed and not new, there's a temp file to use...
set temptar "TmpTar$parent"
global $temptar
set temptarfile [set $temptar]
if {$temptarfile == ""}  {
  set thefile "$TheArcFile"
  }  else  {
  set thefile $temptarfile
#  Should not happen if creating...
  if {$creating}  {
    puts"$thisproc:      Found temp tar $temptarfile while creating. This *cannot* happen  --  how did it?"
    GErrMsgBox 99
    }
  }
set body "$owner.body"
set cdvar "CraDir$body"
global $cdvar
set where [set $cdvar]
set oldwhere [pwd]
if {$TkzG(GotGtar2) && $TkzG(PreferGtar)}  {
  set arcpgm $TkzG(GtarName)
  }  else  {
  if {! $GotTar && $TkzG(GotGtar2)}  {
    set arcpgm $TkzG(GtarName)
    }  else  {
    set arcpgm "tar"
    }
  }
if {$GotGtar && $TkzG(UseGtar)}  {
  if {$jpn}  {
    set theflags "-rf"
    }  else  {
    if {$apn}  {
      set theflags "-rPf"
      }  else  {
      set theflags "-rf"
      }
    }
  }  else  {
  #  We may have to switch on OS type if we find problems here...
  if {$jpn}  {
    set theflags "rf"
    }  else  {
    if {$apn}  {
      set theflags "rPf"
      }  else  {
      set theflags "rf"
      }
    }
  }


catch {unset xlist}
if {$creating}  {
  set created 0
  }  else  {
  set created 1
  }

if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

set flags ""
if {! $apn && ! $jpn && ! $rpn}  {
  cd "/"
  }

set flags ""
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  if {! $created}  {
    if {$GotGtar && $TkzG(UseGtar)}  {
      set theflags "-c[string range $theflags 2 end]"
      }  else  {
      set theflags "c[string range $theflags 1 end]"
      }
    }
  if {! $jpn}  {
    if {! $apn}  {
      if {$rpn}  {
        catch {cd $where}
        if {[string first $where $fn] == 0}  {
          set tfn [string range $fn [string length $where] end]
          if {[string range $tfn 0 0]  == "/"}  {
            set tfn [string range $tfn 1 end]
            }
          set cmd [list "exec" $arcpgm $theflags $thefile $tfn ">$lstf" "2>$errf"]
          set rc [catch {set trc [eval $cmd]} cc]
          }
          catch {cd $oldwhere}
        }  else  {
        set fn [string range $fn 1 end]
        set cmd [list "exec" $arcpgm $theflags $thefile $fn ">$lstf" "2>$errf"]
        set rc [catch {set trc [eval $cmd]} cc]
        }

      }  else  {
      set cmd [list "exec" $arcpgm $theflags $thefile $fn ">$lstf" "2>$errf"]
      set rc [catch {set trc [eval $cmd]} cc]
      }
    }  else  {
    #  Junking the pathname...absolute pathname is meaningless
    set l1 [string last "/" $fn]
    incr l1
    set fnn [string range $fn $l1 end]
    incr l1 -2
    set fnd [string range $fn 0 $l1]
    cd $fnd
    set cmd [list "exec" $arcpgm $theflags $thefile $fnn ">$lstf" "2>$errf"]
    set rc [catch {set trc [eval $cmd]} cc]
    }


  if {$rc != 0}  {
    break
    }
  if {! $created}  {
    if {$GotGtar && $TkzG(UseGtar)}  {
      set theflags "-r[string range $theflags 2 end]"
      }  else  {
      set theflags "r[string range $theflags 1 end]"
      }
    set created 1
    }
  incr ll2
  }

cd $where
if {$rc != 0}  {
  set ErrArgs [list $lstf $errf $TheArcFile]
  GErrMsgBox 88
  return $rc
  }

switch $type      {
    1           -
    5           -
    14          -
    18          {
        if {$temptarfile == ""}  {
          set temptarfile "$TempDir/TkzTtar$tno"
          if {$type == 1}  {
            set l1 [string length $arcname]
            incr l1 -3
            set TheRealArcName $arcname
            if {[string range $arcname $l1 end] == ".gz"}  {
              incr l1 -1
              set TheRealArcName [string range $arcname 0 $l1]
              }
            set temptarfile "$TempDir/$TheRealArcName"
            }
          set $temptar $temptarfile
          }
        if {$thefile == $TheArcFile}  {
          if {$TkzG(Portable)}  {
            set rc [ catch {file copy -force $thefile $temptarfile}]
            }  else  {
            set rc [ catch {exec cp -f $thefile $temptarfile}]
            }
          }
        if [ catch {set fl [open $flist w]} ]  {
          return -1
          }
        puts $fl "$temptarfile"
        catch {[close $fl]}
        switch $type      {
            1      {
               set rc [AddGzp $parent $owner $dirname $arcname $flist $lstf $errf]
               }
            5      {
               set rc [AddCmp $parent $owner $dirname $arcname $flist $lstf $errf]
               }
            14     -
            18     {
               set rc [AddBzip $parent $owner $dirname $arcname $flist $lstf $errf]
               }
            }

        return $rc
        }
    3          {
        }
    default    {
        return $rc
        }
    }


return $rc
}



#--------------------------------------------------------------
#  The Gzip Handling Routines --  Handle Gzip files
#    - with new structure, if unzipped file is a tar,
#      we'll just untar it
#
#--------------------------------------------------------------

#---------------------------------------------------------------
#  GetDirGzp  --  Get the Archive Directory list data for a GZIP
#
#---------------------------------------------------------------
proc GetDirGzp {owner dirname arcname dummyname errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg 
global TmpNo TempDir Home MyPid ErrArgs PgmName
global TwButBg TwButFg GotTar GotGtar
global TkzG

set thisproc "GetDirGzp"
set thiswin $owner
set WinName ".$owner"
set topf "$WinName.top"
set archdr "$WinName.hdr"
set arcbody "$WinName.body"
set fv "ArcFno$thiswin"
global $fv
set ArcFno [set $fv]
set WButBg $TwButBg($ArcFno)
set WButFg $TwButFg($ArcFno)
# incr TmpNo
set tno $TmpNo
set tmpf "$TempDir/TkzTmp$tno"
#set errf "$TempDir/TkzErr$tno"
set temptar "TmpTar$owner"
global $temptar
set temptarname "TkzTtar$tno"
set temptarfile "$TempDir/TkzTtar$tno"
set $temptar $temptarfile
set dirfile "$TempDir/TkzDir$tno"
set killist "Kill$owner"
global $killist
set $killist [lappend $killist $dirfile $tmpf]

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]

set tmp "spacey$thiswin"
global $tmp
set spacey [set $tmp]
set ap "ArcPgm$thiswin"
set lf "ListFlags$thiswin"
global $ap $lf
set arcpgm [set $ap]
set listflags [set $lf]

# set arcpgm "gunzip"
# set listflags "-l"

#--------------------
# Now read the list...
set where [pwd]
#  This is speshul...if we use the full pathname, that's what gunzip will
#  show in the listing, which we don't want.
cd $dirname
set TheArcFile $arcname
if { $dirname == "/dev" && [string first "n" $arcname] == 0 }  {
  cd $TempDir
  set tmp [string last "/" $tmparc]
  incr tmp
  set TheArcFile [string range $tmparc $tmp end]
  }
        set rc [catch {exec gzip -l -N $TheArcFile >$dirfile 2>$errf} tmp]
        if [ catch {set in [open $dirfile r]} ]  {
          #  The caller needs to take the appropriate action here...
          #  just tell him nfg...
	  return -1
	  }

        set dfltwidth 80
        set hdrwidth 0
        set hdrflds 4
        set llen 0
        set ll1 0
        set fl1 0
	set lineno 0
	set ignline 1
	set startdata 0
	# Heading for gzip...
	if {[info commands $archdr.h1] == ""}  {
          label $archdr.h1 -relief groove
          label $archdr.h2 -relief groove
          label $archdr.h3 -relief groove
          label $archdr.h4 -relief groove
          }
	# End gzip heading...
        while  { [ gets $in line ] > -1 } {
          incr lineno
          if {$lineno == 1}  {
            set startdata 1
            # etc
	    $archdr.h1 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text [ lindex $line 0 ]
	    $archdr.h2 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text " [ lindex $line 1 ]" 
	    $archdr.h3 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text " [ lindex $line 2 ]   " 
            $archdr.h4 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text [ lindex $line 3 ] 
#	    pack $archdr.h1 $archdr.h2 $archdr.h3 -side left  
#	    pack $archdr.h$hdrflds -anchor w -side left -fill x -expand yes
            }
          if {! $ignline}  {
#            set stripl [string length $dirname]
#            incr stripl
#            set line [string range $line $stripl end]
            $arcbody.alist insert end $line
            #  Hack to deal with spacey Win95 style filenames...
            #  If one is found in the archive, force selectmode single, so we
            #  might have a chance of getting viewing to work.
            set tmpfn [string trim [lrange $line 3 end]]  
            if {[string first " " $tmpfn] != -1}  {
              set spacey 1
              set tmp "spacey$thiswin"
              global $tmp
              set $tmp $spacey
              }
            #  Get the real stored filename, real or not...
            set RealFname [lrange $line 3 end]
            set temptarfile "$TempDir/$RealFname"
            set $temptar $temptarfile
            }
          if {$startdata}  {
            set ignline 0
            }
          }
        catch { close $in }
#  We've only just begun....
if {$lineno > 2}  {
  #  If this ever happens, something really strange is going on...
  #  just send back a formatted list & let the user figure it out.

  pack $archdr.h1 $archdr.h2 $archdr.h3 -side left  
  pack $archdr.h$hdrflds -anchor w -side left -fill x -expand yes
  if {[info commands $arcbody.scrollx] == ""}  {
    scrollbar $arcbody.scrollx -orient horizontal -command "$arcbody.alist xview"
    }
  $arcbody.alist configure -xscroll "$arcbody.scrollx set"
  pack $arcbody.scrollx -fill x -side bottom
  pack $arcbody.alist  -side left -fill both -expand yes
  cd $where
  return 1
  }

set rc 0
set ItsaTar 0
if {! $TkzG(NoProbe)}  {
#  OK, now to see if what's inside is a tar...
#  Gunzip says nasty things about a raw device here...  what to do, what to do?

  if {[file exists $temptarfile]}  {
    set ErrArgs [list $TheArcFile $RealFname]
    GErrMsgBox 18
    return -5
    }  else  {
    set $killist [lappend $killist $temptarfile]
    }
  if {$dirname != "/dev"}  {
    set RawDev 0
    set rc [ catch { exec gzip -c -d $TheArcFile >$temptarfile 2>$errf } cc]
    }  else  {
    #  This is unacceptably slow, but I dont't know what else to do...
    #  gunzip sometimes complains when reading directly from a device.
    set RawDev 1
    #  Non-portable...
    set rc [ catch { exec cat $TheArcFile | gzip -c -d >$temptarfile 2>$errf } cc]
    }


  set trc [catch {set dummy [exec file $temptarfile ]} cc]
  if { [string first "tar " $cc] != -1 }  {
    set ItsaTar 1
    }  else  {
    if {$TkzG(Desperation)}  {
      #  Kluge time...ask tar if it's a tar.
    if {$TkzG(GotGtar2) && $TkzG(PreferGtar)}  {
      set tarpgm $TkzG(GtarName)
      }  else  {
      if {! $GotTar && $TkzG(GotGtar2)}  {
        set tarpgm $TkzG(GtarName)
        }  else  {
        set tarpgm "tar"
        }
      }
      if {$GotGtar && $TkzG(UseGtar)}  {
        set trc [catch {set dummy [exec $tarpgm -tvf $temptarfile ]} cc]
        }  else  {
        set trc [catch {set dummy [exec $tarpgm tvf $temptarfile ]} cc]
        }
      if {$rc == 0 && $cc != "" && [string first "oesn't" $cc] < 0 && [string first "kipping to" $cc] < 0 && [string first "nly read" $cc] < 0 && [string first "unknown file" $cc] < 0 }  {
        set ItsaTar 1
        }
      }
    }
  #  End  tar probe
  }

  if {$ItsaTar}  {
    #  Call it a tar, and destroy all the widgets the tar func will try to build...
    if {$ArcFno == 4}  {
      set ArcFno 1
      }  else  {
      set ArcFno 5
      }

    set $fv $ArcFno
    set arctype [SetArcVars $owner $ArcFno]
    set arctitle "$PgmName:  $arctype:  $arcname"
    wm title $WinName $arctitle
    $arcbody.alist delete 0
    destroy $archdr.h1
    destroy $archdr.h2
    destroy $archdr.h3
    destroy $archdr.h4

    set trc [GetDirTar $owner $dirname $arcname $temptarfile $errf]
    if {$rc != 0} {
      return -4
      }
    return $trc
    }


pack $archdr.h1 $archdr.h2 $archdr.h3 -side left  
pack $archdr.h$hdrflds -anchor w -side left -fill x -expand yes

#  Now, what about error checking and window size configure...?
#  Well, only Zip needs some special checking at this point.

#  Window size - may need xscrollbar...
        if {$hdrwidth > $dfltwidth}  {
          set dfltwidth $hdrwidth
          }
#	if { $llen > $dfltwidth } {
#	  set ll1 $llen
#	  set llen $dfltwidth
          if {[info commands $arcbody.scrollx] == ""}  {
            scrollbar $arcbody.scrollx -orient horizontal -command "$arcbody.alist xview"
            }
          $arcbody.alist configure -xscroll "$arcbody.scrollx set"
#	  }

#        $arcbody.alist configure -width $llen
#        if { $ll1 > $llen } {
	  pack $arcbody.scrollx -fill x -side bottom
#	  } 
#  Do we want to do this here...?
        pack $arcbody.alist  -side left -fill both -expand yes

cd $where
#--------------------

if {$rc != 0}  {
  return -4
  }

return 1
}

#--------------------------------------------------------------
#  GetVGzp  --  Get a member to view from a GZIP
#
#--------------------------------------------------------------
proc GetVGzp {owner dirname arcname flist tmpd errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "GetVGzp"

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" && [string first "n" $arcname] == 0 }  {
  set tmp [string last "/" $tmparc]
  incr tmp
  set TheArcFile [string range $tmparc $tmp end]
  }

#  Extract to stdout as tmp file...
#set where [pwd]
#cd $TempDir
#set rc [ catch { exec gzip -c -d $TheArcFile >$tmpf 2>$errf } cc]
#cd $where
##set crc [catch {exec cp $TempDir/$fname $tmpf} cc]
##catch {exec rm $TempDir/$fname}
set errc 0
set rc 0
set where [pwd]
set xlist ""
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

cd $tmpd
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  set tmpf "$tmpd/$fn"
  set rc [ catch { exec gzip -c -d $TheArcFile >$tmpf 2>$errf } cc]
  if {$rc > 0}  {
    set rc 0
    }
  incr ll2
  }

cd $where
return $rc
}

#--------------------------------------------------------------
#  ExtGzp  --  Extract member(s) from a GZIP
#
#--------------------------------------------------------------
proc ExtGzp {owner dirname arcname whereto fname flist lstf errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "ExtGzp"

set statw ".$owner.top.vopt.stat"
set stat "Stat$owner"
global $stat
set $stat "          "
$statw configure -textvariable $stat -fg red
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" && [string first "n" $arcname] == 0 }  {
  set tmp [string last "/" $tmparc]
  incr tmp
  set TheArcFile [string range $tmparc $tmp end]
  }
set rc 0

#  Just go to the target dir and extract...
#  Pay no attention to flist, there's only one file to extract...
set where [pwd]
cd $whereto
set $stat "Extracting"
$statw configure -fg red
update idletasks
set rc [ catch { exec gzip -c -d $TheArcFile >$fname 2>$errf } cc]

$statw configure -fg black
set $stat "   Done   "
#  Note: gzip (at least as recently as 1.3.5, and as far back as 1.2.4)
#  does not write its error message to stderr if it can't create the
#  output file; it writes it to stdout.
#  This is brain-damaged. If it were able to write the file, it would be
#  writing the error message into the output file; but since it can't,
#  we can never see the error message. Bad, bad, bad. Bad.
#if {$TkzG(Portable)}  {
#  catch { [file delete -force $lstf $errf $flist] }
#  }  else  {
#  catch { [exec rm $lstf $errf $flist] }
#  }

cd $where
return $rc
}

#--------------------------------------------------------------
#  AddGzp  --  "Add" to a Gzipped File
#    For consistency of program structure, this is called the 
#    Add function. It really amounts to the Compress function.
#    It gets a filelist with one member.
#
#    Options supported:
#        None at present...  Later, speed-vs-compression, and
#        replace-on-compress
#--------------------------------------------------------------
proc AddGzp {parent owner dirname arcname flist lstf errf} {
global TkzG
set thisproc "AddGzp"
global ErrArgs

#set tmp "creating$parent"
#global $tmp
#set creating [set $tmp]
#set tmp "apn$owner"
#global $tmp
#set apn [set $tmp]
#set tmp "recurs$owner"
#global $tmp
#set recurs [set $tmp]
set tmp "ArcFno$parent"
global $tmp
set type [set $tmp]
set rc 0
set TheArcFile $dirname/$arcname
set xlist ""

if [ catch {set fl [open $flist r]} ]  {
#  puts "$thisproc:    open failure"
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

set flags ""
set flags "-c"
#if {$TkzG(CompOpt) != 0}  {
#  set flags [list "$flags" "-$TkzG(CompOpt)"]
#  }
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  set cmd "exec gzip $flags $fn >$TheArcFile 2>$errf"
if {$TkzG(CompOpt) != 0}  {
  set theargs [list $flags "-$TkzG(CompOpt)" $fn ">$TheArcFile" "2>$errf"]
  }  else  {
  set theargs [list $flags $fn ">$TheArcFile" "2>$errf"]
  }
set cmd "exec gzip $theargs"
  set rc [catch {set rc [eval $cmd]} cc]
  if {$rc != 0}  {
    break
    }
  incr ll2
  }
#  Temp...put up a message box here...
if {$rc != 0}  {
  set ErrArgs [list $lstf $errf $TheArcFile]
  GErrMsgBox 89
  return $rc
  }

return $rc
}



#--------------------------------------------------------------
#  The Compress Handling Routines --  Handle Compressed files
#    - with new structure, if uncompressed file is a tar,
#      we'll just untar it
#
#--------------------------------------------------------------

#--------------------------------------------------------------------------
#  GetDirCmp  --  Get the Archive Directory list data for a Compressed file
#
#--------------------------------------------------------------------------
proc GetDirCmp {owner dirname arcname dummyname errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg 
global TmpNo TempDir GotZcat GotCompress PgmName
global TwButBg TwButFg GotTar GotGtar
global TkzG

set thisproc "GetDirCmp"
set thiswin $owner
set WinName ".$owner"
set topf "$WinName.top"
set archdr "$WinName.hdr"
set arcbody "$WinName.body"
set fv "ArcFno$thiswin"
global $fv
set ArcFno [set $fv]
set WButBg $TwButBg($ArcFno)
set WButFg $TwButFg($ArcFno)
# incr TmpNo
set tno $TmpNo
set tmpf "$TempDir/TkzTmp$tno"
#set errf "$TempDir/TkzErr$tno"
set temptar "TmpTar$owner"
global $temptar
set temptarname "TkzTtar$tno"
set temptarfile "$TempDir/TkzTtar$tno"
set $temptar $temptarfile
set dirfile "$TempDir/TkzDir$tno"
set killist "Kill$owner"
global $killist
set $killist [lappend $killist $dirfile $tmpf $temptarfile]

set tmp "spacey$thiswin"
global $tmp
set spacey [set $tmp]
set ap "ArcPgm$thiswin"
set lf "ListFlags$thiswin"
global $ap $lf
set arcpgm [set $ap]
set listflags [set $lf]

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" && [string first "n" $arcname] == 0 }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }
set rc 0

# set arcpgm "zcat"
# set listflags "-l"
#if {$GotCompress}  {
#  set arcpgm "uncompress"
#  }  else  {
#  set arcpgm "zcat"
#  }

#--------------------
# Now read the list...
set where [pwd]
cd $dirname
if {$arcpgm == "gzip"}  {
  #  Uncompress is ugly - call a special func.
  set rc [GetDirGzp $owner $dirname $arcname $dummyname $errf]
  return $rc
  }
if {$arcpgm == "uncompress"}  {
  #  Uncompress is ugly - call a special func.
  set rc [GetDirCmp2 $owner $dirname $arcname $dummyname $errf]
  return $rc
  }
        set rc [catch {exec $arcpgm -l $TheArcFile >$dirfile 2>$errf} tmp]
        if [ catch {set in [open $dirfile r]} ]  {
          #  The caller needs to take the appropriate action here...
          #  just tell him nfg...
	  return -1
	  }

        set dfltwidth 80
        set hdrwidth 0
        set hdrflds 4
        set llen 0
        set ll1 0
        set fl1 0
	set lineno 0
	set ignline 1
	set startdata 0
	# Heading for gzip...
	if {[info commands $archdr.h1] == ""}  {
          label $archdr.h1 -relief groove
          label $archdr.h2 -relief groove
          label $archdr.h3 -relief groove
          label $archdr.h4 -relief groove
          }
	# End gzip heading...
        while  { [ gets $in line ] > -1 } {
          incr lineno
          if {$lineno == 1}  {
            set startdata 1
            # etc
	    $archdr.h1 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text [ lindex $line 0 ]
	    $archdr.h2 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text " [ lindex $line 1 ]" 
	    $archdr.h3 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text " [ lindex $line 2 ]   " 
            $archdr.h4 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text [ lindex $line 3 ] 
#	    pack $archdr.h1 $archdr.h2 $archdr.h3 -side left  
#	    pack $archdr.h$hdrflds -anchor w -side left -fill x -expand yes
            }
          if {! $ignline}  {

            set l1 [llength $line]
            incr l1 -1
            set sfn [lindex $line $l1]
            set l1 [string last $sfn $line]
            incr l1 -1
            set line [string range $line 0 $l1]
            set l1 [string last "/" $sfn]
	    if {$l1 != -1}  {
              incr l1
              set sfn [string range $sfn $l1 end]
	      }  else  {
	      }
             set line "$line$sfn"

#            set stripl [string length $dirname]
#            incr stripl
#            set line [string range $line $stripl end]


            $arcbody.alist insert end $line
            #  Hack to deal with spacey Win95 style filenames...
            #  If one is found in the archive, force selectmode single, so we
            #  might have a chance of getting viewing to work.
            #  - not sure if this placement is right...
            set tmpfn [string trim [lrange $line 3 end]]  
            if {[string first " " $tmpfn] != -1}  {
              set spacey 1
              set tmp "spacey$thiswin"
              global $tmp
              set $tmp $spacey
              }
            }
          if {$startdata}  {
            set ignline 0
            }
          }
        catch { close $in }

#  We've only just begun....
if {$lineno > 2}  {
  #  If this ever happens, we've stumbled upon serious strangeness...
  #  just send back a formatted list & let the user figure it out.

  pack $archdr.h1 $archdr.h2 $archdr.h3 -side left  
  pack $archdr.h$hdrflds -anchor w -side left -fill x -expand yes
  if {[info commands $arcbody.scrollx] == ""}  {
    scrollbar $arcbody.scrollx -orient horizontal -command "$arcbody.alist xview"
    }
  $arcbody.alist configure -xscroll "$arcbody.scrollx set"
  pack $arcbody.scrollx -fill x -side bottom
  pack $arcbody.alist  -side left -fill both -expand yes
  cd $where
  return 1
  }

set rc 0
set ItsaTar 0
if {! $TkzG(NoProbe)}  {
#  OK, now to see if what's inside is a tar...

  if {$dirname != "/dev"}  {
    set RawDev 0
    set rc [ catch { exec $arcpgm -c $TheArcFile >$temptarfile 2>$errf } cc]
    }  else  {
    #  This is unacceptably slow, but I dont't know what else to do...
    set RawDev 1
    #  Non-portable...
    set rc [ catch { exec cat $TheArcFile | $arcpgm -c >$temptarfile 2>$errf } cc]
    }

  set trc [catch {set dummy [exec file $temptarfile ]} cc]
  if { [string first "tar " $cc] != -1 }  {
    set ItsaTar 1
    }  else  {
    if {$TkzG(Desperation)}  {
      #  Kluge time...ask tar if it's a tar.
      if {$TkzG(GotGtar2) && $TkzG(PreferGtar)}  {
        set tarpgm $TkzG(GtarName)
        }  else  {
        if {! $GotTar && $TkzG(GotGtar2)}  {
          set tarpgm $TkzG(GtarName)
          }  else  {
          set tarpgm "tar"
          }
        }
      if {$GotGtar && $TkzG(UseGtar)}  {
        set trc [catch {set dummy [exec $tarpgm -tvf $temptarfile ]} cc]
        }  else  {
        set trc [catch {set dummy [exec $tarpgm tvf $temptarfile ]} cc]
        }
      if {$rc == 0 && $cc != "" && [string first "oesn't" $cc] < 0 && [string first "kipping to" $cc] < 0 && [string first "nly read" $cc] < 0 && [string first "unknown file" $cc] < 0 }  {
        set ItsaTar 1
        }
      }
    }
  #  End  tar probe
  }

  if {$ItsaTar}  {
    #  Call it a tar, and destroy all the widgets the tar func will try to build...
    set ArcFno 5
    set $fv $ArcFno
    set arctype [SetArcVars $owner $ArcFno]
    set arctitle "$PgmName:  $arctype:  $arcname"
    wm title $WinName $arctitle
    $arcbody.alist delete 0
    destroy $archdr.h1
    destroy $archdr.h2
    destroy $archdr.h3
    destroy $archdr.h4

    set trc [GetDirTar $owner $dirname $arcname $temptarfile $errf]
    if {$rc != 0} {
      return -4
      }
    return $trc
    }


pack $archdr.h1 $archdr.h2 $archdr.h3 -side left  
pack $archdr.h$hdrflds -anchor w -side left -fill x -expand yes

#  Now, what about error checking and window size configure...?
#  Well, only Zip needs some special checking at this point.

#  Window size - may need xscrollbar...
        if {$hdrwidth > $dfltwidth}  {
          set dfltwidth $hdrwidth
          }
#	if { $llen > $dfltwidth } {
#	  set ll1 $llen
#	  set llen $dfltwidth
          if {[info commands $arcbody.scrollx] == ""}  {
            scrollbar $arcbody.scrollx -orient horizontal -command "$arcbody.alist xview"
            }
          $arcbody.alist configure -xscroll "$arcbody.scrollx set"
#	  }

#        $arcbody.alist configure -width $llen
#        if { $ll1 > $llen } {
	  pack $arcbody.scrollx -fill x -side bottom
#	  } 
#  Do we want to do this here...?
        pack $arcbody.alist  -side left -fill both -expand yes

cd $where
#--------------------

if {$rc != 0}  {
  return -4
  }

return 1
}

#--------------------------------------------------------------------------
#  GetDirCmp2  --  called from GetDirCmp if we can't use zcat...
#
#--------------------------------------------------------------------------
proc GetDirCmp2 {owner dirname arcname dummyname errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg 
global TmpNo TempDir GotZcat GotCompress PgmName
global TwButBg TwButFg GotTar GotGtar
global TkzG

set thisproc "GetDirCmp2"
set thiswin $owner
set WinName ".$owner"
set topf "$WinName.top"
set archdr "$WinName.hdr"
set arcbody "$WinName.body"
set fv "ArcFno$thiswin"
global $fv
set ArcFno [set $fv]
set WButBg $TwButBg($ArcFno)
set WButFg $TwButFg($ArcFno)
# incr TmpNo
set tno $TmpNo
set tmpf "$TempDir/TkzTmp$tno"
#set errf "$TempDir/TkzErr$tno"
set temptar "TmpTar$owner"
global $temptar
set temptarname "TkzTtar$tno"
set temptarfile "$TempDir/TkzTtar$tno"
set $temptar $temptarfile
set dirfile "$TempDir/TkzDir$tno"

set tmp "spacey$thiswin"
global $tmp
set spacey [set $tmp]
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" && [string first "n" $arcname] == 0 }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }

set ap "ArcPgm$thiswin"
set lf "ListFlags$thiswin"
global $ap $lf
set arcpgm [set $ap]
set listflags [set $lf]

set arcpgm "uncompress"
# set listflags "-l"

#--------------------
# Now pretend to read the list...
set where [pwd]
# cd $dirname
  #  This is really crappy...uncompress doesn't tell you anything, so
  #  make something up.
set hdrflds 2
set tmp [string length $arcname]
incr tmp -2
if { [string range $arcname $tmp end] == ".z" || [string range $arcname $tmp end] == ".Z" }  {
  incr tmp -1
  set line [string range $arcname 0 $tmp]
  }  else  {
  set line $arcname
  }


if {[info commands $archdr.h1] == ""}  {
  label $archdr.h1 -relief groove
  }
$archdr.h1 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "              Name              "
  #  In fact, we should be sarcastic about it...
if {[info commands $archdr.h2] == ""}  {
  label $archdr.h2 -relief groove
  }
$archdr.h2 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg \
  -text "(You really should install Gnu tar-zcat-gzip)"
$arcbody.alist insert end $line
#  Hack to deal with spacey Win95 style filenames...
#  If one is found in the archive, force selectmode single, so we
#  might have a chance of getting viewing to work.
set tmpfn [string trim [lrange $line 0 end]]  
if {[string first " " $tmpfn] != -1}  {
  set spacey 1
  set tmp "spacey$thiswin"
  global $tmp
  set $tmp $spacey
  }


set rc 0
set ItsaTar 0
if {! $TkzG(NoProbe)}  {
#  We've only just begun....
#  OK, now to see if what's inside is a tar...
#  Treat this the same way we do for gunzip...
  if {$dirname != "/dev"}  {
    set RawDev 0
    set rc [ catch { exec $arcpgm -c $TheArcFile >$temptarfile 2>$errf } cc]
    }  else  {
    #  This is unacceptably slow, but I dont't know what else to do...
    set RawDev 1
    #  Non-portable...
    set rc [ catch { exec cat $TheArcFile | $arcpgm -c >$temptarfile 2>$errf } cc]
    }

  set trc [catch {set dummy [exec file $temptarfile ]} cc]
  if { [string first "tar " $cc] != -1 }  {
    set ItsaTar 1
    }  else  {
    if {$TkzG(Desperation)}  {
      #  Kluge time...ask tar if it's a tar.
      if {$TkzG(GotGtar2) && $TkzG(PreferGtar)}  {
        set tarpgm $TkzG(GtarName)
        }  else  {
        if {! $GotTar && $TkzG(GotGtar2)}  {
          set tarpgm $TkzG(GtarName)
          }  else  {
          set tarpgm "tar"
          }
        }
      if {$GotGtar && $TkzG(UseGtar)}  {
        set trc [catch {set dummy [exec $tarpgm -tvf $temptarfile ]} cc]
        }  else  {
        set trc [catch {set dummy [exec $tarpgm tvf $temptarfile ]} cc]
        }
      if {$rc == 0 && $cc != "" && [string first "oesn't" $cc] < 0 && [string first "kipping to" $cc] < 0 && [string first "nly read" $cc] < 0 && [string first "unknown file" $cc] < 0 }  {
        set ItsaTar 1
        }
      }
    }
  #  End  tar probe
  }

  if {$ItsaTar}  {
    #  Call it a tar, and destroy all the widgets the tar func will try to build...
    set ArcFno 5
    set $fv $ArcFno
    set arctype [SetArcVars $owner $ArcFno]
    set arctitle "$PgmName:  $arctype:  $arcname"
    wm title $WinName $arctitle
    $arcbody.alist delete 0
    destroy $archdr.h1
    destroy $archdr.h$hdrflds

    set trc [GetDirTar $owner $dirname $arcname $temptarfile $errf]
    if {$rc != 0} {
      return -4
      }
    return $trc
    }


pack $archdr.h1 -side left  
pack $archdr.h$hdrflds -anchor w -side left -fill x -expand yes

#  Now, what about error checking and window size configure...?
#  Well, only Zip needs some special checking at this point.

#  Window size - may need xscrollbar...
#        if {$hdrwidth > $dfltwidth}  {
#          set dfltwidth $hdrwidth
#          }
#	if { $llen > $dfltwidth } {
#	  set ll1 $llen
#	  set llen $dfltwidth
          if {[info commands $arcbody.scrollx] == ""}  {
            scrollbar $arcbody.scrollx -orient horizontal -command "$arcbody.alist xview"
            }
          $arcbody.alist configure -xscroll "$arcbody.scrollx set"
#	  }

#        $arcbody.alist configure -width $llen
#        if { $ll1 > $llen } {
	  pack $arcbody.scrollx -fill x -side bottom
#	  } 
#  Do we want to do this here...?
        pack $arcbody.alist  -side left -fill both -expand yes

# cd $where
#--------------------

if {$rc != 0}  {
  return -4
  }

return 1
}

#--------------------------------------------------------------
#  GetVCmp  --  Get a member to view from a Compressed file
#
#--------------------------------------------------------------
proc GetVCmp {owner dirname arcname flist tmpd errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "GetVCmp"

set ap "ArcPgm$owner"
global $ap
set arcpgm [set $ap]
set vf "ViewFlags$owner"
global $vf
set flags [set $vf]
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" && [string first "n" $arcname] == 0 }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }

#  Extract to stdout as tmp file...
#set where [pwd]
#cd $TempDir
#set rc [ catch { exec zcat -c $TheArcFile >$tmpf 2>$errf } cc]
#cd $where
##set crc [catch {exec cp $TempDir/$fname $tmpf} cc]
##catch [exec rm $TempDir/$fname]
#if {$rc > 0}  {
#  set rc 0
#  }
set errc 0
set rc 0
set where [pwd]
set xlist ""
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

cd $tmpd
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  set l1 [string last "/" $fn]
    if {$l1 != -1}  {
      incr l1
      set sfn [string range $fn $l1 end]
      }  else  {
      set sfn $fn
      }
#  set tmpf "$tmpd$fn"

#  set rc [ catch { exec $arcpgm -c $TheArcFile >$sfn 2>$errf } cc]
set cmd [list "exec" "$arcpgm"]
set i1 [llength $flags]
set i2 0
while {$i2 < $i1}  {
  lappend cmd [lindex $flags $i2]
  incr i2
  }
lappend cmd "$TheArcFile" ">$sfn" "2>$errf"
  set rc [catch {set rc [eval $cmd]} cc]
  if {$rc > 0}  {
    set rc 0
    }
  incr ll2
  }

cd $where
return $rc
}

#--------------------------------------------------------------
#  ExtCmp  --  Extract member(s) from a Compressed file
#
#--------------------------------------------------------------
proc ExtCmp {owner dirname arcname whereto fname flist lstf errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "ExtCmp"

set statw ".$owner.top.vopt.stat"
set stat "Stat$owner"
global $stat
set $stat "          "
$statw configure -textvariable $stat -fg red

set ap "ArcPgm$owner"
global $ap
set arcpgm [set $ap]
set vf "ViewFlags$owner"
global $vf
set flags [set $vf]

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" && [string first "n" $arcname] == 0 }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }

#  Just go to the target dir and extract...
#  Pay no attention to flist, there's only one file to extract...
set where [pwd]
cd $whereto
set $stat "Extracting"
$statw configure -fg red
update idletasks
#set tmp [string last "/" $fname]
#incr tmp
#set fn [string range $fname $tmp end]
#set rc [ catch { exec $arcpgm -c $TheArcFile >$fname 2>$errf } cc]
#puts "flags = $flags  fname = $fname  flist = $flist"
set theargs [list $flags "$TheArcFile" ">$fname" "2>$errf"]
set cmd "exec $arcpgm $theargs"
#puts "cmd = $cmd"
set rc [catch {set rc [eval $cmd]} cc]

$statw configure -fg black
set $stat "   Done   "
#  Now done in common error check func
#if {$TkzG(Portable)}  {
#  catch { [file delete -force $lstf $errf $flist] }
#  }  else  {
#  catch { [exec rm $lstf $errf $flist] }
#  }

cd $where
return $rc
}

#--------------------------------------------------------------
#  AddCmp  --  "Add" to a Compressed File
#    Called Add for consistency, it's really just Compress.
#    It gets a filelist with one member.
#
#    Options supported:
#        None at present...  
#--------------------------------------------------------------
proc AddCmp {parent owner dirname arcname flist lstf errf} {
global TkzG
set thisproc "AddCmp"
global ErrArgs

#set tmp "creating$parent"
#global $tmp
#set creating [set $tmp]
#set tmp "apn$owner"
#global $tmp
#set apn [set $tmp]
#set tmp "recurs$owner"
#global $tmp
#set recurs [set $tmp]
set tmp "ArcFno$parent"
global $tmp
set type [set $tmp]
set rc 0
set TheArcFile $dirname/$arcname
set xlist ""

set where [pwd]
if [ catch {set fl [open $flist r]} ]  {
  puts "$thisproc:    open failure"
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

set flags ""
set flags2 ""
if {$TkzG(CompOpt) != 0}  {
#  set flags "-c -b"
#  switch $TkzG(CompOpt)    {
#      1        {
#          set flags "$flags 10"
#          }
#      6        {
#          set flags "$flags 13"
#          }
#      9        {
#          set flags "$flags 16"
#          }
#      }
  set flags "-c"
  switch $TkzG(CompOpt)    {
      1        {
          set flags2 "-b 10"
          }
      6        {
          set flags2 "-b 13"
          }
      9        {
          set flags2 "-b 16"
          }
      }
  }  else  {
  set flags "-c"
  }

set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  set l1 [string last "/" $fn]
  if {$l1 != -1}  {
      incr l1
      set sfn [string range $fn $l1 end]
      incr l1 -2
      set sdn [string range $fn 0 $l1]
      }  else  {
      set sfn $fn
      set sdn ""
      }

  if {$sdn != ""}  {
    cd $sdn
    }
  if {$TkzG(CompOpt) != 0}  {
    set theargs [list $flags]
    foreach token $flags2  {
      lappend theargs $token
      }
    lappend theargs "<$sfn" ">$TheArcFile" "2>$errf"
    }  else  {
    set theargs [list $flags "<$sfn" ">$TheArcFile" "2>$errf"]
    }
  set cmd "exec compress $theargs"
  set rc [catch {set rc [eval $cmd]} cc]
  #  Hack for brain-damaged compress pgms...
  #  Non-portable...
  set junk ""
  if {$TkzG(Portable)}  {
    if {[file size $errf] > 0}  {
      set ef ""
      catch {set ef [open $errf r]}     
      if {$ef != ""}  {
        while {[ gets $ef efline ] > -1}  {
          set junk "$junk$efline"
          }
        }
      catch {close $ef}
      }
    }  else  {
    set junk [exec cat $errf]
    }
  if {$junk != ""}  {
    set rc 89
    }
  if {$rc != 0}  {
    break
    }
  incr ll2
  }

cd $where
if {$rc != 0}  {
  set ErrArgs [list $lstf $errf $TheArcFile]
  GErrMsgBox 89
  return $rc
  }

return $rc
}



#--------------------------------------------------------------
#  The Bzip Handling Routines --  Handle Bzipped files
#    - this program works just like the classic compress,
#      it's not particularly informative (no feature bloat here!)
#
#--------------------------------------------------------------

#--------------------------------------------------------------------------
#  GetDirBzip  --  Get the Archive Directory list data for a Bzip file
#
#--------------------------------------------------------------------------
proc GetDirBzip {owner dirname arcname dummyname errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg 
global TmpNo TempDir GotBzip PgmName
global TwButBg TwButFg GotTar GotGtar
global TkzG

set thisproc "GetDirBzip"
set thiswin $owner
set WinName ".$owner"
set topf "$WinName.top"
set archdr "$WinName.hdr"
set arcbody "$WinName.body"
set fv "ArcFno$thiswin"
global $fv
set ArcFno [set $fv]
set WButBg $TwButBg($ArcFno)
set WButFg $TwButFg($ArcFno)
# incr TmpNo
set tno $TmpNo
set tmpf "$TempDir/TkzTmp$tno"
#set errf "$TempDir/TkzErr$tno"
set temptar "TmpTar$owner"
global $temptar
set temptarname "TkzTtar$tno"
set temptarfile "$TempDir/TkzTtar$tno"
set $temptar $temptarfile
set dirfile "$TempDir/TkzDir$tno"
set killist "Kill$owner"
global $killist
set $killist [lappend $killist $dirfile $tmpf $temptarfile]

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" && [string first "n" $arcname] == 0 }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }

set ap "ArcPgm$thiswin"
set ap2 "ArcPgm2$thiswin"
set lf "ListFlags$thiswin"
global $ap $ap2 $lf
set arcpgm [set $ap]
set arcpgm2 [set $ap2]
set listflags [set $lf]

#set arcpgm "bunzip"
#set arcpgm2 "bzip"
set bzext ".bz"
if {$ArcFno == 17}  {
#  Fixed SetArcVars to do this properly...
#  set arcpgm "bunzip2"
#  set arcpgm2 "bzip2"
#  set $ap $arcpgm
#  set $ap2 $arcpgm2
  set bzext ".bz2"
  }
set tempbz "TmpBz$owner"
global $tempbz
set tempbzfile "$TempDir/Tbz$tno$bzext"
set $tempbz $tempbzfile

# set listflags "-l"

#--------------------
# Now pretend to read the list...
set where [pwd]
# cd $dirname
  #  This is really crappy...bzip doesn't tell you any more than uncompress, so
  #  make something up.
set hdrflds 2
set tmp [string length $arcname]
  if {$ArcFno == 17}  {
  incr tmp -4
  }  else  {
  incr tmp -3
  }
if { [string range $arcname $tmp end] == $bzext}  {
  incr tmp -1
  set line [string range $arcname 0 $tmp]
  }  else  {
  set line $arcname
  }

if {[info commands $archdr.h1] == ""}  {
  label $archdr.h1 -relief groove
  }
$archdr.h1 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "              Name              "
  #  In fact, we should be sarcastic about it...
if {[info commands $archdr.h2] == ""}  {
  label $archdr.h2 -relief groove
  }
$archdr.h2 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg \
  -text "(This space intentionally left)"
$arcbody.alist insert end $line

set rc 0
set ItsaTar 0
if {! $TkzG(NoProbe)}  {
#  We've only just begun....
#  OK, now to see if what's inside is a tar...
#  Treat this the same way we do for gunzip, sort of...
#  Bzip probably won't even read from a device...but the name changing
#  gyrations below should take care of that.
  #  Bzip is really anal, it insists that the filename end in ".bz"...
  #  So if it doesn't, make it so.
  set tmp [string length $arcname]
  incr tmp -3
  set tmp2 [string last $bzext $arcname]
  if {$tmp != $tmp2}  {
    if {$TkzG(Portable)}  {
      set rc [ catch { file copy -force $TheArcFile $tempbzfile } cc ]
      }  else  {
      set rc [ catch { exec cp $TheArcFile $tempbzfile } cc ]
      }
    set rc [ catch { exec $arcpgm -c -d $tempbzfile >$temptarfile 2>$errf } cc]
# puts "$thisproc:  What's wrong with $TheArcFile - $tempbzfile - $cc"
    }  else  {
    set $tempbz ""
    set rc [ catch { exec $arcpgm -c -d $TheArcFile >$temptarfile 2>$errf } cc]
    }
  #  In case we misidentified this as a bzip, check for the error now, not later.
  #  This pgm doesn't set an error code or anything - gotta read the stderr file...
  #  Non-portable...
  set cc ""
  if {$TkzG(Portable)}  {
    if {[file size $errf] > 0}  {
      set ef ""
      catch {set ef [open $errf r]}     
      if {$ef != ""}  {
        while {[ gets $ef efline ] > -1}  {
          set cc "$cc$efline"
          }
        }
      catch {close $ef}
      }
    }  else  {
    set erc [ catch { exec cat $errf } cc]
    }
  if { [string first "not a BZIP" $cc] != -1 || [string first "not a bzip2" $cc] != -1 || [string first "skipping" $cc] != -1}  {
    return -1
    }

  set trc [catch {set dummy [exec file $temptarfile ]} cc]
  if { [string first "tar " $cc] != -1 }  {
    set ItsaTar 1
    }  else  {
    if {$TkzG(Desperation)}  {
      #  Kluge time...ask tar if it's a tar.
      if {$TkzG(GotGtar2) && $TkzG(PreferGtar)}  {
        set tarpgm $TkzG(GtarName)
        }  else  {
        if {! $GotTar && $TkzG(GotGtar2)}  {
          set tarpgm $TkzG(GtarName)
          }  else  {
          set tarpgm "tar"
          }
        }
      if {$GotGtar && $TkzG(UseGtar)}  {
        set trc [catch {set dummy [exec $tarpgm -tvf $temptarfile ]} cc]
        }  else  {
        set trc [catch {set dummy [exec $tarpgm tvf $temptarfile ]} cc]
        }
      if {$rc == 0 && $cc != "" && [string first "oesn't" $cc] < 0 && [string first "kipping to" $cc] < 0 && [string first "nly read" $cc] < 0 && [string first "unknown file" $cc] < 0 }  {
        set ItsaTar 1
        }
      }
    }
  #  End  tar probe
  }

  if {$ItsaTar}  {
    #  Call it a tar, and destroy all the widgets the tar func will try to build...

    if {$ArcFno == 17}  {
      set ArcFno 18
      }  else  {
      set ArcFno 14
      }
    set $fv $ArcFno
    set arctype [SetArcVars $owner $ArcFno]
    set arctitle "$PgmName:  $arctype:  $arcname"
    wm title $WinName $arctitle
    $arcbody.alist delete 0
    destroy $archdr.h1
    destroy $archdr.h$hdrflds

    set trc [GetDirTar $owner $dirname $arcname $temptarfile $errf]
    if {$rc != 0} {
      return -4
      }
    return $trc
    }


pack $archdr.h1 -side left  
pack $archdr.h$hdrflds -anchor w -side left -fill x -expand yes

#  Now, what about error checking and window size configure...?
#  Well, only Zip needs some special checking at this point.

#  Window size - may need xscrollbar...
#        if {$hdrwidth > $dfltwidth}  {
#          set dfltwidth $hdrwidth
#          }
#	if { $llen > $dfltwidth } {
#	  set ll1 $llen
#	  set llen $dfltwidth
          if {[info commands $arcbody.scrollx] == ""}  {
            scrollbar $arcbody.scrollx -orient horizontal -command "$arcbody.alist xview"
            }
          $arcbody.alist configure -xscroll "$arcbody.scrollx set"
#	  }

#        $arcbody.alist configure -width $llen
#        if { $ll1 > $llen } {
	  pack $arcbody.scrollx -fill x -side bottom
#	  } 
#  Do we want to do this here...?
        pack $arcbody.alist  -side left -fill both -expand yes

# cd $where
#--------------------

if {$rc != 0}  {
  return -4
  }

return 1
}

#--------------------------------------------------------------
#  GetVBzip  --  Get a member to view from a Bzipped file
#
#--------------------------------------------------------------
proc GetVBzip {owner dirname arcname flist tmpd errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "GetVBzip"

set thiswin $owner
set tempbz "TmpBz$owner"
global $tempbz
set tempbzfile [set $tempbz]
#  May be bunzip, may be bunzip2...
set ap "ArcPgm$owner"
global $ap
set arcpgm [set $ap]
set fv "ArcFno$thiswin"
global $fv
set ArcFno [set $fv]
set bzext ".bz"
if {$ArcFno == 17}  {
  set bzext ".bz2"
  }

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" && [string first "n" $arcname] == 0 }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }

#  Extract to stdout as tmp file...
set tmp [string length $arcname]
incr tmp -3
set tmp2 [string last ".bz" $arcname]
if {$tmp != $tmp2}  {
  set TheFile $tempbzfile
  }  else  {
  set TheFile $TheArcFile
  }

#set where [pwd]
#cd $TempDir
#set rc [ catch { exec bunzip -c $TheFile >$tmpf 2>$errf } cc]
#cd $where
##set crc [catch {exec cp $TempDir/$fname $tmpf} cc]
##catch [exec rm $TempDir/$fname]
#if {$rc > 0}  {
#  set rc 0
#  }
set errc 0
set rc 0
set where [pwd]
set xlist ""
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

cd $tmpd
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  set tmpf "$tmpd/$fn"
  set rc [ catch { exec $arcpgm -c -d $TheFile >$tmpf 2>$errf } cc]
  if {$rc > 0}  {
    set rc 0
    }
  incr ll2
  }

cd $where

return $rc
}

#--------------------------------------------------------------
#  ExtBzip  --  Extract member(s) from a Bzipped file
#
#--------------------------------------------------------------
proc ExtBzip {owner dirname arcname whereto fname flist lstf errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "ExtBzip"

set tempbz "TmpBz$owner"
global $tempbz
set tempbzfile [set $tempbz]
set statw ".$owner.top.vopt.stat"
set stat "Stat$owner"
global $stat
set $stat "          "
$statw configure -textvariable $stat -fg red
#  May be bunzip, may be bunzip2...
set ap "ArcPgm$owner"
global $ap
set arcpgm [set $ap]
set fv "ArcFno$owner"
global $fv
set ArcFno [set $fv]
set bzext ".bz"
if {$ArcFno == 17}  {
  set bzext ".bz2"
  }

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" && [string first "n" $arcname] == 0 }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }

#  Just go to the target dir and extract...
#  Pay no attention to flist, there's only one file to extract...
set where [pwd]
cd $whereto
set $stat "Extracting"
$statw configure -fg red
update idletasks
#set tmp [string last "/" $fname]
#incr tmp
#set fn [string range $fname $tmp end]
set tmp [string length $arcname]
incr tmp -3
set tmp2 [string last $bzext $arcname]
if {$tmp != $tmp2}  {
  set TheFile $tempbzfile
  }  else  {
  set TheFile $TheArcFile
  }
set rc [ catch { exec $arcpgm -c -d $TheFile >$fname 2>$errf } cc]
#puts "ExtBzip:  rc = $rc  cc = $cc"

$statw configure -fg black
set $stat "   Done   "
#  Now done in common error check func
#if {$TkzG(Portable)}  {
#  catch { [file delete -force $lstf $errf $flist] }
#  }  else  {
#  catch { [exec rm $lstf $errf $flist] }
#  }

cd $where
return $rc
}

#--------------------------------------------------------------
#  AddBzip  --  "Add" to a BZIP File
#    Called Add function for consistency, it's really just Compress.
#    It gets a filelist with one member.
#
#    Options supported:
#        None at present...  
#--------------------------------------------------------------
proc AddBzip {parent owner dirname arcname flist lstf errf} {
global TkzG
set thisproc "AddBzip"
global ErrARgs

#set tmp "creating$parent"
#global $tmp
#set creating [set $tmp]
#set tmp "apn$owner"
#global $tmp
#set apn [set $tmp]
#set tmp "recurs$owner"
#global $tmp
#set recurs [set $tmp]
set tmp "ArcFno$parent"
global $tmp
set type [set $tmp]
set rc 0
set TheArcFile $dirname/$arcname
set xlist ""

#  May be bunzip, may be bunzip2...
set ap2 "ArcPgm2$parent"
global $ap2
set arcpgm2 [set $ap2]
set fv "ArcFno$parent"
global $fv
set ArcFno [set $fv]
set bzext ".bz"
if {$ArcFno == 17}  {
  set bzext ".bz2"
  }

if [ catch {set fl [open $flist r]} ]  {
#  puts "$thisproc:    open failure"
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

set flags ""
set flags "-c"
#  Set the compression blocksize (1-9).... Note - this
#  value will be stored in the 4th byte of the magic string.
#if {$TkzG(CompOpt) != 0}  {
#  set flags "$flags -$TkzG(CompOpt)"
#  }
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
#    set cmd "exec $arcpgm2 $flags $fn >$TheArcFile 2>$errf"
    if {$TkzG(CompOpt) != 0}  {
      set theargs [list $flags "-$TkzG(CompOpt)" $fn ">$TheArcFile" "2>$errf"]
      }  else  {
      set theargs [list $flags $fn ">$TheArcFile" "2>$errf"]
      }
    set cmd "exec $arcpgm2 $theargs"
    set rc [catch {set rc [eval $cmd]} cc]
  if {$rc != 0}  {
    break
    }
  incr ll2
  }

if {$rc != 0}  {
  set ErrArgs [list $lstf $errf $TheArcFile]
  GErrMsgBox 89
  return $rc
  }

return $rc
}



#-------------------------------------------------------------------
#  The LHarc Handling Routines --  Handle lha/lzh archives (type 15)
#    - 
#
#-------------------------------------------------------------------

#--------------------------------------------------------------------------
#  GetDirLha  --  Get the Archive Directory list data for an LHa archive
#
#--------------------------------------------------------------------------
proc GetDirLha {owner dirname arcname dummyname errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg 
global TmpNo TempDir GotBzip
global TwButBg TwButFg
global TkzG

set thisproc "GetDirLha"
set thiswin $owner
set WinName ".$owner"
set topf "$WinName.top"
set archdr "$WinName.hdr"
set arcbody "$WinName.body"
set fv "ArcFno$thiswin"
global $fv
set ArcFno [set $fv]
set WButBg $TwButBg($ArcFno)
set WButFg $TwButFg($ArcFno)
# incr TmpNo
set tno $TmpNo
set tmpf "$TempDir/TkzTmp$tno"
# set errf "$TempDir/TkzErr$tno"
set dirfile "$TempDir/TkzDir$tno"
set killist "Kill$owner"
global $killist
set $killist [lappend $killist $dirfile $tmpf]

set ap "ArcPgm$thiswin"
set lf "ListFlags$thiswin"
global $ap $lf
set arcpgm [set $ap]
set listflags [set $lf]

set tmp "spacey$thiswin"
global $tmp
set spacey [set $tmp]
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
#  Zip doesn't like to read from devices at all...
if { $dirname == "/dev" }  {
    set TheArcFile $tmparc
  }


# set arcpgm "lha"
# set listflags "v"
set rc 0

#--------------------
# Now read the list...
##--------------------

        set rc [catch {exec $arcpgm $listflags $TheArcFile >$dirfile 2>$errf} tmp]
        if [ catch {set in [open $dirfile r]} ]  {
          #  The caller needs to take the appropriate action here...
          #  just tell him nfg...
	  return -1
	  }

        set dfltwidth 80
        set hdrwidth 0
        set hdrflds 8
        set llen 0
        set ll1 0
        set fl1 0
#--------------------------
        set fl1 11
        set fl2 11
        set fl3 9
        set fl4 9
        set fl5 8
        set fl6 12
        set fl7 18
        set fl8 24
#--------------------------
	set lineno 0
	# Heading for lha...
        if {[info commands $archdr.h1] == ""}  {
          label $archdr.h1 -relief groove
          label $archdr.h2 -relief groove
          label $archdr.h3 -relief groove
          label $archdr.h4 -relief groove
          label $archdr.h5 -relief groove
          label $archdr.h6 -relief groove
          label $archdr.h7 -relief groove
          label $archdr.h8 -relief groove
          }
	pack $archdr.h1 $archdr.h2 $archdr.h3 $archdr.h4 $archdr.h5 $archdr.h6 $archdr.h7 -side left  
	pack $archdr.h8 -anchor w -side left -fill x -expand yes
	$archdr.h1 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "   Perm       "
	$archdr.h2 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "  Owner/Grp  "
	$archdr.h3 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "  Packed  " 
	$archdr.h4 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "   Size     "
	$archdr.h5 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text " Ratio     "
	$archdr.h6 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "      CRC      "
	$archdr.h7 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "          Date              " 
	$archdr.h8 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "           Name        "
	# End lha heading...
	set ignline 1

        while  { [ gets $in line ] > -1 } {
	  incr lineno
	  if {$ignline}  {
            if {[string first "--------" $line] == 0}  {
              set ignline 0
	      }
	    continue
	    }  else  {
            if {[string first "--------" $line] == 0}  {
              set ignline 1
              continue
              }
	    }
#-------------
          #  Adapt column widths to actual data found...
          set fc 0
          set ffc 0
          set fline ""
          while {$fc < $hdrflds}  {
            set fld [lindex $line $ffc]
            switch    $ffc    {
              0      -
              1      -
              2      -
              3      -
              4      {
                  set fl [string length [lindex $line $ffc]]
                  }
              5      {
                  set fl [string length [lindex $line $ffc]]
                  incr ffc
                  incr fl [string length [lindex $line $ffc]]
                  incr fl
                  set fld [string trim $fld]
                  set fldtmp [string trim [lindex $line $ffc]]
                  set fld "$fld $fldtmp"
                  }
              7      {
                  set date [lindex $line $ffc]
#                  set name [lindex $line end]
                  set name [lrange $line 10 end]
                  set ds [string first $date $line]
                  set ns [string last $name $line]
                  incr ds -1
                  incr ns -1
                  set fld [string range $line $ds $ns]
                  set fl [string length $fld]
                  }
              }

            if {$fc == 7}  {
#              set fld [lindex $line end]
              set fld [lrange $line 10 end]
              set fl [string length $fld]
              }
            incr fc
            incr ffc
            set fln "fl$fc"
            if {$fl > [set $fln]}  {
               set $fln $fl
               }
            set fld [string trim $fld]

            switch    $fc        {
                3          -
                4          -
                5          {
                    set fld [string trim $fld]
                    set fltmp [string length $fld]
                    set fltmp2 [set $fln]
                    set fltmp2 [expr $fltmp2 - $fltmp]
                    if {$fltmp2 > 0}  {
                      incr fltmp2 -1
                      set ftmp [string range "                " 0 $fltmp2]
                      set fld "$ftmp$fld"
                      }
                    }
                6          -
                8          {
                    set fld " $fld "
                    }
                default    {
                    set fld "$fld                "
                    set fltmp [set $fln]
                    incr fltmp -1
                    set fld [string range $fld 0 $fltmp]
                    }
                  }


            set fline "$fline$fld"
            }

          $arcbody.alist insert end $fline
          #  Hack to deal with spacey Win95 style filenames...
          #  If one is found in the archive, force selectmode single, so we
          #  might have a chance of getting viewing to work.
          set tmpfn [string trim [lrange $fline 10 end]]  
          if {[string first " " $tmpfn] != -1}  {
            set spacey 1
            set tmp "spacey$thiswin"
            global $tmp
            set $tmp $spacey
            }
          }
        catch { close $in }

##--------------------
# Done...
#--------------------
set llen 80
##  Window size - may need xscrollbar...
#        if {$hdrwidth > $dfltwidth}  {
#          set dfltwidth $hdrwidth
#          }
##	if { $llen > $dfltwidth } {
##	  set ll1 $llen
##	  set llen $dfltwidth
          if {[info commands $arcbody.scrollx] == ""}  {
            scrollbar $arcbody.scrollx -orient horizontal -command "$arcbody.alist xview"
            }
          $arcbody.alist configure -xscroll "$arcbody.scrollx set"
##	  }
#
        $arcbody.alist configure -width $llen
##        if { $ll1 > $llen } {
	  pack $arcbody.scrollx -fill x -side bottom
##	  } 
#  Do we want to do this here...?
        pack $arcbody.alist  -side left -fill both -expand yes
##--------------------

return $rc
}

#--------------------------------------------------------------
#  GetVLha  --  Get a member to view from an LHa archive
#
#--------------------------------------------------------------
proc GetVLha {owner dirname arcname flist tmpd errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global ErrArgs
global TkzG
set thisproc "GetVLha"

set tmp "spacey$owner"
global $tmp
set spacey [set $tmp]
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }

#  This one should be simple, but -p to stdout tacks on a crappy heading, so...
#set where [pwd]
#cd $TempDir
#set l1 [string last "/" $fname]
#if {$l1 != -1}  {
#  incr l1
#  set fnn [string range $fname $l1 end]
#  }  else  {
#  set fnn $fname
#  }
#
#set rc [catch {exec lha -xi $TheArcFile $fname >$tmpf 2>$errf} cc]
#set here [pwd]
##puts "Trying to copy $fnn to $tmpf in $here"
#catch {[exec cp $fnn $tmpf]}
#catch {[exec rm -f $fnn]}
#------------------
set errc 0
set rc 0
set where [pwd]
set xlist ""
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

cd $tmpd
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  set l1 [string last "/" $fn]
  if {$l1 != -1}  {
    incr l1
    set fnn [string range $fn $l1 end]
    }  else  {
    set fnn $fn
    }

    set tmpf "$tmpd/$fn"
    set rc [catch {exec lha -xi $TheArcFile $fn >>$errf 2>>$errf} cc]

    if {$TkzG(Portable)}  {
      catch {file copy -force $fn $tmpf}
      }  else  {
      catch {exec cp $fn $tmpf}
      }
  if {$rc != 0}  {
    cd $where
    return $rc
    }
  incr ll2
  }
#------------------

cd $where
return $rc
}

#--------------------------------------------------------------
#  ExtLha  --  Extract member(s) from an LHa archive
#
#--------------------------------------------------------------
proc ExtLha {owner dirname arcname whereto fname flist lstf errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "ExtLha"

set statw ".$owner.top.vopt.stat"
set stat "Stat$owner"
global $stat
set $stat "          "
set fv "ArcFno$owner"
global $fv
set ArcFno [set $fv]
if {$ArcFno == 2}  {
  set vred "red"
  }  else  {
  #  Because the background on that one is also red...
  #  so call this virtual red.
  set vred "green"
  }

set tmp "apn2$owner"
global $tmp
set apn2 [set $tmp]
set tmp "jpn2$owner"
global $tmp
set jpn2 [set $tmp]
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" }  {
  set TheArcFile $tmparc
  }
set tmp "sdirl$owner"
global $tmp
set flist3 [set $tmp]
if {$jpn2}  {
  set theflags "xfi"
  }  else  {
  set theflags "xf"
  }
set rc 0

$statw configure -textvariable $stat -fg $vred

#  Pay no attention to fname, we may have a lotta files to extract...
#  gotta access the list of member names to extract.
#  For each file in list, just extract in the target dir.
set $stat "Extracting"
$statw configure -fg $vred

update idletasks
set xlist ""
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

set where [pwd]
cd $whereto
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1 && $rc == 0}  {
  set fn [lindex $xlist $ll2]
#  set rc [catch {exec lha -x $TheArcFile $fn >$lstf 2>$errf} cc]
  set cmd [list "exec" "lha" "$theflags" "$TheArcFile" "$fn" ">$lstf" "2>$errf"]
  set rc [catch {set trc [eval $cmd]} cc]
#puts "ExtLha1:  rc = $rc  cc = $cc"
  incr ll2
  }
#------------
set ll1 0
set ll2 0
catch {set ll1 [llength $flist3]}
if {! $rc && $ll1 != 0}  {
  while {$ll2 < $ll1 && $rc == 0}  {
    set fn [lindex $flist3 $ll2]
#    set rc [catch {exec lha -x $TheArcFile $fn >>$lstf 2>>$errf} cc]
    set cmd [list "exec" "lha" "$theflags" "$TheArcFile" "$fn" ">$lstf" "2>$errf"]
    set rc [catch {set trc [eval $cmd]} cc]
#puts "ExtLha2:  rc = $rc  cc = $cc"
    incr ll2
    }
  }
#------------

$statw configure -fg black
set $stat "   Done   "
#  Now done in common error check func
#if {$TkzG(Portable)}  {
#  catch { [file delete -force $lstf $errf $flist] }
#  }  else  {
#  catch { [exec rm $lstf $errf $flist] }
#  }

cd $where
return $rc
}

#--------------------------------------------------------------
#  AddLha  --  Add member(s)to an LHa archive
#
#    Options supported:
#        Absolute or relative pathnames  --  default: relative
#        Loose or keep pathnames  --  default: keep pathnames
#--------------------------------------------------------------
proc AddLha {parent owner dirname arcname flist lstf errf} {
global TkzG
set thisproc "AddLha"
global ErrArgs


set tmp "creating$parent"
global $tmp
set creating [set $tmp]
set tmp "apn$owner"
global $tmp
set apn [set $tmp]
set tmp "rpn$owner"
global $tmp
set rpn [set $tmp]
set tmp "jpn$owner"
global $tmp
set jpn [set $tmp]
#set tmp "recurs$owner"
#global $tmp
#set recurs [set $tmp]
set tmp "ArcFno$parent"
global $tmp
set type [set $tmp]
set rc 0
set TheArcFile $dirname/$arcname
set xlist ""
set body "$owner.body"
set cdvar "CraDir$body"
global $cdvar
set where [set $cdvar]

if [ catch {set fl [open $flist r]} ]  {
#  puts "$thisproc:    open failure"
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

set flags ""
if {! $apn && ! $jpn && ! $rpn}  {
  cd "/"
  }

set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
#    ****  gotta check what the options are...
  if {! $jpn}  {
    if {! $apn}  {
      if {$rpn}  {
        if {[string first $where $fn] == 0}  {
          set fn [string range $fn [string length $where] end]
          if {[string range $fn 0 0]  == "/"}  {
            set fn [string range $fn 1 end]
            }
          }
        }  else  {
        set fn [string range $fn 1 end]
        }
      }
#set here [pwd]
    set rc [catch {exec lha -a $TheArcFile $fn >$lstf 2>$errf} cc]
    }  else  {
#  Junking the pathname...absolute pathname is meaningless
set l1 [string last "/" $fn]
if {$l1 != -1}  {
  incr l1
  set fnn [string range $fn $l1 end]
  }  else  {
  set fnn $fn
  }
#incr l1 -2
#set fnd [string range $fn 0 $l1]
#cd $fnd
#puts "What the hell is fnd...?  =  $fnd"
    set rc [catch {exec lha -a $TheArcFile $fnn >$lstf 2>$errf} cc]
    }

#  set rc [catch {exec lha -a $TheArcFile $fn >$lstf 2>$errf} cc]

  if {$rc != 0}  {
    break
    }
  incr ll2
  }

cd $where
#  Put up an oops box here...
if {$rc != 0}  {
  set ErrArgs [list $lstf $errf $TheArcFile]
  GErrMsgBox 88
  return $rc
  }

return $rc
}

#--------------------------------------------------------------
#  DelLha  --  Delete member(s) from an LHa archive
#
#    Options supported:
#        None at present...  
#--------------------------------------------------------------
proc DelLha {owner dirname arcname flist lstf errf} {
global TkzG
set thisproc "DelLha"
global ErrArgs

set TheArcFile $dirname/$arcname
set xlist ""
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  set rc [catch {exec lha -d $TheArcFile $fn >$lstf 2>$errf} cc]
  if {$rc != 0}  {
    break
    }
  incr ll2
  }

if {$rc != 0}  {
  set ErrArgs [list $lstf $errf $TheArcFile]
  GErrMsgBox 87
  return $rc
  }

return $rc
}



#--------------------------------------------------------------
#  The Cpio Handling Routines --  Handle cpio archives (type 16)
#    - 
#
#--------------------------------------------------------------

#--------------------------------------------------------------------------
#  GetDirCpio  --  Get the Archive Directory list data for a cpio archive
#
#--------------------------------------------------------------------------
proc GetDirCpio {owner dirname arcname dummyname errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg 
global TmpNo TempDir GotBzip
global TwButBg TwButFg
global TkzG

set thisproc "GetDirCpio"
set thiswin $owner
set WinName ".$owner"
set topf "$WinName.top"
set archdr "$WinName.hdr"
set arcbody "$WinName.body"
set fv "ArcFno$thiswin"
global $fv
set ArcFno [set $fv]
set WButBg $TwButBg($ArcFno)
set WButFg $TwButFg($ArcFno)
# incr TmpNo
set tno $TmpNo
set tmpf "$TempDir/TkzTmp$tno"
# set errf "$TempDir/TkzErr$tno"
set dirfile "$TempDir/TkzDir$tno"
set killist "Kill$owner"
global $killist
set $killist [lappend $killist $dirfile $tmpf]

set tmp "spacey$thiswin"
global $tmp
set spacey [set $tmp]
set ap "ArcPgm$thiswin"
set ap2 "ArcPgm2$thiswin"
set lf "ListFlags$thiswin"
global $ap $ap2 $lf
set arcpgm [set $ap]
set arcpgm2 [set $ap2]
set listflags [set $lf]

set cpext ".cpio"
set tempcpio "TmpCpio$owner"
global $tempcpio
set tempcpiofile "$TempDir/Tcp$tno$cpext"
set $tempcpio $tempcpiofile
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
#  Zip doesn't like to read from devices at all...
if { $dirname == "/dev" }  {
    set TheArcFile $tmparc
  }
if {$ArcFno == 19}  {
    set rc [ catch { exec rpm2cpio $TheArcFile >$tempcpiofile } cc ]
    set TheArcFile $tempcpiofile
  }


# set arcpgm "cpio"
# set listflags "-t"
set rc 0

#--------------------
# Now read the list...
##--------------------

        set rc [catch {exec $arcpgm $listflags <$TheArcFile >$dirfile 2>$errf} tmp]
        if [ catch {set in [open $dirfile r]} ]  {
          #  The caller needs to take the appropriate action here...
          #  just tell him nfg...
	  return -1
	  }
        set dfltwidth 80
        set hdrwidth 0
        set hdrflds 5
        set llen 0
        set ll1 0
        set fl1 0
#--------------------------
        set fl1 11
        set fl2 11
        set fl3 9
        set fl4 18
        set fl5 24
        set fl3 10
        set fl4 12
        set fl5 24
#--------------------------
	set lineno 0
	# Heading for cpio...
        if {[info commands $archdr.h1] == ""}  {
          label $archdr.h1 -relief groove
          label $archdr.h2 -relief groove
          label $archdr.h3 -relief groove
          label $archdr.h4 -relief groove
          label $archdr.h5 -relief groove
          }
	pack $archdr.h1 $archdr.h2 $archdr.h3 $archdr.h4 -side left  
	pack $archdr.h5 -anchor w -side left -fill x -expand yes
	$archdr.h1 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "   Perm       "
	$archdr.h2 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "  Owner/Grp  "
	$archdr.h3 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "  Size        " 
	$archdr.h4 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "          Date              " 
	$archdr.h5 configure -bg $WButBg -fg $WButFg -highlightbackground $WButBg -text "           Name        "
	# End cpio heading...
        while  { [ gets $in line ] > -1 } {
	  incr lineno
#-------------
          #  Adapt column widths to actual data found...

#--------------------------
#  New handling...
#  the old stuff left over from the generic routine got badly
#  broken by spacey filenames.
#--------------------------
set perm [lindex $line 0]
set ownr "[lindex $line 2]/[lindex $line 3]"
set size [lindex $line 4]
set date [lrange $line 5 7]
set name [lindex [lrange $line 8 end] 0]
set tmp [string length $perm]
if {$tmp <= $fl1}  {
#  set perm "$perm                        "
#  set perm [string range $perm 0 $fl1]
  }  else  {
  set fl1 [string length $perm]
#  incr fl1
  }
set perm [string range "$perm                        " 0 $fl1]
set tmp [string length $ownr]
if {$tmp <= $fl2}  {
#  set ownr "$ownr                        "
#  set ownr [string range $ownr 0 $fl3]
  }  else  {
  set fl2 [string length $ownr]
#  incr fl2
  }
set ownr [string range "$ownr                        " 0 $fl2]
set tmp [string length $size]
if {$tmp <= $fl3}  {
#  set size "$size                        "
#  set size [string range $size 0 $fl3]
  }  else  {
  set fl3 [string length $size]
#  incr fl3
  }
set size [string range "$size                        " 0 $fl3]
set tmp [string length $date]
if {$tmp <= $fl4}  {
#  set date "$date                        "
#  set date [string range "$date                        " 0 $fl4]
  }  else  {
  set fl4 [string length $date]
#  incr fl4
  }
set date [string range "$date                        " 0 $fl4]
set tmp [string length $name]
if {$tmp <= $fl5}  {
#  set name "$name                        "
#  set name [string range $name 0 $fl5]
  }  else  {
  set fl5 [string length $name]
#  incr fl5
  }
set name [string range "$name                        " 0 $fl5]
eval {set fline "$perm $ownr $size $date $name  "}
#--------------------------
          $arcbody.alist insert end $fline
#            $arcbody.alist insert end $line
            #  Hack to deal with spacey Win95 style filenames...
            #  If one is found in the archive, force selectmode single, so we
            #  might have a chance of getting viewing to work.
            set tmpfn [string trim [lrange $fline 6 end]]
            if {[string first " " $tmpfn] != -1}  {
              set spacey 1
              set tmp "spacey$thiswin"
              global $tmp
              set $tmp $spacey
              }
          }
        catch { close $in }

##--------------------
# Done...
#--------------------
#	$archdr.h1 configure -width $fl1
#	$archdr.h2 configure -width $fl2
#	$archdr.h3 configure -width $fl3
#	$archdr.h4 configure -width $fl4
#	$archdr.h5 configure -width $fl5
set llen 80
##  Window size - may need xscrollbar...
#  Aww, just set the damn thing...who cares whether it's needed?
          if {[info commands $arcbody.scrollx] == ""}  {
            scrollbar $arcbody.scrollx -orient horizontal -command "$arcbody.alist xview"
            }
          $arcbody.alist configure -xscroll "$arcbody.scrollx set"
        $arcbody.alist configure -width $llen
	  pack $arcbody.scrollx -fill x -side bottom
#  Do we want to do this here...?
        pack $arcbody.alist  -side left -fill both -expand yes
##--------------------

return $rc
}

#--------------------------------------------------------------
#  GetVCpio  --  Get a member to view from a cpio archive
#
#--------------------------------------------------------------
proc GetVCpio {owner dirname arcname flist tmpd errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global ErrArgs
global TkzG
set thisproc "GetVCpio"

set fv "ArcFno$owner"
global $fv
set ArcFno [set $fv]
set ap "ArcPgm$owner"
set ap2 "ArcPgm2$owner"
global $ap $ap2
set arcpgm [set $ap]
set arcpgm2 [set $ap2]
set cpext ".cpio"
set tempcpio "TmpCpio$owner"
global $tempcpio
set tempcpiofile [set $tempcpio]
#set tempcpiofile "$TempDir/Tcp$tno$cpext"
#set $tempcpio $tempcpiofile

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set TheArcFile $dirname/$arcname
if { $dirname == "/dev" }  {
#  set tmp [string last "/" $tmparc]
#  incr tmp
#  set TheArcFile [string range $tmparc $tmp end]
  set TheArcFile $tmparc
  }
if {$ArcFno == 19}  {
#    set rc [ catch { exec rpm2cpio $TheArcFile >$tempcpiofile } cc ]
    set TheArcFile $tempcpiofile
  }

#  This is really grotesque...
#  Have to go to temp dir & extract it there - the whole damn path...
#  and if it has a leading "/" we have to refuse to do it, for obvious reasons.
#  Note - we should make Add refuse ever to use a leading "/"...
set rc 0
set errc 0
set where [pwd]
set xlist ""
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

cd $tmpd
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
  if {[string first "/" $fn] == 0}  {
    if {! $errc}  {
      set ErrArgs [list $fn]
      GErrMsgBox 85
      set errrc 85
      set rc $errrc
      return $rc
      }
    }  else  {
      set tmpi [string last "/" $fn]
      set tmpf [string range $fn $tmpi end]
      set rc [catch {exec $arcpgm -id -I $TheArcFile $fn  2>$errf} cc]
      if {$fn != $tmpf}  {
        set tmpf "$tmpd/$tmpf"
        if {$TkzG(Portable)}  {
          catch {file copy -force $fn $tmpf}
          }  else  {
          catch {exec cp $fn $tmpf}
          }
        set l1 [string first "/" $fn]
        if {$l1 != -1}  {
          incr l1 -1
          set fdir [string range $fn 0 $l1]
          if {$TkzG(Portable)}  {
            catch {file delete -force $fdir}
            }  else  {
            catch {exec rm -rf $fdir}
            }
          }  else  {
          if {$TkzG(Portable)}  {
            catch {file delete -force $fn}
            }  else  {
            catch {exec rm -f $fn}
            }
          }
        }
    if {$rc != 0}  {
      cd $where
      return $rc
      }
    }
  incr ll2
  }
  cd $where

return $rc
}

#--------------------------------------------------------------
#  ExtCpio  --  Extract member(s) from a cpio archive
#
#--------------------------------------------------------------
proc ExtCpio {owner dirname arcname whereto fname flist lstf errf} {
global whohdr timehdr WhoBg MainButBg MainBg MainFg TBg TButBg TFg TmpNo TempDir
global TkzG
set thisproc "ExtCpio"

set statw ".$owner.top.vopt.stat"
set stat "Stat$owner"
global $stat
set $stat "          "
set fv "ArcFno$owner"
global $fv
set ArcFno [set $fv]
if {$ArcFno == 2}  {
  set vred "red"
  }  else  {
  #  Because the background on that one is also red...
  #  so call this virtual red.
  set vred "green"
  }

set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]

set ap "ArcPgm$owner"
set ap2 "ArcPgm2$owner"
global $ap $ap2
set arcpgm [set $ap]
set arcpgm2 [set $ap2]
set cpext ".cpio"
set tempcpio "TmpCpio$owner"
global $tempcpio
set tempcpiofile [set $tempcpio]
#set tempcpiofile "$TempDir/Tcp$tno$cpext"
#set $tempcpio $tempcpiofile


set TheArcFile $dirname/$arcname
if { $dirname == "/dev" }  {
  set TheArcFile $tmparc
  }
if {$ArcFno == 19}  {
#    set rc [ catch { exec rpm2cpio $TheArcFile >$tempcpiofile } cc ]
    set TheArcFile $tempcpiofile
  }
set tmp "sdirl$owner"
global $tmp
set flist3 [set $tmp]
set rc 0

$statw configure -textvariable $stat -fg $vred

#  Pay no attention to fname, we may have a lotta files to extract...
#  gotta access the list of member names to extract.
#  For each file in list, just extract in the target dir.
set $stat "Extracting"
$statw configure -fg $vred

update idletasks
set xlist ""
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

set where [pwd]
cd $whereto
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1 && $rc == 0}  {
  set fn [lindex $xlist $ll2]
  set rc [catch {exec cpio -id -I $TheArcFile $fn >$lstf 2>$errf} cc]
#puts "ExtCpio1:  rc = $rc  cc = $cc"
  #  cpio, at least the GNU version, doesn't set an error return code,
  #  but it does write an error message to stderr. So, we have to check
  #  whether anything has been written to errf. Sick, very sick.
  if {[file exists $errf]}  {
    if {[file size $errf] > 0}  {
      set rc -1
      }
    }
  incr ll2
  }
#------------
set ll1 0
set ll2 0
catch {set ll1 [llength $flist3]}
if {! $rc && $ll1 != 0}  {
  while {$ll2 < $ll1 && $rc == 0}  {
    set fn [lindex $flist3 $ll2]
    set rc [catch {exec $arcpgm -id -I $TheArcFile $fn >>$lstf 2>>$errf} cc]
#puts "ExtCpio2:  rc = $rc  cc = $cc"
    if {[file exists $errf]}  {
      if {[file size $errf] > 0}  {
        set rc -1
        }
      }
    incr ll2
    }
  }
#------------

$statw configure -fg black
set $stat "   Done   "
#  Now done in common error check func
#if {$TkzG(Portable)}  {
#  catch { [file delete -force $lstf $errf $flist] }
#  }  else  {
#  catch { [exec rm $lstf $errf $flist] }
#  }

cd $where
return $rc
}

#--------------------------------------------------------------
#  AddCpio  --  Add member(s)to a cpio archive
#
#    Note - this needs to be fixed to work just like lha...
#
#    Options supported:
#        None at present...  
#--------------------------------------------------------------
proc AddCpio {parent owner dirname arcname flist lstf errf} {
global TkzG
set thisproc "AddCpio"
global ErrArgs


set tmp "creating$parent"
global $tmp
set creating [set $tmp]
set tmp "apn$owner"
global $tmp
set apn [set $tmp]
set tmp "rpn$owner"
global $tmp
set rpn [set $tmp]
set tmp "jpn$owner"
global $tmp
set jpn [set $tmp]
#set tmp "recurs$owner"
#global $tmp
#set recurs [set $tmp]
set tmp "ArcFno$parent"
global $tmp
set type [set $tmp]
set rc 0
set TheArcFile $dirname/$arcname
set xlist ""
set body "$owner.body"
set cdvar "CraDir$body"
global $cdvar
set where [set $cdvar]

if [ catch {set fl [open $flist r]} ]  {
#  puts "$thisproc:    open failure"
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

if {! $apn && ! $jpn && ! $rpn}  {
  cd "/"
  }
set flags ""
set fno 0
set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
if {! $apn}  {
#  set fn [string range $fn 1 end]
  }
#    ****  gotta specify append if not new file...
  if {! $jpn}  {
    if {! $apn}  {
      if {$rpn}  {
        if {[string first $where $fn] == 0}  {
          set fn [string range $fn [string length $where] end]
          if {[string range $fn 0 0]  == "/"}  {
            set fn [string range $fn 1 end]
            }
          }
        }  else  {
        set fn [string range $fn 1 end]
        }
      }
set here [pwd]
    if {$creating}  {
      if {$fno == 0}  {
        incr fno
        set rc [catch {exec echo "$fn" | cpio -o -F $TheArcFile 2>$errf} cc]
        }  else  {
        set rc [catch {exec echo "$fn" | cpio -oA -F $TheArcFile 2>$errf} cc]
        }
      }  else  {
      set rc [catch {exec echo "$fn" | cpio -oA -F $TheArcFile 2>$errf} cc]
      }
    }  else  {
    #  Junking the pathname (jpn)...absolute pathname is meaningless
    set l1 [string last "/" $fn]
    incr l1
    set fnn [string range $fn $l1 end]
    incr l1 -2
    set fnd [string range $fn 0 $l1]
    cd $fnd
    if {$creating}  {
      if {$fno == 0}  {
        incr fno
        set rc [catch {exec echo "$fnn" | cpio -o -F $TheArcFile 2>$errf} cc]
        }  else  {
        set rc [catch {exec echo "$fnn" | cpio -oA -F $TheArcFile 2>$errf} cc]
        }
      }  else  {
      set rc [catch {exec echo "$fnn" | cpio -oA -F $TheArcFile 2>$errf} cc]
      }
    }

  if {$rc != 0}  {
    break
    }
  incr ll2
  }

cd $where
#  Put up a message box if error...
if {$rc != 0}  {
  set ErrArgs [list $lstf $errf $TheArcFile]
  GErrMsgBox 88
  return $rc
  }

return $rc
}

#--------------------------------------------------------------
#  DelCpio  --  Delete member(s) from a cpio archive
#
#    Options supported:
#        None at present...  
#--------------------------------------------------------------
proc DelCpio {owner dirname arcname flist lstf errf} {
global TkzG
set thisproc "DelCpio"
global ErrArgs

set TheArcFile $dirname/$arcname
set rc -1

if {$rc != 0}  {
  set ErrArgs [list "delete" "cpio"]
  GErrMsgBox 84
  return $rc
  }

return $rc
}






#--------------------------------------------------------
#  The Old Routines
#
#--------------------------------------------------------

#--------------------------------------------------------
#  Many things deleted...
#--------------------------------------------------------

#---------------------------------
#  KillArc  --  Destroy this view 
#---------------------------------
proc KillArc {owner cleanall}  {
global MenuHelp WinList TempDir
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 20
  return 1
  }

#  We need to clean up any temp files we left lying around
set tmp "TmpTar$owner"
global $tmp
set tmptar [set $tmp]
set tmp "tmparc$owner"
global $tmp
set tmparc [set $tmp]
set tmp "TmpBz$owner"
global $tmp
set tmpbz [set $tmp]
set tmp "TmpRar$owner"
global $tmp
set tmprar [set $tmp]
set tmp "TmpArj$owner"
global $tmp
set tmparj [set $tmp]
set tmp "TmpCpio$owner"
global $tmp
set tmpcpio [set $tmp]
set where [pwd]

if {$tmparc != ""}  {
  if {$TkzG(Portable)}  {
    catch {file delete -force $tmparc}
    }  else  {
    catch {exec rm -f $tmparc}
    }
  }
#  In case temp tar belongs to somebody else...
if {$tmptar != "" && $cleanall}  {
  if {$TkzG(Portable)}  {
    catch {file delete -force $tmptar}
    }  else  {
    catch {exec rm -f $tmptar}
    }
  }
if {$tmpbz != ""}  {
  if {$TkzG(Portable)}  {
    catch {file delete -force $tmpbz}
    }  else  {
    catch {exec rm -f $tmpbz}
    }
  }
if {$tmprar != ""}  {
  if {$TkzG(Portable)}  {
    catch {file delete -force $tmprar}
    }  else  {
    catch {exec rm -f $tmprar}
    }
  }
if {$tmparj != ""}  {
  if {$TkzG(Portable)}  {
    catch {file delete -force $tmparj}
    }  else  {
    catch {exec rm -f $tmparj}
    }
  }
if {$tmpcpio != ""}  {
  if {$TkzG(Portable)}  {
    catch {file delete -force $tmpcpio}
    }  else  {
    catch {exec rm -f $tmpcpio}
    }
  }
set tmp "Kill$owner"
global $tmp
set killist [set $tmp]
set kli [llength $killist]
set kli2 0
while {$kli2 < $kli}  {
  set file [lindex $killist $kli2]
  if {[file isdirectory $file]}  {
    if {$TkzG(Portable)}  {
      catch {file delete -force $file}
      }  else  {
      catch {exec rm -rf $file}
      }
    }  else  {
    if {$TkzG(Portable)}  {
      catch {file delete -force $file}
      }  else  {
      catch {exec rm -f $file}
      }
    #  Arrrgh -- catch the case where file was used by us in an internal
    #  viewing call - if the temp dir it's in is empty (there could
    #  have been multiple files), then delete the dir also
    set l1 [string last "/" $file]
    if {$l1 != -1}  {
      incr l1 -1
      set tdir [string range $file 0 $l1]
      set l1 [string length $TempDir]
      set tdir2 [string range $tdir $l1 end]
      if {$tdir != ""}  {
        set fl ""
        catch {set fl [glob "$tdir/*"] }
        if {$fl == ""}  {
          if {$TkzG(Portable)}  {
            catch {file delete -force $tdir}
            }  else  {
            catch {exec rm -rf $tdir}
            }
          cd $TempDir
          }
        }
      }
    }
  incr kli2
  }

set tmp "Addwin$owner"
global $tmp
set addwin [set $tmp]
if {$addwin != ""}  {
  KillAdd $addwin $owner
  set addwin ""
  set $tmp $addwin
  }

#  Destroy a Find window if it exists.
set fw "Fnds"
set tmp "$owner$fw"
if [winfo exists .$tmp] {
  KillFindWin $tmp
  }

set buttons ".$owner.top.but"
KillMyButtons "$buttons"
PluckFromList $owner "WinList"

catch {destroy ".uninst$owner"}
destroy .$owner
catch {cd $where}
if {$TkzG(PipeIn) && $WinList == ""}  {
  FinalExit
  }
if {$TkzG(NoMainWin) || $TkzG(LastCloseExits)}  {
  if {$WinList == ""}  {
    FinalExit
    }
  }
return 1
}


#--------------------------------
#  SelectOne  --  enable buttons 
#--------------------------------
proc SelectOne {owner}  {
global MainSelected GotGtar
global TkzG

set tmp "SimpleCmp$owner"
global $tmp
set simple [set $tmp]
set tmp "ArcFno$owner"
global $tmp
set type [set $tmp]
set buttons ".$owner.top.but"
##$buttons.view configure -state normal
##$buttons.ext configure -state normal
##set TDel 1
###  Always disable tar delete - I know of no version where it's reliable.
###if {! $GotGtar}  {
###  }
##  if {$type == 1 || $type == 3 || $type == 5 || $type == 14 || $type == 18} {
##    set TDel 0
##    }
##if {! $simple && $type != 10 && $type != 11 && $type != 19}  {
##  if {$TDel}  {
##    $buttons.del configure -state normal
##    }
###  $buttons.uninst configure -state normal
##  }
##if {! $simple}  {
##  $buttons.uninst configure -state normal
##  }
EnableDirButtons $owner

KillOtherButtons "$buttons"
return 1
}


#-----------------------------------------------------------
#  SelectAll  --  Select all the items in an archive list   
#-----------------------------------------------------------
proc SelectAll {owner arcname dirname}  {
global MenuHelp GotGtar
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 21
  return 1
  }

set tmp "SimpleCmp$owner"
global $tmp
set simple [set $tmp]
set tmp "ArcFno$owner"
global $tmp
set type [set $tmp]
set alist "$owner.body.alist"
set buttons "$owner.top.but"
.$alist selection set 0 [.$alist size]
set cmd "SelectNone $owner [list $arcname] $dirname"
.$buttons.selall configure -text "Deselect All" -command $cmd
##.$buttons.view configure -state normal
##.$buttons.ext configure -state normal
##set TDel 1
###  Always disable tar delete - I know of no version where it's reliable.
###if {! $GotGtar}  {
###  }
##  if {$type == 1 || $type == 3 || $type == 5 || $type == 14 || $type == 18} {
##    set TDel 0
##    }
##if {! $simple && $type != 10 && $type != 11 && $type != 19}  {
##  if {$TDel}  {
##    .$buttons.del configure -state normal
##    }
##  .$buttons.uninst configure -state normal
##  }
EnableDirButtons $owner
return 1
}


#-----------------------------------------------------------
#  SelectNone  --  Select all the items in an archive list  
#-----------------------------------------------------------
proc SelectNone {owner arcname dirname}  {
global MenuHelp
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 21
  return 1
  }

set alist "$owner.body.alist"
set buttons "$owner.top.but"
.$alist selection clear 0 [.$alist size] 
set cmd "SelectAll $owner [list $arcname] $dirname"
.$buttons.selall configure -text "Select All" -command $cmd
#.$buttons.view configure -state disabled
#.$buttons.ext configure -state disabled
#.$buttons.del configure -state disabled
#.$buttons.uninst configure -state disabled
DisableDirButtons $owner

return 1
}


#-----------------------------------------------------------
#  EnableDirButtons  --  Enable buttons that only work when
#     something's selected.
#-----------------------------------------------------------
proc EnableDirButtons {owner}  {
global MenuHelp MainSelected
global TkzG

set tmp "ArcName$owner"
global $tmp
set arcname [set $tmp]
set tmp "DirName$owner"
global $tmp
set dirname [set $tmp]
set alist "$owner.body.alist"
set buttons "$owner.top.but"
set tmp "SimpleCmp$owner"
global $tmp
set simple [set $tmp]
set tmp "ArcFno$owner"
global $tmp
set type [set $tmp]

.$buttons.view configure -state normal
.$buttons.ext configure -state normal

set TDel 1
#  Disable Delete for all types of tars...
if {$type == 1 || $type == 3 || $type == 5 || $type == 14 || $type == 18} {
#  RBW - temp test...
#  We need to limit this to GNU tar...
  set TDel 0
  }
if {! $simple && $type != 10 && $type != 11 && $type != 19}  {
  if {$TDel}  {
    .$buttons.del configure -state normal
    }
  .$buttons.uninst configure -state normal
  }
.main.f2.but2.m1 entryconfigure 3 -state disabled \
  -foreground PowderBlue
.main.f2.but2.m1 entryconfigure 4 -state disabled \
  -foreground PowderBlue
set MainSelected 0


}


#-----------------------------------------------------------
#  DisableDirButtons  --  Disable buttons that only work when
#     something's selected.
#-----------------------------------------------------------
proc DisableDirButtons {owner}  {
global MenuHelp
global TkzG

set tmp "ArcName$owner"
global $tmp
set arcname [set $tmp]
set tmp "DirName$owner"
global $tmp
set dirname [set $tmp]
set alist "$owner.body.alist"
set buttons "$owner.top.but"

.$buttons.view configure -state disabled
.$buttons.ext configure -state disabled
.$buttons.del configure -state disabled
.$buttons.uninst configure -state disabled


}



#-----------------------------------------------------------------------------
#  AddItem  --  Add Item(s) to an Archive
#-----------------------------------------------------------------------------
proc AddItem {owner arcname dirname}  {
global ErrArgs MenuHelp ArcWin MainButBg MainBg MainFg WhoBg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg DSlidBg
global EntBg EntFg SelBg SelFg PgmName
global TkzG

set thisproc "AddItem"
if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 24
  return 1
  }

set WBg $TwBg(0)
set WButBg $TwButBg(0)
set WButFg $TwButFg(0)
set WEntBg $EntBg(0)
set WEntFg $EntFg(0)
set WSelBg $SelBg(0)
set WSelFg $SelFg(0)
set WFg $TwFg(0)
set lbg $TwLFg(0)
set lfg $TwLFg(0)

#set win ".$owner"

#  OK, pop up a what'll ya have dialogue...
#-------------------------------------------------------------------
#  Make some unique names for us...
incr ArcWin
set thiswin "addmbr$ArcWin"
set WinName ".$thiswin"
set crfunc "crfunc$thiswin"
global $crfunc
set $crfunc 0
set tmp "creating$owner"
global $tmp
set creating [set $tmp]

if {$dirname == "dummy" && $arcname == "dummy"}  {
  set arcname ""
  set dirname [ GetCurDir "$owner" ]
  }
if {$dirname == "/dev"}  {
  GErrMsgBox 15;
  return -1;
  }

set arcn "arcname$thiswin"
global $arcn
set $arcn $arcname
set atype "ArcFno$owner"
global $atype
set type [set $atype]

set tmp "Addwin$owner"
global $tmp
set addwin [set $tmp]
if {$addwin != ""}  {
  catch {raise .$addwin}
  return -1
  }
set addwin "$thiswin"
set $tmp $addwin

set recurs "recurs$thiswin"
global $recurs
set $recurs 1
set rpn "rpn$thiswin"
global $rpn
set $rpn 1
set apn "apn$thiswin"
global $apn
set $apn 0
set jpn "jpn$thiswin"
global $jpn
set $jpn 0

if [catch {toplevel $WinName}] {
  raise $WinName
  } else {
#  Build the window...
  set arctitle "$PgmName: Add to Archive"
  wm title $WinName $arctitle
  set topf [frame $WinName.top -bg $WBg -highlightbackground $WBg]
  set buttons [frame $topf.but -bg $WBg -highlightbackground $WBg]
  set namef [frame $WinName.top.namef -bg $WBg -highlightbackground $WBg]
  set typef [frame $WinName.top.types -bg $WBg -highlightbackground $WBg]
  set typef1 [frame $WinName.top.types.types1 -bg $WBg -highlightbackground $WBg]
  set typef2 [frame $WinName.top.types.types2 -bg $WBg -highlightbackground $WBg]

  set cmd [list "AddItem2" $owner $thiswin $arcname $dirname]
  button $buttons.add2arc -text "Add to Archive" \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg \
    -command $cmd
  bind $buttons.add2arc <3> {ShowHelp 24b}

  set cmd [list "KillAdd" "$thiswin" "$owner"]
  button $buttons.quit -text "Cancel" \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg \
    -command $cmd
  bind $buttons.quit <3> {ShowHelp 24b}
#  Gotta intercept wm killing the window with this command too
  wm protocol $WinName "WM_DELETE_WINDOW" $cmd
  wm protocol $WinName "WM_SAVE_YOURSELF" $cmd

  label $namef.where -text "   Directory:  " -relief flat -bg $WBg -fg $WFg
  entry $namef.dir -text " " -relief sunken -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg -width 30 \
  -font "-*-fixed-bold-*-*-*-*-*-*-*-*-*-*-1"
  label $namef.fndsc -text "   Archive Name:  " -bg $WBg -fg $WFg -highlightbackground $WBg
  entry $namef.fname -textvariable $arcn -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg -width 20
  label $namef.pad -text "    " -bg $WBg -fg $WFg -highlightbackground $WBg
  checkbutton $typef1.rec -variable $recurs -text "Recurse Subdirectories" -bg $WBg -fg $WFg -highlightbackground $WBg

  set cmd "SetApn $typef2"
  checkbutton $typef2.apn -variable $apn -text "Absolute Path Names" \
    -bg $WBg -fg $WFg -highlightbackground $WBg -command $cmd
  set cmd "SetRpn $typef2"
  checkbutton $typef2.rpn -variable $rpn -text "Relative Path Names" \
    -bg $WBg -fg $WFg -highlightbackground $WBg -command $cmd
  set cmd "SetJpn $typef2"
  checkbutton $typef2.jpn -variable $jpn -text "No Path Names" \
    -bg $WBg -fg $WFg -highlightbackground $WBg -command $cmd

  if {$TkzG(Windows)}  {
    $typef1.rec configure -selectcolor $WBg
    $typef2.apn configure -selectcolor $WBg
    $typef2.rpn configure -selectcolor $WBg
    $typef2.jpn configure -selectcolor $WBg
    }

  pack $buttons.add2arc $buttons.quit -side left 
  pack $namef.where $namef.dir $namef.fndsc $namef.fname $namef.pad -side left -expand no
  pack $typef1.rec -side left 
  pack $typef2.apn $typef2.rpn $typef2.jpn -side left
  pack $typef2 $typef1 -side bottom


#  Now build a file selection list for directory to create in & filename...
  set flbody [ frame $WinName.body  -bg $WBg -highlightbackground $WBg]
  set body $thiswin.body

  set stuff [BuildDirList "$body"]

  pack $flbody -anchor w -fill x -side bottom -fill both -expand yes
  
  pack $typef -side bottom -fill both -expand yes -pady 2
  pack $namef -side bottom -anchor center -pady 2
  pack $buttons -side bottom -pady 4
  
  pack $topf -side bottom -anchor center -expand yes -fill x

  $flbody.list1.dirlist configure -selectbackground $WSelBg \
    -selectforeground $WSelFg
  $flbody.list2.arclist configure -selectbackground $WSelBg \
    -selectforeground $WSelFg
  set cradir "CraDir$body"
  global $cradir
  set $cradir $dirname
  set cmd "UpdCraDir $body"
  bind $flbody.list1.dirlist <Double-1> $cmd
  $flbody.list1.dirlist configure -selectmode extended
  $flbody.list2.arclist configure -selectmode extended
  set cmd "UpdCraDir2 $thiswin"
  bind $namef.dir <Return> $cmd
  bind $typef1.rec <3> {ShowHelp 24a}
  bind $typef2.apn <3> {ShowHelp 24a}
  bind $typef2.rpn <3> {ShowHelp 24a}
  bind $typef2.jpn <3> {ShowHelp 24a}


  $namef.dir configure -textvariable $cradir
  set $cradir [UpdDirList "$body" "$dirname"]

#  Now a few type-specific hacks...
#    - tar always recurses subdirs, won't junk pathnames
#    - zip has no absolute pathname option
#    - only allow 1 selection, and no directories, for simple 
#      compressed files
switch $type    {
    1         -
    5         -
    14        -
    18        {
        $typef1.rec configure -state disabled
#        $typef2.jpn configure -state disabled
        set $recurs 1
        }
    2        {
#        $typef2.rpn configure -state disabled
#        $typef2.apn configure -state disabled
        }
    9        {
        $typef1.rec configure -state disabled
        $typef2.apn configure -state disabled
        $typef2.rpn configure -state disabled
        $typef2.jpn configure -state disabled
        set $recurs 0
        }
    4        -
    6        -
    12       -
    13       -
    17       {
        $flbody.list1.dirlist configure -selectmode single
        $flbody.list2.arclist configure -selectmode single
        $typef1.rec configure -state disabled
        $typef2.apn configure -state disabled
        $typef2.rpn configure -state disabled
        $typef2.jpn configure -state disabled
        set $recurs 0
        }
    3        -
    15       {
#        $typef2.apn configure -state disabled
        $typef1.rec configure -state disabled
#        $typef2.jpn configure -state disabled
        set $recurs 1
        }
#  Don't need to add type 19 - we don't update rpms
    16       {
#        $typef2.apn configure -state disabled
        $typef1.rec configure -state disabled
#        $typef2.jpn configure -state disabled
        set $recurs 0
        }
    default  {

        }
    }

  }

return 1
}

#-----------------------------------------------------------------------------
#  SetApn  --  Set the Absolute Path Names option
#-----------------------------------------------------------------------------
proc SetApn {ownerw}  {
global ErrArgs TmpNo TempDir
global TkzG
set thisproc "SetApn"

set tmp [lindex [$ownerw.apn configure -variable] 4]
global $tmp
set apn [set $tmp]
if {$apn}  {
  set tmp [lindex [$ownerw.rpn configure -variable] 4]
  global $tmp
  set $tmp 0
  set tmp [lindex [$ownerw.jpn configure -variable] 4]
  global $tmp
  set $tmp 0
  }

return
}

#-----------------------------------------------------------------------------
#  SetApn2  --  Set the Absolute Path Names option for extract
#-----------------------------------------------------------------------------
proc SetApn2 {ownerw}  {
global ErrArgs TmpNo TempDir
global TkzG
set thisproc "SetApn2"

set tmp [lindex [$ownerw.apn2 configure -variable] 4]
global $tmp
set apn2 [set $tmp]
if {$apn2}  {
  set tmp [lindex [$ownerw.jpn2 configure -variable] 4]
  global $tmp
  set $tmp 0
  }

return
}

#-----------------------------------------------------------------------------
#  SetRpn  --  Set the Relative Path Names option
#-----------------------------------------------------------------------------
proc SetRpn {ownerw}  {
global ErrArgs TmpNo TempDir
global TkzG
set thisproc "SetRpn"

set tmp [lindex [$ownerw.rpn configure -variable] 4]
global $tmp
set rpn [set $tmp]
if {$rpn}  {
  set tmp [lindex [$ownerw.apn configure -variable] 4]
  global $tmp
  set $tmp 0
  set tmp [lindex [$ownerw.jpn configure -variable] 4]
  global $tmp
  set $tmp 0
  }

return
}

#-----------------------------------------------------------------------------
#  SetJpn  --  Set the Junk Path Names option
#-----------------------------------------------------------------------------
proc SetJpn {ownerw}  {
global ErrArgs TmpNo TempDir
global TkzG
set thisproc "SetJpn"

set tmp [lindex [$ownerw.jpn configure -variable] 4]
global $tmp
set jpn [set $tmp]
if {$jpn}  {
  set tmp [lindex [$ownerw.rpn configure -variable] 4]
  global $tmp
  set $tmp 0
  set tmp [lindex [$ownerw.apn configure -variable] 4]
  global $tmp
  set $tmp 0
  }

return
}

#-----------------------------------------------------------------------------
#  SetJpn2  --  Set the Junk Path Names option for extract
#-----------------------------------------------------------------------------
proc SetJpn2 {ownerw}  {
global ErrArgs TmpNo TempDir
global TkzG
set thisproc "SetJpn2"

set tmp [lindex [$ownerw.jpn2 configure -variable] 4]
global $tmp
set jpn2 [set $tmp]
if {$jpn2}  {
  set tmp [lindex [$ownerw.apn2 configure -variable] 4]
  global $tmp
  set $tmp 0
  }

return
}



#-----------------------------------------------------------------------------
#  AddItem2  --  Callback for the OK Do It button
#-----------------------------------------------------------------------------
proc AddItem2 {parent owner arcname dirname}  {
global ErrArgs TmpNo TempDir
global TkzG
set thisproc "AddItem2"

set atype "ArcFno$parent"
global $atype
set type [set $atype]
set jpn "jpn$owner"
global $jpn
#set $jpn 0

set body "$owner.body"
set cradir "CraDir$body"
global $cradir
set seldir [set $cradir]
#puts "$thisproc:    selected items from $seldir"

set nodirs 0
incr TmpNo
set tno $TmpNo
set lstf "$TempDir/TkzLst$tno"
set errf "$TempDir/TkzErr$tno"
set flist "$TempDir/TkzFlst$tno"
set killist "Kill$parent"
global $killist
set $killist [lappend $killist $lstf $errf $flist]

set dlist ".$owner.body.list1.dirlist"
set alist ".$owner.body.list2.arclist"

switch $type    {
    4        -
    6        -
    12       -
    13       -
    17       {
        set nodirs 1
        }
    default  {
        set nodirs 0
        }
    }

set files ""
if {[$dlist curselection] != ""}  {
  if {$nodirs}  {
    #  You don't compress a directory...
    return 1
    }
  if {[set $jpn]}  {
    set ErrArgs [list "    "]
    GErrMsgBox 82
    return 1
    }
  set sellist [$dlist curselection]
  foreach i $sellist {
    set files "$files [$dlist get $i $i]"
    }
  }  else  {
  set sellist [$alist curselection]
  foreach i $sellist {
    set files "$files [$alist get $i $i]"
    }
  }
set files [string trim $files]
#puts "files = <$files>"
if {$files == ""}  {
  return 1
  }

#  May need to append the dirname to all the filenames, depending on options...
set ff [open $flist w]
foreach file $files {
  puts $ff "$seldir/$file"
  }
catch {[close $ff]}


  #  OK, now do the dirty work...
  switch $type        {
      1        -
      3        -
      5        -
      14       -
      18       {
          set rc [AddTar $parent $owner $dirname $arcname $flist $lstf $errf]
          }
      2        {
          set rc [AddZip $parent $owner $dirname $arcname $flist $lstf $errf]
          }
      4        {
          set rc [AddGzp $parent $owner $dirname $arcname $flist $lstf $errf]
          }
      6        {
          set rc [AddCmp $parent $owner $dirname $arcname $flist $lstf $errf]
          }
      9        {
          set rc [AddAr $parent $owner $dirname $arcname $flist $lstf $errf]
          }
      12       {
          set rc [AddShn $parent $owner $dirname $arcname $flist $lstf $errf]
          }
      13       -
      17       {
          set rc [AddBzip $parent $owner $dirname $arcname $flist $lstf $errf]
          }
      15       {
          set rc [AddLha $parent $owner $dirname $arcname $flist $lstf $errf]
          }
#  Don't need to add type 19 - we don't update rpms
      16       {
          set rc [AddCpio $parent $owner $dirname $arcname $flist $lstf $errf]
          }
      default  {
#PluckFromList $owner "FLList"
#destroy .$owner
KillAdd $owner $parent
set ErrArgs [list "Add-to-Archive"]
GErrMsgBox 6
          }
      }


set temptar "TmpTar$parent"
global $temptar
set temptarfile [set $temptar]
set tmp "creating$parent"
global $tmp
set creating [set $tmp]
#  Indicate creation done, and refresh any open filelist windows
#  affected by adding the new file. And since it's new, raise
#  the arc window.
if {$creating}  {
  #  Protect against losing our place during creation.
  set where [pwd]
  RefDirs $dirname
  cd $where
  set creating 0
  set $tmp $creating
  catch {raise .$parent}
  }
if {[file exists $temptarfile]}  {
#    puts "Whoops!  $temptarfile exists...should we kill it?"
  if {$TkzG(Portable)}  {
    catch {file delete -force $temptarfile}
    }  else  {
    catch {exec rm -f $temptarfile}
    }
  }
#  Destroy the Add window...but then, why should we?
#KillAdd $owner $parent

#  Now refresh the directory list...
#  new way - don't destroy and recreate window, just refresh it.
set drc  [GetArcDir $parent $dirname $arcname $errf]
#  Old way...
##  KillArc $parent
##  DispArc $dirname $arcname 0 0

return 1
}

#-----------------------------------------------------------------------------
#  KillAdd  --  Kill the Add window
#-----------------------------------------------------------------------------
proc KillAdd {owner parent}  {
global TkzG

set body "$owner.body"
set tmp "CraDir$body"
global $tmp
set dirname [set $tmp]
set tmp "arcname$owner"
global $tmp
set arcname [set $tmp]

set addwin ""
set tmp "Addwin$parent"
global $tmp
set $tmp $addwin

PluckFromList $owner "FLList"
set WinName ".$owner"
destroy $WinName

return 1
}



#-----------------------------------------------------------------------------
#  DelItem  --  Delete Item(s) from an Archive
#-----------------------------------------------------------------------------
proc DelItem {owner arcname dirname}  {
global ErrArgs MenuHelp TempDir TmpNo
global TkzG
set thisproc "DelItem"

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 25
  return 1
  }
if {$dirname == "/dev"}  {
  GErrMsgBox 15;
  return -1;
  }

set tmp "ArcFno$owner"
global $tmp
set arcfno [set $tmp]
incr TmpNo
set tno $TmpNo
set alist ".$owner.body.alist"
set sellist [$alist curselection]
set flist "$TempDir/TkzFlst$tno"
set lstf "$TempDir/TkzLst$tno"
set errf "$TempDir/TkzErr$tno"
set killist "Kill$owner"
global $killist
set $killist [lappend $killist $lstf $errf $flist]
#puts "$thisproc:    entered with arcfno = $arcfno, filelist = $flist"

BuildMbrList $owner "delete" $tno $arcfno


#  Use the generic routine where possible...
#  Note:  the delete function is very buggy with my version of GNU tar (1.11.8)...
#    - not TkZip's code, theirs. Can't recommend its use very highly.
switch $arcfno    {
    1       -
    3       -
    5       -
    14      -
    18      {
        set rc [DelTar $owner $dirname $arcname $flist $lstf $errf]
        }
    9       {
        set rc [DelAr $owner $dirname $arcname $flist $lstf $errf]
        }
    15       {
        set rc [DelLha $owner $dirname $arcname $flist $lstf $errf]
        }
#  Don't need to add type 19 - we don't update rpms
    16       {
        set rc [DelCpio $owner $dirname $arcname $flist $lstf $errf]
        }
    default       {
        set rc [DelItem2 $owner $dirname $arcname $flist $lstf $errf $arcfno]
        }
    }
#  Now destroy the original window and refresh the directory list...
#KillArc $owner
#DispArc $dirname $arcname 0 0
#  Experimental...
set drc  [GetArcDir $owner $dirname $arcname $errf]

return 1
}


#-----------------------------------------------------------------------------
#  DelItem2  --  Generic delete routine works for most types...
#-----------------------------------------------------------------------------
proc DelItem2 {owner dirname arcname flist lstf errf arcfno}  {
global ErrArgs MenuHelp TempDir TmpNo
global TkzG
set thisproc "DelItem2"

set TheArcFile $dirname/$arcname
catch {unset xlist}
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
while {[ gets $fl line ] > -1}  {
  lappend xlist [string trim $line]
  }
catch {close $fl}

switch $arcfno    {
    2       {
        set flags "-d"
        set arcpgm "zip"
        }
    default       {
        set ErrArgs [list "Delete-from-Archive"]
        GErrMsgBox 6
        return -1
        }
    }


set ll1 0
set ll2 0
catch {set ll1 [llength $xlist]}
while {$ll2 < $ll1}  {
  set fn [lindex $xlist $ll2]
#set cmd "$arcpgm $flags $TheArcFile $fn >$lstf 2>$errf"
#puts "Trying to exec\n '$cmd'  "
  set rc [catch {exec $arcpgm $flags $TheArcFile $fn >$lstf 2>$errf} cc]
  incr ll2
  }

return $rc
}


#-----------------------------------------------------------------------------
#  Uninstall  --  Uninstall file(s) selected from an archive directory
#-----------------------------------------------------------------------------
proc Uninstall {owner arcname dirname}  {
global ErrArgs MenuHelp ArcWin MainButBg MainBg MainFg WhoBg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg DSlidBg
global EntBg EntFg SelBg SelFg PgmName
global TempDir TmpNo
global TkzG

set thisproc "Uninstall"
if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 53
  return 1
  }

set WBg $TwBg(0)
set WButBg $TwButBg(0)
set WButFg $TwButFg(0)
set WEntBg $EntBg(0)
set WEntFg $EntFg(0)
set WSelBg $SelBg(0)
set WSelFg $SelFg(0)
set WFg $TwFg(0)
set lbg $TwLFg(0)
set lfg $TwLFg(0)

set TheArcFile $dirname/$arcname
# puts "$thisproc:  uninstall req from $owner for $TheArcFile"
set tmp "ArcFno$owner"
global $tmp
set arcfno [set $tmp]
incr TmpNo
set tno $TmpNo
set alist ".$owner.body.alist"
set sellist [$alist curselection]
set flist "$TempDir/TkzFlst$tno"
set lstf "$TempDir/TkzLst$tno"
set errf "$TempDir/TkzErr$tno"
set killist "Kill$owner"
global $killist
set $killist [lappend $killist $lstf $errf $flist]

BuildMbrList $owner "uninstall" $tno $arcfno

#  OK, pop up a where to do it dialogue...
#-------------------------------------------------------------------
#  Make some unique names for us...
incr ArcWin
#set thiswin "uninst$ArcWin"
set thiswin "uninst$owner"
set WinName ".$thiswin"
if {$dirname == "dummy" && $arcname == "dummy"}  {
  set arcname ""
  set dirname [ GetCurDir "$owner" ]
  }
if {$dirname == "/dev"}  {
  GErrMsgBox 15;
  return -1;
  }
set arcn "arcname$thiswin"
global $arcn
set $arcn $arcname

if [catch {toplevel $WinName}] {
  raise $WinName
  } else {
#  Build the window...
  set arctitle "$PgmName: Uninstall Package"
  wm title $WinName $arctitle
  set topf [frame $WinName.top -bg $WBg -highlightbackground $WBg]
  set buttons [frame $topf.but -bg $WBg -highlightbackground $WBg]
  set namef [frame $WinName.top.namef -bg $WBg -highlightbackground $WBg]
#  set typef1 [frame $WinName.top.types.types1 -bg $WBg -highlightbackground $WBg]
#  set typef2 [frame $WinName.top.types.types2 -bg $WBg -highlightbackground $WBg]

  set cmd [list "Uninst2" $owner $thiswin $arcname $dirname "0"]
  button $buttons.test -text "Test" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  bind $buttons.test <3> {ShowHelp 53a}
  set cmd [list "Uninst2" $owner $thiswin $arcname $dirname "1"]
  button $buttons.uninst -text "Uninstall" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  bind $buttons.uninst <3> {ShowHelp 53a}
  set cmd "KillUninst $thiswin"
  button $buttons.quit -text "Cancel" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  bind $buttons.quit <3> {ShowHelp 53a}
#  Gotta intercept wm killing the window with this command too
  wm protocol $WinName "WM_DELETE_WINDOW" $cmd
  wm protocol $WinName "WM_SAVE_YOURSELF" $cmd
  label $namef.where -text "   Directory:  " -relief flat -bg $WBg -fg $WFg
  entry $namef.dir -text " " -relief sunken -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg -width 30 \
  -font "-*-fixed-bold-*-*-*-*-*-*-*-*-*-*-1"
  label $namef.pad -text "    " -bg $WBg -fg $WFg -highlightbackground $WBg

  pack $buttons.test $buttons.uninst $buttons.quit -side left
  pack $namef.where $namef.dir $namef.pad -side left -expand no

#  Now build a file selection list for directory to create in & filename...
  set flbody [ frame $WinName.body  -bg $WBg -highlightbackground $WBg]
  set body $thiswin.body

  set stuff [BuildDirList "$body"]

  pack $flbody -anchor w -fill x -side bottom -fill both -expand yes
  
  pack $namef -side bottom -anchor center 
  pack $buttons -side bottom
 
  pack $topf -side bottom -anchor center -expand yes -fill x

  $flbody.list1.dirlist configure -selectbackground $WSelBg \
    -selectforeground $WSelFg
  $flbody.list2.arclist configure -selectbackground $WSelBg \
    -selectforeground $WSelFg
  set cradir "CraDir$body"
  global $cradir
  set $cradir $dirname
  set cmd "UpdCraDir $body"
  bind $flbody.list1.dirlist <Double-1> $cmd
  $flbody.list1.dirlist configure -selectmode extended
  $flbody.list2.arclist configure -selectmode extended
  set cmd "UpdCraDir2 $thiswin"
  bind $namef.dir <Return> $cmd

  $namef.dir configure -textvariable $cradir
  set $cradir [UpdDirList "$body" "$dirname"]

  }

return
}


#-----------------------------------------------------------------------------
#  Uninst2  --  Uninstall file(s) - part 2
#-----------------------------------------------------------------------------
proc Uninst2 {owner thiswin arcname dirname uninstall}  {
global ErrArgs MenuHelp ArcWin MainButBg MainBg MainFg WhoBg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg DSlidBg
global EntBg EntFg SelBg SelFg PgmName TkzVer
global TempDir TmpNo Home ADWarn
global TkzG


set thisproc "Uninst2"
set TheArcFile $dirname/$arcname
set tmp "ArcFno$owner"
global $tmp
set arcfno [set $tmp]
set tno $TmpNo
set alist ".$owner.body.alist"
set sellist [$alist curselection]
set unlog1 "$Home/$PgmName-Uninstall-Log"
set unlog2 "$TempDir/TkzUlog$tno"
set flist "$TempDir/TkzFlst$tno"
set lstf "$TempDir/TkzLst$tno"
set errf "$TempDir/TkzErr$tno"
set killist "Kill$owner"
global $killist
set $killist [lappend $killist $lstf $errf $flist]
set body "$thiswin.body"
set cradir "CraDir$body"
global $cradir
set whereweare [set $cradir]
set warnd $ADWarn
set warna 1

#  Ok, now do the dirty work...
if {$uninstall}  {
  set deleting "Deleting"
  set succeeded "deleted"
  set notfound "not found, cannot be deleted"
  }  else  {
  set deleting "Testing delete"
  set succeeded "would be deleted"
  set notfound "not found, would not be deleted"
  }
set failed "delete failed"

set rc 0
catch {unset xlist}
if [ catch {set fl [open $flist r]} ]  {
  return -1
  }
if [ catch {set log1 [open $unlog1 a]} ]  {
  return -1
  }
if [ catch {set log2 [open $unlog2 w]} ]  {
  return -1
  }
if {$TkzG(Portable)}  {
  set when [clock format [clock seconds] -format "%c %Z"]
  }  else  {
  set when [exec date]
  }
puts $log1 "\n\n                 $PgmName $TkzVer"
puts $log2 "\n\n                 $PgmName $TkzVer"
puts $log1 "          $when"
puts $log2 "          $when"
puts $log1 "           Uninstall Package Log for"
puts $log2 "           Uninstall Package Log for"
puts $log1 "   $TheArcFile\n"
puts $log2 "   $TheArcFile\n"
puts $log1 "$deleting from :  $whereweare\n"
puts $log2 "$deleting from :  $whereweare\n"
set gotany 0
set gotdirs 0
set success 0
set failure 0

while {[ gets $fl line ] > -1}  {
  incr gotany
  set whynot ""
  if {$warna > -1}  {
    set warna 1
    }
  set file [string trim $line]
  set fnl [string length $file]
  incr fnl -1
  if {[file isdirectory $file] || [string range $file $fnl $fnl] == "/"}  {
    lappend xlist [string trim $line]
    incr gotdirs
    }  else  {
    if {[file exists $file]}  {
      if {$uninstall}  {
        if {$warnd}  {
          set ErrArgs [list $file]
          set wrc [GModMsgBox $owner 107]
#          puts "Warn reply = $wrc"
          if {! $wrc}  {
            set warna 0
#            puts "Don't do it!"
            }  else  {
            switch  $wrc  {
              1      {
                set warna 1
                }
              2      {
                set warnd 0
                set warna -1
                }
              3      {
                set warnd 0
                set warna 1
                }
              4      {
                set warnd 0
                set warna 0
                puts $log1 "  ****  Uninstall terminated at user request."
                puts $log2 "  ****  Uninstall terminated at user request."
                catch {close $log1}
                catch {close $log2}
                set tags ""
                DisplayList $unlog2 "Delete Package Log" 0 ".uninslog" $tags
                if {$TkzG(Portable)}  {
                  catch {file delete -force $unlog2}
                  }  else  {
                  catch {exec rm -f $unlog2}
                  }
                return 0
                }
              default {
                set warna 0
                }
              }
            }
          }  else  {
          if {$warna > -1}  {
            set warna 1
            }
          }
        if {$warna == 1}  {
          set theargs [list $file]
          if {$TkzG(Portable)}  {
            set cmd "file delete -force $theargs"
            }  else  {
            set cmd "exec rm $theargs"
            }
          set rc [catch {eval $cmd} dummy] 
          }  else  {
          set rc 1
          set whynot "(user override)"
          }
        }
      if {$rc == 0}  {
        #  Delete succeeded
        puts $log1 "    $file    $succeeded"
        puts $log2 "    $file    $succeeded"
        incr success
        }  else  {
        #  Delete failed
        puts $log1 "    $file    $failed    $whynot"
        puts $log2 "    $file    $failed    $whynot"
        incr failure
        }
      }  else  {
      #  File doesn't exist
      puts $log1 "    $file    $notfound"
      puts $log2 "    $file    $notfound"
      incr failure
      }
    }
  }
catch {close $fl}
set numfiles [expr $gotany - $gotdirs]

#  Ok to delete directories now...
if {$gotdirs != 0}  {
  puts $log1 "    ------------------------"
  puts $log2 "    ------------------------"
  set ll1 0
  set ll1 $gotdirs
  incr ll1 -1
  #  Reverse traverse the directory list...
  while {$ll1 >= 0}  {
    set whynot ""
    if {$warna > -1}  {
      set warna 1
      }
    set file [lindex $xlist $ll1]
    #-----------------------------
    if {[file exists $file]}  {
set dummy ""
set whynot ""
catch {set dummy [glob $file*]}
      if {$uninstall}  {
#---------------------------
        set dummylist ""
        catch {set dummylist [glob $file*]}
        if {$warnd  && $dummylist == ""}  {
          set ErrArgs [list $file]
          set wrc [GModMsgBox $owner 107]
          if {! $wrc}  {
            set warna 0
            }  else  {
            switch  $wrc  {
              1      {
                set warna 1
                }
              2      {
                set warnd 0
                set warna -1
                }
              3      {
                set warnd 0
                set warna 1
                }
              4      {
                set warnd 0
                set warna 0
                puts $log1 "  ****  Uninstall terminated at user request."
                puts $log2 "  ****  Uninstall terminated at user request."
                catch {close $log1}
                catch {close $log2}
                set tags ""
                DisplayList $unlog2 "Delete Package Log" 0 ".uninslog" $tags
                if {$TkzG(Portable)}  {
                  catch {file delete -force $unlog2}
                  }  else  {
                  catch {exec rm -f $unlog2}
                  }
                return 0
                }
              default {
                set warna 0
                }
              }
            }
          }  else  {
          if {$warna > -1}  {
            set warna 1
            }
          }
#---------------------------
       #-----------
#        puts "Directory $file contents:\n    <$dummy>"
        if {$warna == 1}  {
          if {$dummylist == ""}  {
            set theargs [list "-rf" $file]
            if {$TkzG(Portable)}  {
              set cmd "file delete -force $file"
              }  else  {
              set cmd "exec rm $theargs"
              }
            set rc [catch {eval $cmd} dummy] 
            }  else  {
            set rc 1
            set whynot "(directory not empty)"
            }
          }  else  {
          set rc 1
          set whynot "(user override)"
          }
       #-----------
        }
      if {$rc == 0}  {
        #  Delete succeeded
        puts $log1 "    $file    $succeeded"
        puts $log2 "    $file    $succeeded"
        incr success
        }  else  {
        #  Delete failed
        puts $log1 "    $file    $failed    $whynot"
        puts $log2 "    $file    $failed    $whynot"
        incr failure
        }
      }  else  {
      #  File doesn't exist
      puts $log1 "    $file    $notfound"
      puts $log2 "    $file    $notfound"
      incr failure
      }
    #-----------------------------
#    incr ll1
    incr ll1 -1
    }
  puts $log1 "    ------------------------"
  puts $log2 "    ------------------------"
  }




puts $log1 "        ($numfiles files,  $gotdirs directories)"
puts $log2 "        ($numfiles files,  $gotdirs directories)"
puts $log1 "\n    Successful deletes:  $success    Failures:  $failure"
puts $log2 "\n    Successful deletes:  $success    Failures:  $failure"
if {! $uninstall}  {
  set msg "    (Successful deletes total, obviously, is meaningless. This\
    \n    was a test run.)"
  puts $log1 $msg
  puts $log2 $msg
  }
catch {close $log1}
catch {close $log2}

set tags ""
DisplayList $unlog2 "Delete Package Log" 0 ".uninslog" ""
if {$TkzG(Portable)}  {
  catch {file delete -force $unlog2}
  }  else  {
  catch {exec rm -f $unlog2}
  }

return 0
}

#-----------------------------------------------------------------------------
#  KillUninst  --  Kill the Uninstall window
#-----------------------------------------------------------------------------
proc KillUninst {owner}  {
global TkzG


PluckFromList $owner "FLList"
set WinName ".$owner"
destroy $WinName

return 1
}

#-----------------------------------------------------------------------------
#  DisplayList  --  Display a file in a listbox window
#-----------------------------------------------------------------------------
proc DisplayList {file title pos winname tags}  {
#global WhoBg MainButBg MainBg MainFg MenuHelp
#global DSlidBg NumWins
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg
global clicky clicky1 clicky2 clickybg1 clickybg2
global PgmName TkzVer
global TkzG


set wnum 102
set hbg $TwBg($wnum)
set hfg $TwFg($wnum)
set hlbg $TwLBg($wnum)
set hlfg $TwLFg($wnum)
set hbutbg $TwButBg($wnum)
set hbutfg $TwButFg($wnum)
set sbg $SlidBg($wnum)
set tcol $TrCol($wnum)

if {$winname == ""}  {
  set win ".listbox"
  }  else  {
  set win $winname
  }

set wintitle "$PgmName:  $title"
set list "$win.ht1"

if [catch {toplevel $win} rc]  {
  $list configure -state normal
  $list delete 0.1 end
  raise $win
  #  Sounds like a good idea, but handling will be inconsistent
  #  among window mgrs, since these are all top-level windows...
  #  let's not go there.
  # focus $win
  }  else  {
  #------------
  # Create the window
  catch {toplevel $win}
  # Define our widgets
  wm title $win $wintitle
  text $win.ht1
  scrollbar $win.sby
  frame $win.f2
  set cmd "destroy $win"
  button $win.f2.hb1 -text "Ok" -bg $hbutbg -fg $hbutfg -command $cmd
  # Tell the window mgr how to put 'em together
  pack $win.f2.hb1
  pack $win.f2 -side top -fill x
  pack $win.sby -side right -fill y
  pack $win.ht1 -fill both -expand yes
  #------------
  }

#-----------------------------------
$win.ht1 configure -fg black
# Now set up the text
# Define some styles
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*
$win.ht1 tag configure reallybig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-180-*-*-*-*-*-*

if [ catch {set if [open $file r]} ]  {
  return -1
  }
while {[ gets $if line ] > -1}  {
  $list insert end "$line\n" normal
#puts "...inserted   '$line'"
  }
catch {close $if}
if {$pos == 1}  {
  $list see end
  }
#-----------------------------------
#  Set some tags for links
set tno 0
set tnum [llength $tags]
if {$tnum > 0}  {
  set tno 0
  set tlist [lindex $tags 0]
  set clist [lindex $tags 1]
  set tnum2 [llength $tlist]
  while {$tno < $tnum2}  {
    set tagt [lindex $tlist $tno]
    set tagc [lindex $clist $tno]
    set tagname "tagn$tno"
    $list tag configure $tagname \
      -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-* \
      -foreground $clicky
    $list tag bind $tagname <1> "$tagc"
    set ind1 [$list search -exact $tagt 1.0 end]
    if {$ind1 != ""}  {
      set i [string first "." $ind1]
      incr i -1
      set tmp1 [string range $ind1 0 $i]
      incr i 2
      set tmp2 [string range $ind1 $i end]
      set i2 [string length $tagt]
      incr tmp2 $i2
      set ind2 "$tmp1.$tmp2"
      $list tag add $tagname $ind1 $ind2
      }
    incr tno
    }
  }

#-----------------------------------
#-----------------------------------
  # Set the other attributes

set ycmd "$win.sby set"
$win.ht1 configure -bg $hlbg -fg $hlfg -wrap word -state disabled \
  -yscroll $ycmd 
if {$win == ".readme"}  {
  $win.ht1 configure -width 86
  }
if {$win == ".uninslog"}  {
  $win.ht1 configure -width 86
  }
if {$win == ".relnote"}  {
  $win.ht1 configure -width 86
  }

$win.f2 configure -bg $hbg
set ycmd "$win.ht1 yview"
$win.sby configure -command $ycmd

set wno 102
ConfigureScrollbar $win.sby $wno 0
#-----------------------------------



return 1
}




#------------------------------------------------------------------
#  SetArcVars  --  based on the generic type, set pgm & flags, etc.
#-----------------------------------------
#  Duhhh...lots of junk to clean out here.
#-----------------------------------------
#------------------------------------------------------------------
proc SetArcVars {owner fno} {
global ArcPgm UnarcPgm ArcFlags ListFlags ViewFlags ExtFlags FTypes ArcFno
global GotTar GotGtar GotGzip GotZip GotZcat GotCompress GotPgm
global GotAr GotArj GotRar GotShn GotBzip GotBzip2 GotLha GotCpio GotRpm
global GotPgmFlags2 NeededPgmFlags2
global TkzG

set thisproc "SetArcVars"
set GotPgm 1
set tartype "Tar Archive"
set plainzip "Zip Archive"
set zipexe "Self-Extracting Zip Executable"
set tarzip "Zipped Tar Archive"
set targzip "GNU-Zipped Tar Archive"
set gziptype "GNU Zipped File"
set comptype "Compressed File"
set comptar "Compressed Tar Archive"
set arfile "Archive/Lib"
set rarfile "RAR Archive"
set arjfile "ARJ Archive"
set shortfile "Shorten File"
set unktype "Unknown File Type"
set bziptype "Bzipped File"
set bziptar "Bzipped Tar Archive"
set bzip2type "Bzipped(v.2) File"
set bzip2tar "Bzipped (v.2) Tar Archive"
set lhatype "LHa (lzh) Archive"
set cpiotype "Cpio Archive"
set rpmtype  "RedHat Pkg Mgr File"
set debtype  "Debian Pkg Mgr File"

set arcpgm "ArcPgm$owner"
set arcpgm2 "ArcPgm2$owner"
set listflags "ListFlags$owner"
set viewflags "ViewFlags$owner"
set extflags "ExtFlags$owner"
set gotpgm "GotPgm$owner"

if {! [info exists $arcpgm] }  {
global $arcpgm
  }
if {! [info exists $arcpgm2] }  {
global $arcpgm2
  }
if {! [info exists $listflags] }  {
global $listflags
  }
if {! [info exists $viewflags] }  {
global $viewflags
  }
if {! [info exists $extflags] }  {
global $extflags
  }
if {! [info exists $gotpgm] }  {
global $gotpgm
  }
set $gotpgm 1


switch $fno {
  1        { 
    set $arcpgm "tar"
    set $arcpgm2 "tar"
    set $listflags "-ztvf"
    set $viewflags "-zxOf"
    set $extflags "-zxvf"
    set arctype $targzip
    if {! $GotTar && ! $GotGtar} {
      set $gotpgm 0
      }
    }
  2        { 
    set $arcpgm "unzip"
    set $arcpgm2 "zip"
    set $listflags "-v"
    set $viewflags "-p"
    set $extflags "-o"
    set arctype $plainzip
    if {! $GotZip} {
      set $gotpgm 0
      }
    }
  3        { 
    set $arcpgm "tar"
    set $arcpgm2 "tar"
    set $listflags "-tvf"
    set $viewflags "-xOf"
    set $extflags "-xvf"
    set arctype $tartype
    if {! $GotTar && ! $GotGtar} {
      set $gotpgm 0
      }
    }
  4        { 
    set $arcpgm "gzip"
    set $arcpgm2 "gzip"
    set $listflags "-l"
    set $viewflags "-c -d"
    set $extflags ""
    set arctype $gziptype
    if {! $GotGzip} {
      set $gotpgm 0
      }
    }
  5        { 
    set $arcpgm "tar"
    set $arcpgm2 "tar"
    set $listflags "-ztvf"
    set $viewflags "-zxOf"
    set $extflags "-zxvf"
    set arctype $comptar
    if {! $GotTar && ! $GotGtar} {
      set $gotpgm 0
      }
    }
  6        {
    #  Use compress or zcat  --  ?
    #  If gzip is present, use it...uncompress is often inclined not
    #  to like files that end in ".taz"
    #  zcat is really quirky on some systems...let's not use it.
    if {$GotGzip}  {
      set $arcpgm "gzip"
      set $viewflags "-c -d"
      }  else  {
      if {$GotCompress}  {
        set $arcpgm "uncompress"
        set $viewflags "-c"
        }  else  {
        set $arcpgm "zcat"
        set $viewflags ""
        }
    }

    set $arcpgm2 "compress"
    set $listflags "-l"
    set $extflags ""
    set arctype $comptype
#    if {! $GotZcat && ! $GotCompress} {
#      set $gotpgm 0
#      }
    if {! $GotCompress && ! $GotGzip} {
      set $gotpgm 0
      }
    }
  7        { 
    set $arcpgm "unzip"
    set $arcpgm2 "zip"
    set $listflags "-v"
    set $viewflags "-p"
    set $extflags "-o"
    set arctype $zipexe
    if {! $GotZip} {
      set $gotpgm 0
      }
    }
  8        { 
    #  This is an obsolete placeholder - used to be a raw device...
    set $arcpgm "tar"
    set $arcpgm2 "tar"
    set $listflags "-ztvf"
    set $viewflags "-zxOf"
    set $extflags "-zxvf"
    set arctype $targzip
    if {! $GotTar && ! $GotGtar} {
      set $gotpgm 0
      }
    }
  9        { 
    #  Old Unix archive (static lib)
    set $arcpgm "ar"
    set $arcpgm2 "ar"
    set $listflags "-t"
    set $viewflags "-x"
    set $extflags "-x"
    set arctype $arfile
    if {! $GotAr} {
      set $gotpgm 0
      }
    }
  10        { 
    #  ARJ archive
    set $arcpgm "unarj"
    #  Doesn't exist...
    set $arcpgm2 "arj"
    set $listflags "l"
    set $viewflags "x"
    set $extflags "x"
    set arctype $arjfile
    if {! $GotRar} {
      set $gotpgm 0
      }
    }
  11        { 
    #  RAR archive...
    set $arcpgm "unrar"
    #  Doesn't exist...
    set $arcpgm2 "rar"
    set $listflags "l"
    set $viewflags "x"
    set $extflags "x"
    set arctype $rarfile
    if {! $GotArj} {
      set $gotpgm 0
      }
    }
  12        { 
    #  Shorten file...
    set $arcpgm "shorten"
    set $arcpgm2 "shorten"
    set $listflags "-x"
    set $viewflags "-x"
    set $extflags "-x"
    set arctype $shortfile
    if {! $GotShn} {
      set $gotpgm 0
      }
    }
  13        { 
    #  Bzip file...
    set $arcpgm "bzip"
    set $arcpgm2 "bzip"
    set $listflags ""
    set $viewflags "-c -d"
    set $extflags "-c -d"
    set arctype $bziptype
    if {! $GotBzip} {
      set $gotpgm 0
      }
    }
  14        { 
    set $arcpgm "bzip"
    set $arcpgm2 "bzip"
    set $listflags ""
    set $viewflags "-c -d"
    set $extflags "-c -d"
    set arctype $bziptar
    if {! $GotTar && ! $GotGtar} {
      set $gotpgm 0
      }
    }
  15        { 
    set $arcpgm "lha"
    set $arcpgm2 "lha"
    set $listflags "-v"
    set $viewflags "-x"
    set $extflags "-x"
    set arctype $lhatype
    if {! $GotLha} {
      set $gotpgm 0
      }
    }
  16        { 
    set $arcpgm "cpio"
    set $arcpgm2 "cpio"
    set $listflags "-tv"
    set $viewflags "-i"
    set $extflags "-i"
    set arctype $cpiotype
    if {! $GotCpio} {
      set $gotpgm 0
      }
    }
  17        { 
    #  Bzip2 file...
    set $arcpgm "bzip2"
    set $arcpgm2 "bzip2"
    set $listflags ""
    set $viewflags "-c -d"
    set $extflags "-c -d"
    set arctype $bzip2type
    if {! $GotBzip2} {
      set $gotpgm 0
      }
    }
  18        { 
    set $arcpgm "bzip2"
    set $arcpgm2 "bzip2"
    set $listflags ""
    set $viewflags "-c -d"
    set $extflags "-c -d"
    set arctype $bzip2tar
    if {! $GotTar && ! $GotGtar} {
      set $gotpgm 0
      }
    }
 19        { 
    set $arcpgm "cpio"
    set $arcpgm2 "cpio"
    set $listflags "-tv"
    set $viewflags "-i"
    set $extflags "-i"
    set arctype $rpmtype
    if {! $GotCpio} {
      set $gotpgm 0
      }
    }
  default  {
    set $arcpgm "NoSuchPgm"
    set $listflags "-ztvf"
    set $viewflags "-zxOf"
    set $extflags "-zxvf"
    set arctype $unktype
    set $gotpgm 0
    }
  }

if {$TkzG(Debug)}  {
#  puts "$thisproc: for type $fno -    ArcPgm:     $arcpgm = [set $arcpgm]" 
#  puts "                             ViewFlags:  $viewflags = [set $viewflags]" 
  }

return $arctype
}


#--------------------------------------------------
#  ViewItem  --  extract a file from arc & view
#    -- list handling changed to accommodate spacey
#       Win95 style filenames
#--------------------------------------------------
proc ViewItem {WinName arcname arcdir} {
global PgmName PgmNamelc ArcPgm ViewFlags ErrArgs TkzVer MainBg MainFg MainButBg MyPid TmpNo TempDir
global MenuHelp
global MimeNum MimeTags MimeTypes MimeViewers GotGtar GtRel
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 22
  return 1
  }

set thisproc "ViewItem"
set thiswin $WinName
set owner $thiswin
set viewbin "vbin$WinName"
global $viewbin
set vbin [set $viewbin]
set killist "Kill$WinName"
global $killist
incr TmpNo
set tno $TmpNo
set tmpf "$TempDir/TkzTmp$tno"
# Make it a dir instead, and use flist...
set flist "$TempDir/TkzFlst$tno"
#set flist2 ""
set tmpd "$TempDir/TkzTmp$tno"
set errf "$TempDir/TkzErr$tno"
set $killist [lappend $killist $errf $flist]
set spacey1 0
set rc 0
set where [pwd]
if {$vbin == ""}  {
  GErrMsgBox 4
  return -1
  }

set tmp "ArcPgm$WinName"
global $tmp
set arcpgm [set $tmp]
set tmp "ViewFlags$WinName"
global $tmp
set viewflags [set $tmp]
set tmp "ArcFno$WinName"
global $tmp
set arcfno [set $tmp]
set tmp "spacey$thiswin"
global $tmp
set spacey [set $tmp]


set alist ".$WinName.body.alist"
if {[$alist curselection] == ""}  {
  set ErrArgs [list $arcname]
  GErrMsgBox 7
  return -1
  }

#===============================================================
#  New stuff...  temp file extraction removed to a common func -
#  1.0.15.
#===============================================================
TmpExt $owner $arcdir $arcname
set tmp "TVDir$owner"
global $tmp
set tmpd [set $tmp]
set tmp "Flist2$owner"
global $tmp
set flist2 [set $tmp]

#  Temp files are extracted...
#  figure out what to use to view them.


#  Kluge for now...only pass 1 to ourselves -- we'll fix later!
# set tmpf [lindex $flist2 0]
# set tmpf "$tmpd/$tmpf"
#
#  If the viewer is ourselves, just do an internal call.
#  ...and ignore any opts they may have tried to set.
 set pgm [lindex $vbin 0]
#-----------
#  First part of mailcap-style viewing...
#  Check file for any types we handle internally; if it's one,
#  just call ourselves.
#  The check for recognized MIME types, pluck those from list
#  and handle separately. Anything remaining in list uses the
#  default (selected) viewer and the old logic.
set mimenum 0
#  Here we have to address Win95 style spacey names. Major rewriting done.
if {$TkzG(IntView)}  {
  catch { unset flist3 }

#-------------------------
    set ll1 0
    set ll2 0
    catch {set ll1 [llength $flist2]}
    while {$ll2 < $ll1}  {
      set tmpf [lindex $flist2 $ll2]
      set tmpf2 "$tmpd/$tmpf"
      if {! [file exists $tmpf2]}  {
        set ErrArgs [list "dummy" "$tmpf2"]
        GErrMsgBox 92
        incr ll2
        continue
        }
      set lsl [string last "/" $tmpf2]
      if {$lsl < 0}  {
        set theDir [pwd]
        set theFile $tmpf2
        }
      if {$lsl == 0}  {
        set theDir "/"
        set theFile [string range $tmpf2 1 end]
        }
      if {$lsl > 0}  {
        set theDir [string range $tmpf2 0 [expr $lsl - 1]]
        set theFile [string range $tmpf2 [expr $lsl + 1] end]
        }
      set vftype [ArcType2 "DummyWin" $theDir $theFile 0 0]
      if {$vftype == "Unknown File Type" || $vftype == " "}  {
        lappend flist3 $tmpf
        }  else  {
        DispArc $theDir $theFile 0 0
        }
      incr ll2
      }
#-------------------------
#  set flist2 [string trim $flist3]
  if [catch {llength $flist3}]  {
    return 1
    }
  set flist2 $flist3

  #  Now handle MIME types
  catch {unset flist3}
#-------------------------
  set ll1 0
  set ll2 0
  catch {set ll1 [llength $flist2]}
    while {$ll2 < $ll1}  {
    set tmpf [lindex $flist2 $ll2]
    set vftype [CheckMime $tmpd $tmpf]
    if {$vftype == -1}  {
      lappend flist3 $tmpf
      }  else  {
      set mimev $MimeViewers($vftype)
      set vi 0
      set vfound 0
      while {$vi < $mimenum && ! $vfound}  {
        if {$mimev == $mv($vi)}  {
          lappend mlist($vi) $tmpf
          set vfound 1
          }  else  {
          incr vi
          }
        }
      if {$vi == $mimenum}  {
        set mv($vi)  $mimev
        lappend mlist($vi) $tmpf
        incr mimenum
        }
      }
    incr ll2
    }
#-------------------------

  #  Now invoke any MIME type viewers.
  set where [pwd]
  cd $tmpd
  set vi 0
  while {$vi < $mimenum}  {
    set mimev $mv($vi)
#------------
    if {$TkzG(Vpn)}  {
     catch {unset flist3}
     set ll1 0
     set ll2 0
     catch {set ll1 [llength $mlist($vi)]}
     while {$ll2 < $ll1}  {
       set file [lindex $mlist($vi) $ll2]
       lappend flist3 "$tmpd/$file"
       incr ll2
       }
     set mlist($vi) $flist3
      }
    set cmd $mimev
    if {! $spacey1}  {
      set flist4 ""
      set ll1 0
      set ll2 0
      catch {set ll1 [llength $mlist($vi)]}
      while {$ll2 < $ll1}  {
#        set flist4 "$flist4 [lindex $mlist($vi) $ll2]"
        lappend flist4 [lindex $mlist($vi) $ll2]
#  New...
if {$TkzG(FastClean)}  {
set $killist [lappend $killist "$tmpd/[lindex $mlist($vi) $ll2]"]
  }
        incr ll2
        }
#      set flist4 [string trim $flist4]
      set dummy [SpawnViewer "$spacey" "$mimev" "$flist4"]
      }  else  {
      set ll1 0
      set ll2 0
      catch {set ll1 [llength $mlist($vi)]}
      while {$ll2 < $ll1}  {
        set file [list [lindex $mlist($vi) $ll2]]
#        set file [list $file]
        set dummy [SpawnViewer "$spacey" "$mimev" "$file"]
        incr ll2
        }
      }
#------------
    incr vi
    }
  cd $where
#-------------------------

  #  If nothing left in the list, get out.
  set ll1 0
  catch {set ll1 [llength $flist3]}
  if {$ll1 == 0}  {
    return 1
    }
  set flist2 $flist3
  }

#  End of internal viewer handling
#
#  Gawd, that's convoluted!
#
#-----------

#  Eventually, merge the old logic below with the new stuff above.
#  For now, we leave it to support the old-style of invoking
#  TkZip itself as an "external" viewer and calling it internally.

 if {$pgm == $PgmName || $pgm == $PgmNamelc}  {
    #--------------
#-------------------------
    set ll1 0
    set ll2 0
    catch {set ll1 [llength $flist2]}
    while {$ll2 < $ll1}  {
      set tmpf [lindex $flist2 $ll2]
        set tmpf "$tmpd/$tmpf"
        if {! [file exists $tmpf]}  {
          set ErrArgs [list "dummy" "$tmpf"]
          GErrMsgBox 92
          incr ll2
          continue
          }
      #  Gotta split the filename from the directory path...bummer!
      #  Why did I think that was useful on intial entry?
      set lsl [string last "/" $tmpf]
      if {$lsl < 0}  {
        set theDir [pwd]
        set theFile $tmpf
        }
      if {$lsl == 0}  {
        set theDir "/"
        set theFile [string range $tmpf 1 end]
        }
      if {$lsl > 0}  {
        set theDir [string range $tmpf 0 [expr $lsl - 1]]
        set theFile [string range $tmpf [expr $lsl + 1] end]
        }
      DispArc $theDir $theFile 0 0
      incr ll2
      }
    #--------------
   }  else  {
   #  Otherwise, spawn an external viewer...
   #  Probably should have an option to suppress this killist stuff.
   #  May have a bad effect on, for example, a sound or video player.
   if {$TkzG(FastClean)}  {
     set $killist [lappend $killist $tmpf]
     }

   set where [pwd]
   cd $tmpd

# --  Need to add parsing for opts - new syntax:
#     pgmname -opts $*    (not really needed)
#     pgmname -opts$*     (needed; for example,  edith -b$*)
#
   if {$TkzG(Vpn)}  {
     catch {unset flist3}
     set ll1 0
     set ll2 0
     catch {set ll1 [llength $flist2]}
    
     while {$ll2 < $ll1}  {
       lappend flist3 "$tmpd/$file"
       }
     catch {set flist2 $flist3}
     }
   set cmd "$vbin"
#   if {$spacey}  {
#     set dummy [SpawnViewer "$spacey" "$vbin" "$flist2"]
#     }  else  {
#     set dummy [SpawnViewer "$spacey" "$vbin" "$flist2"]
#     }
    if {! $spacey1}  {
      set flist4 ""
      set ll1 0
      set ll2 0
      catch {set ll1 [llength $flist2]}
      while {$ll2 < $ll1}  {
        set file [lindex $flist2 $ll2]
        if {! [file exists $file]}  {
          set ErrArgs [list "dummy" "$file"]
          GErrMsgBox 92
          incr ll2
          continue
          }
#        set flist4 "$flist4 $file"
        lappend flist4 $file
        if {$TkzG(Vpn)}  {
          set $killist [lappend $killist $file]
          }  else  {
          set $killist [lappend $killist "$tmpd/$file"]
          }
        incr ll2
        }
#      set flist4 [string trim $flist4]
      if {$flist4 != ""}  {
        set dummy [SpawnViewer "$spacey" "$vbin" "$flist4"]
        }
      }  else  {
      set ll1 0
      set ll2 0
      catch {set ll1 [llength $flist2]}
      while {$ll2 < $ll1}  {
        set file [list [lindex $flist2 $ll2]]
        if {! [file exists $file]}  {
          set ErrArgs [list "dummy" "$file"]
          GErrMsgBox 92
          incr ll2
          continue
          }
#        set file [list $file]
        set dummy [SpawnViewer "$spacey" "$vbin" "$file"]
        incr ll2
        }
      }
   cd $where
   }
 cd $where


return 1
}


#----------------------------------------------------------------
#  TmpExt  --  Extract temporary copies of files selected
#              for viewing
#----------------------------------------------------------------
proc TmpExt {owner dirname arcname} {
global ErrArgs TmpNo TempDir
global TkzG
set thisproc "TmpExt"

#set thiswin $owner
#set WinName $owner

set tmp "ArcFno$owner"
global $tmp
set arcfno [set $tmp]

set killist "Kill$owner"
global $killist
incr TmpNo
set tno $TmpNo
#set tmpf "$TempDir/TkzTmp$tno"

# Make it a dir instead, and use flist...
set flist "$TempDir/TkzFlst$tno"

set flist2 ""
set tmpd "$TempDir/TkzTmp$tno"
set errf "$TempDir/TkzErr$tno"
set $killist [lappend $killist $errf $flist]

#==== new ====
set tmp "TVDir$owner"
global $tmp
set $tmp $tmpd
set tmp "Flist$owner"
global $tmp
set $tmp $flist

set tmp "Flist2$owner"
global $tmp
set $tmp ""
#==== new ====

set rc 0
set where [pwd]
#====================================================================
set alist ".$owner.body.alist"
if {[$alist curselection] == ""}  {
  return -1
  }
set item1ind [lindex [$alist curselection] 0]

set sellist [$alist curselection]
if {! $TkzG(MultView)}  {
  set sellist [lindex $sellist 0]
  }
#====================================================================
#  The file list loop...

set ff [open $flist w]

foreach filind $sellist {
#------------------
  set tmp1 [$alist get $filind $filind]
  #  Account for symlinks (different pgms say it differently)...
  #  gotta do this first, because it affects locating the filename.
  set tmpi [string first "->" $tmp1]
  set tmpi2 [string first "link to" $tmp1]
  #  Just say no to symlinks...
  if {$tmpi != -1 || $tmpi2 != -1}  {
    #  unrar sometimes has a "-->" in the compression ratio field (I think
    # it's in the case of multi-part archives).
    if {$arcfno != 11}  {
      continue
    }  else  {
    if {[string first "-->" $tmp1] == -1}  {
      continue
      }
    }
    }
#------------------
  #  Depending on file type, the filename may be the last field,
  #  or the first, or who-knows-what for newly added formats...
  switch    $arcfno        {
    10             -
    11             {
       #  ARJ & RAR have filename at beginning...
       set file [string trim [lindex [lindex $tmp1 0] 0]]
       }
    2              -
    7              {
       #  Hack for locating spacey Win95-style filenames in a zip - part 1...
       #  - but viewing has a second problem - the complex multiple list 
       #    handling for different viewers would all have to be redone...
       #    maybe for a future release.
       set file [string trim [lrange [lindex $tmp1 0] 7 end]]  
       }
    1              -
    3              -
    5              -
    14             -
    18             {
       set tmp "tartype$owner"
       global $tmp
       set tartype [set $tmp]
       set tni $tartype
#       set tni 7
#       if {$GotGtar && $GtRel > "1.11.8"}  {
#         set tni 5
#         }  else  {
#         if {[string trim [lrange [lindex $tmp1 0] $tni end]] == ""}  {
#           set tni 5
#           }
#         }
       set file [string trim [lrange [lindex $tmp1 0] $tni end]]
       }
    9              {
       set file [string trim [lrange [lindex $tmp1 0] 0 end]]  
       }
    15              {
       set file [string trim [lrange [lindex $tmp1 0] 10 end]]  
       }
    16              -
    19              {
       set file [string trim [lrange [lindex $tmp1 0] 6 end]]  
       }
    default        {
       #  Most have filename at the end (*or* it's the only field).
       set file [string trim [lindex [lindex $tmp1 0] end]]
       }
    }
#------------------
#  1.0.6 - Account for a major bogosity that occurs if there's a "$" 
#  in the filename - we get a list instead of a simple string, so we
#  have to convert it back. (Noticed this trying to browse one of the
#  jars in the JFC 1.0.1 distribution.)
if {[string first "\$" $file] != -1}  {
  set tmpi 0
  set tmpi2 [llength $file]
  set tmpf2 ""
  while {$tmpi < $tmpi2}  {
    set tmpf2 "$tmpf2 [lindex $file $tmpi]"
    incr tmpi
    }
  set file [string trim $tmpf2]
  }

#------------------
  #  ...and don't include directories 
  set tmpi [string last "/" $file]
  incr tmpi
  if {$file != "" && $tmpi != [string length $file]}  {
    #-----------------------------------
    #  Right here we have to strip the filename from path and add
    #  to our list to pass to viewer...
    #-----------------------------------
    set tmp [string range $file $tmpi end]
#   Change to proper list handling for spacey filenames
#    set flist2 [string trim "$flist2 $tmp"]
    lappend flist2 [string trim $tmp]

    puts $ff $file
    }
#------------------

  }
catch { [close $ff] }
#==== new ====
set tmp "Flist2$owner"
set $tmp $flist2
#==== new ====

#====================================================================
#  OK, now the file list's built. Now what?
#  Guess we have to extract some stuff, huh?
#

if {$TkzG(Portable)}  {
  catch {file mkdir $tmpd}
  }  else  {
  catch {exec mkdir $tmpd}
  }



switch $arcfno       {
      1            -
      5            -
      14           -
      18           {
        #  Gzipped, compressed, or bzipped TAR archive
#        set item1 [lindex [$alist get [lindex [$alist curselection] 0] ] end]
        set rc [GetVTar $owner $dirname $arcname $flist $tmpd $errf]
        }
      2           -
      7           {
        #  ZIP archive
#        set item1 [lindex [$alist get [lindex [$alist curselection] 0] ] end]
        set rc [GetVZip $owner $dirname $arcname $flist $tmpd $errf]
        }
      3           {
        #  TAR archive
#        set item1 [lindex [$alist get [lindex [$alist curselection] 0] ] end]
        set rc [GetVTar $owner $dirname $arcname $flist $tmpd $errf]
        }
      4           {
        #  Gzipped file
#        set item1 [lindex [$alist get [lindex [$alist curselection] 0] ] end]
        set rc [GetVGzp $owner $dirname $arcname $flist $tmpd $errf]
        }
      6           {
        #  Compressed file
#        set item1 [lindex [$alist get [lindex [$alist curselection] 0] ] end]
        set rc [GetVCmp $owner $dirname $arcname $flist $tmpd $errf]
        }
      9           {
        #  AR archive/lib
#        set item1 [lindex [$alist get [lindex [$alist curselection] 0] ] 0]
        set rc [GetVAr $owner $dirname $arcname $flist $tmpd $errf]
        }
      10          {
        #  ARJ archive
#        set item1 [lindex [$alist get [lindex [$alist curselection] 0] ] 0]
        #  unarj often incorrectly displays file name as all upper when it will
        #  extract a lower-case filename. Bummer.
#        set item1 [string tolower $item1]
        set rc [GetVArj $owner $dirname $arcname $flist $tmpd $errf]
        }
      11          {
        #  RAR archive
#        set item1 [lindex [$alist get [lindex [$alist curselection] 0] ] 0]
        set rc [GetVRar $owner $dirname $arcname $flist $tmpd $errf]
        }
      12          {
        #  SHN (shorten) file
#        set item1 [lindex [$alist get [lindex [$alist curselection] 0] ] 0]
        set rc [GetVShn $owner $dirname $arcname $flist $tmpd $errf]
        }
      13          -
      17          {
        #  Bzipped file
#        set item1 [lindex [$alist get [lindex [$alist curselection] 0] ] 0]
        set rc [GetVBzip $owner $dirname $arcname $flist $tmpd $errf]
        }
      15          {
        #  LHarc archive
#        set item1 [lindex [$alist get [lindex [$alist curselection] 0] ] end]
        set rc [GetVLha $owner $dirname $arcname $flist $tmpd $errf]
        }
      16          -
      19          {
        #  Cpio archive
#        set item1 [lindex [$alist get [lindex [$alist curselection] 0] ] end]
        set rc [GetVCpio $owner $dirname $arcname $flist $tmpd $errf]
        }
      default     {
        #  This is the old style logic - works for all the old types...
#        set item1 [lindex [$alist get [lindex [$alist curselection] 0] ] end]
#        set rc [catch {exec $arcpgm $viewflags $dirname/$arcname $item1 >$tmpf 2>$errf} cc]
        set rc -100
        }
      }


if {$rc != 0}  {
  if {$rc == 85}  {
    return -1
    }
#  obsolete...
  }

#====================================================================
#  I don't want to go jumping to concussions, but I think we're done
#  with this crap. What do we pass back? We need the dir name...
#



#====================================================================

#====================================================================

#====================================================================

#====================================================================





return 1
}



#----------------------------------------------------------------
#  SpawnViewer  --  Build command and spawn viewer
#       The viewer command has to be parsed out into individual
#    args. Ditto the filename(s). Then build the command line as
#    a proper list. Old-style "$*" syntax supported only for a
#    single non-spacey filename.
#----------------------------------------------------------------
proc SpawnViewer {spacey viewer file} {
global ErrArgs
global TkzG
set thisproc "SpawnViewer"


#  New handling - build the cmd line rigorously, arg by arg.
if {[string first "$*" $viewer] == -1}  {
  set cmd [list "exec"]
  set vlnum [llength $viewer]
  set i 0
  while {$i < $vlnum}  {
    lappend cmd [lindex $viewer $i]
    incr i
    }
  set vlnum [llength $file]
  set i 0
  while {$i < $vlnum}  {
    lappend cmd [lindex $file $i]
    incr i
    }
  lappend cmd "&"
  if [catch  {set dummy [eval $cmd]}]  {
    set ErrArgs [list $viewer $file]
    GErrMsgBox 90
    return -1
    }
  return 1
  }


#  The old handling...only used for those "$*" viewer specs,
#  and then only for a single non-spacey filename.
if {[string first " " $file] != -1 || [llength $file] > 1}  {
    set ErrArgs [list $viewer]
    GErrMsgBox 73
    return -1
  }
set cmd $viewer
if {[string last "\$*" $cmd] == -1}  {
  set cmd "$cmd \$*"
  }
set tmpi [string last "\$*" $cmd]
while {$tmpi != -1}  {
  incr tmpi -1
  set tmpc [string range $cmd 0 $tmpi]
  incr tmpi 3
  set tmpc2 [string range $cmd $tmpi end]
  set cmd "$tmpc$file$tmpc2"
  set tmpi [string last "\$*" $cmd]
  }
set cmd "exec $cmd &"
#puts "$thisproc:  trying old-fashioned cmd <$cmd>"
if [catch  {set dummy [eval $cmd]}]  {
  set ErrArgs [list $viewer $file]
  GErrMsgBox 90
  return -1
  }
return 1
}


#-----------------------------------------------------------
#  CheckMime  --  Check the file for a recognized MIME type
#    - a thought...should we have an option for exact, total
#    match? - to catch something like "data" but not
#    "JPEG image data"
#-----------------------------------------------------------
proc CheckMime {dirname fname} {
global MimeNum MimeTags MimeExtns MimeTypes MimeViewers
global TkzG

set thisproc "CheckMine"
set type -1
set rc [catch {set dummy [exec file $dirname/$fname ]} cc]
set tmp "$dirname/$fname:"
set i [string first $tmp $cc]
if {$i != -1}  {
  set tmpl [string length $tmp]
  set cc [string range $cc $tmpl end]
  }
set cc [string trim $cc]
set i 0
set found 0
while {$i < $MimeNum && ! $found}  {
  set mtag [string trim $MimeTags($i)]
  set mext [string trim $MimeExtns($i)]
  set mimev [string trim $MimeViewers($i)]
  #  Don't bother if no viewer defined...
  if {$mimev != ""}  {
    #  First try file probe.
    if {$mtag != ""}  {
      if { [string first $mtag $cc] != -1 }  {
        set found 1
        set type $i
        }
      }
    #  Ok, if that didn't work, try deprecated extension method.
    if {! $found}  {
      if {$mext != ""}  {
        set extnloc [string last $mext $fname]
        set fnlen [string length $fname]
        set extlen [string length $mext]
        set fnlen [expr $fnlen - $extlen]
        if {$fnlen != -1 && $fnlen == $extnloc}  {
          set found 1
          set type $i
          }
        }
      }
    }

  incr i
  }
return $type
}



#----------------------------------------------------
#  SetViewer  --  set the viewer to use for this file
#----------------------------------------------------
proc SetViewer {WinName arcname arcdir vn} {
global VNames VBins VNum
global MenuHelp
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 26
  return 1
  }

set vdp "VDPending$WinName"
global $vdp
set delflag [set $vdp]
if {$delflag}  {
  DeleteViewer $WinName $arcname $arcdir $vn
  return 1
  }

set thisproc "SetViewer"
set viewer "vnam$WinName"
set viewbin "vbin$WinName"
set viewnum "vnum$WinName"
set vbname ".$WinName.top.vopt.vname"
set vbentry ".$WinName.top.vopt.vbin"
set menu ".$WinName.top.but.selv.m"
global $viewer $viewbin $viewnum

if {$vn == $VNum}  {
  $vbname configure -state normal
  $vbentry configure -state normal
  }  else  {
  $vbname configure -state disabled
  $vbentry configure -state disabled
  }
set $viewer $VNames($vn)
set $viewbin $VBins($vn)

return 1
}


#----------------------------------------------------
#  AddViewer  --  add a user-selected viewer to list 
#----------------------------------------------------
proc AddViewer {WinName arcname arcdir} {
global VNames VBins VNum ViewButtons
global TkzG

set thisproc "AddViewer"
set viewer "vnam$WinName"
set viewbin "vbin$WinName"
set vbname ".$WinName.top.vopt.vname"
set vbentry ".$WinName.top.vopt.vbin"
global $viewer $viewbin 



    set label "[set $viewer]"
    set bin "[set $viewbin]"
    # "Nothing will come of nothing."  - King Lear, I, 1  
    if {[string trim "$bin" " "] != ""}  {
      $vbname configure -state disabled
      $vbentry configure -state disabled
      set ovn $VNum
      incr VNum
      set nvn $VNum
      if {$label == "User defined"}  {
        set label "$bin"
        }

#  Update menu for all active views...
      foreach buttons "$ViewButtons"  {
        #  Have to extract win name from buttons - 
	set wn [string range "$buttons" 1 [expr [string last ".top.but" "$buttons"] - 1]]
        set menu "$buttons.selv.m"
        set VNames($ovn) "$label"
        set VBins($ovn) "$bin"
        set VNames($nvn) "User defined"
        set VBins($nvn) ""
        #  A nasty little hack because 4.0 propagates the visual checked state of the last 
	#  radiobutton in the menu - so delete & re-add the little sucker...
#	$menu delete $ovn
#        $menu add radiobutton -label "$label" -command "SetViewer $wn $arcname $arcdir $ovn" \
#          -indicatoron 1
        #  OK, enough - just hide the damned things. Should have used plain old buttons.
        $menu add radiobutton -label "User defined" -command "SetViewer $wn $arcname $arcdir $nvn" \
          -indicatoron 0
        $menu entryconfigure $ovn -label "$label"
        }

      } 

return 1
}


#----------------------------------------------------
#  SetViewerDelete  --  set viewer deletion pending...
#----------------------------------------------------
proc SetViewerDelete {owner} {
global VNames VBins VNum
global MenuHelp
global TkzG

set vdp "VDPending$owner"
global $vdp
set $vdp 1

}


#----------------------------------------------------
#  DeleteViewer  --  delete the clicked viewer
#----------------------------------------------------
proc DeleteViewer {owner arcname arcdir vn} {
global VNames VBins VNum ViewButtons
global MenuHelp VDWarn ErrArgs
global TkzG

set thisproc "DeleteViewer"
set vdp "VDPending$owner"
global $vdp
set $vdp 0

#  Never delete "User defined"...
if {$vn == $VNum || $vn < 1}  {
  return 1
  }

#  Do the warning thing till the user gets tired of that...
if {$VDWarn}  {
  set ErrArgs [list $VBins($vn)]
  set rc [GModMsgBox $owner 103]
  if {! $rc}  {
    return 1
    }
  }

#  Disable the menus while we work...
foreach buttons "$ViewButtons"  {
  #  Have to extract win name from buttons - 
  set wn [string range "$buttons" 1 [expr [string last ".top.but" "$buttons"] - 1]]
  set mb "$buttons.selv"
  $mb configure -state disabled
  }

#  We'll want to reset the selected viewer name if it's the one we're deleting...
set TheViewer $VNames($vn)
set TheBinary $VBins($vn)

#  Now update the list...
set vn1 $vn
set vn2 $vn1
incr vn2
while {$vn1 < $VNum}  {
  set VNames($vn1) $VNames($vn2)
  set VBins($vn1) $VBins($vn2)
  incr vn1
  incr vn2
  }
unset VNames($VNum)
unset VBins($VNum)
incr VNum -1

#  OK, it's gone from the list. Now update all the active menus (groan...)
foreach buttons "$ViewButtons"  {
  #  Have to extract win name from buttons - 
  set wn [string range "$buttons" 1 [expr [string last ".top.but" "$buttons"] - 1]]
  set mb "$buttons.selv"
  set menu "$buttons.selv.m"
  set vn1 $vn

  while {$vn1 <= $VNum}  {
    $menu entryconfigure $vn1 \
      -label "$VNames($vn1)" -command "SetViewer $wn $arcname $arcdir $vn1" \
      -indicatoron 0
    incr vn1
    }
  $menu delete $vn1
  $mb configure -state normal

  #  If deleted viewer was selected for this window, reset selection
  set viewer "vnam$wn"
  set viewbin "vbin$wn"
  set vbname ".$wn.top.vopt.vname"
  set vbentry ".$wn.top.vopt.vbin"
  global $viewer $viewbin 
  set label "[set $viewer]"
  set bin "[set $viewbin]"
  if {$label == $TheViewer && $bin == $TheBinary}  {
    set $viewer $VNames(1)
    set $viewbin $VBins(1)
    }

  }

return 1
}


#----------------------------------------------------
#  SetButton3VD  --  Bind Button-3 to Viewer Delete
#                    for all open windows
#----------------------------------------------------
proc SetButton3VD {}  {
#global VNames VBins VNum
#global MenuHelp 
global ViewButtons Button3VD
global TkzG

#set vdp "VDPending$owner"
#global $vdp
#set $vdp 1

foreach buttons $ViewButtons  {
  set wn [string range "$buttons" 1 [expr [string last ".top.but" "$buttons"] - 1]]
  set mb "$buttons.selv"
  set menu "$buttons.selv.m"
  if {$Button3VD}  {
    set cmd "SetViewerDelete $wn"
    bind $menu <3> $cmd
    }  else  {
    bind $menu <3> ""
    }
  }


}



#------------------------------------------------
#  ExtractItems  --  extract files from arc
#------------------------------------------------
proc ExtractItems {WinName arcname arcdir} {
global PgmName ArcPgm ErrArgs TkzVer WhoBg MainBg MainFg MainButBg ExtWin CurExtDir ExtDirSel
global ViewFlags ExtFlags MyPid TmpNo TempDir Home
global ForceStat MenuHelp ExtDirs GotGtar GtRel
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg DSlidBg
global EntBg EntFg SelBg SelFg
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 23
  return 1
  }

set thisfunc "ExtractItems"
set thisproc "ExtractItems"
incr ExtWin
set this "Ext$ExtWin"
set this "$WinName$this"
set owner "$WinName"
set thiswin ".$this"
set alist ".$WinName.body.alist"

set WBg $TwBg(0)
set WButBg $TwButBg(0)
set WButFg $TwButFg(0)
set WEntBg $EntBg(0)
set WEntFg $EntFg(0)
set WSelBg $SelBg(0)
set WSelFg $SelFg(0)
set WFg $TwFg(0)
set lbg $TwLFg(0)
set lfg $TwLFg(0)

set tmp "ArcPgm$WinName"
global $tmp
set arcpgm [set $tmp]
set tmp "ExtFlags$WinName"
global $tmp
set extflags [set $tmp]
set tmp "ArcType$WinName"
global $tmp
set arctype [set $tmp]
set tmp "ArcFno$WinName"
global $tmp
set arcfno [set $tmp]
set tmp "sdirl$owner"
global $tmp
set $tmp ""
set apn2 "apn2$owner"
global $apn2
set $apn2 0
set jpn2 "jpn2$owner"
global $jpn2
set $jpn2 0

set WarnOverResp 0
set statw ".$WinName.top.vopt.stat"
set stat "Stat$WinName"
global $stat
set $stat "          "
$statw configure -textvariable $stat -fg red

incr TmpNo
set tno $TmpNo
set lstf "$TempDir/TkzLst$tno"
set errf "$TempDir/TkzErr$tno"

set seldir ""
set olddir [ pwd ]
set ExtDirSel 0
set sellist [$alist curselection]

set tarlike 0
if {$arcfno == 1 || $arcfno == 3 || $arcfno == 5 \
    || $arcfno == 14 || $arcfno == 18}  {
  set tarlike 1
  }
#------------------------------
#  Duhhh...  clean this up.
#------------------------------
#  If all are selected, we don't want to waste time with individual selections...
set tmp [llength $sellist]
if { $tmp == [$alist size] && $tmp > 1 }  {
  set selall 1
#  For now, force off for ar, arj, and rar
  if {$arcfno == 9 || $arcfno == 10 || $arcfno == 11}  {
    set selall 0
    }
  }  else  {
  set selall 0
  }
set maybeall $selall
if {$selall}  {
  if {$TkzG(OvWarn) || ! $TkzG(OvOpt)}  {
    set selall 0
    }
  }
#------------------------------

set howmanyl [$alist size]
set howmanys [llength $sellist]
if { [llength $sellist] == 1 }  {
  set justone 1
  }  else  {
  set justone 0
  }

#  Moved dir sel block...
#  Find out where they want to put this stuff

if [catch {toplevel $thiswin}] {
  raise $thiswin
  } else {
  set arctitle "$PgmName: Select Extract-to Directory for:  $arcname"
  wm title $thiswin $arctitle
  set topf [frame $thiswin.top -bg $WBg -highlightbackground $WBg]
  set buttons [frame $topf.but -bg $WBg]
  set archdr [frame $topf.hdr -bg $WBg] 
  set typef [frame $topf.types -bg $WBg -highlightbackground $WBg]
  set typef2 [frame $topf.types.types2 -bg $WBg -highlightbackground $WBg]
  set arcbody [frame $thiswin.body]
  set body "$this.body"

#------------------------------
#  More cd'ing to purge...
#------------------------------
  set cdvar "CurDir$body"
  global $cdvar
  set $cdvar $arcdir
#  Why is this here...?
  if { ! [info exists $cdvar] } {
    global $cdvar
    }
#------------------------------

  set cmd "destroy $thiswin"
  button $buttons.quit -text "Cancel" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  bind $buttons.quit <3> {ShowHelp 23b}
  set cmd "SelDir $this"
  button $buttons.sel -text "Extract" \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg \
    -command $cmd
  bind $buttons.sel <3> {ShowHelp 23b}
  label $archdr.l1 -text "Directory to Extract to: " -bg $WBg -fg $MainFg -width 25
  entry $archdr.where -text " " -relief sunken -bg $WEntBg -fg $WEntFg -width 40 -textvariable $cdvar \
    -font "-*-fixed-bold-*-*-*-*-*-*-*-*-*-*-1"

#--------------------
  set cmd "SetApn2 $typef2"
  checkbutton $typef2.apn2 -variable $apn2 -text "Absolute Path Names" \
    -bg $WBg -fg $WFg -highlightbackground $WBg -command $cmd
  set cmd "SetJpn2 $typef2"
  checkbutton $typef2.jpn2 -variable $jpn2 -text "No Path Names" \
    -bg $WBg -fg $WFg -highlightbackground $WBg -command $cmd

  if {$TkzG(Windows)}  {
    $typef2.apn2 configure -selectcolor $WBg
    $typef2.jpn2 configure -selectcolor $WBg
    }
#--------------------

  pack $buttons.sel $buttons.quit -side left -anchor w -expand no 
  pack $buttons -side top -anchor n -pady 4
  pack $archdr.l1 $archdr.where -side left -fill x -anchor center
  pack $typef2.apn2 $typef2.jpn2 -side left
  pack $typef2 -side bottom

  pack $archdr -fill x -anchor center -pady 2
  pack $typef -side top -fill both -expand yes -pady 2
  pack $topf -anchor w -fill x
  pack $arcbody -anchor w -fill x -side bottom -fill both -expand yes
  

#  Now build a file selection list for extract-to dir...

  set stuff [BuildDirList "$body"]

  $arcbody.list1.dirlist configure -selectbackground $WSelBg \
    -selectforeground $WSelFg
  $arcbody.list2.arclist configure -selectbackground $WSelBg \
    -selectforeground $WSelFg
  set cmd "UpdExtDir $body"
  bind $arcbody.list1.dirlist <Double-1> $cmd
  set cmd "UpdExtDir2 $this"
  bind $archdr.where <Return> $cmd
  bind $typef2.apn2 <3> {ShowHelp 23a}
  bind $typef2.jpn2 <3> {ShowHelp 23a}

  set seldir [UpdDirList "$body" "$arcdir"]
  set tmp "ExtDir$body"
  global $tmp
  set $tmp $seldir
  set tmp "ExtDirSel$this"
  global $tmp
  set $tmp 0

#  The type specifics...
#  Tar supports absolute pathnames (GNU cpio does too,
#  can't be sure of others - 16 & 19 - research this later).
#  We can fake "junk pathnames" in a later release, no time now.
#  Zip and LHarc support no pathnames only
  switch $arcfno  {
    1         -
    3         -
    5         -
    14        -
    18        {
        $typef2.apn2 configure -state normal
#        $typef2.jpn2 configure -state normal
        $typef2.jpn2 configure -state disabled
        }
    2         -
    15        {
        $typef2.apn2 configure -state disabled
        $typef2.jpn2 configure -state normal
        }
    default   {
        $typef2.apn2 configure -state disabled
        $typef2.jpn2 configure -state disabled
        }
    }


  tkwait window $thiswin

  # After this point, none of the selection list vars exists...
  # set dlist ".$body.list1.dirlist"
  # puts "List = $dlist"

PluckFromList $body "FLList"
set tmp "ExtDir$body"
set seldir [set $tmp]
set tmp "ExtDirSel$this"
set extdirsel [set $tmp]


#------------------------------
#  More cd'ing to purge...
#------------------------------
if {$seldir == ""}  {
#  puts "ooooops!"
  set seldir "/"
  }
cd $seldir

#------------------------------

#  Moved dir sel block...
if {$extdirsel}  {
  set $stat "Checking selections"
  $statw configure -fg red -width 26
  update idletasks
  }  else  {
  return 1
  }



#  Build a filelist for extracting  
set flist "$TempDir/TkzFlst$tno"
set flist2 ""
catch {unset flist3}
set flist3 ""
#---------------------------
if {! $selall}  {
set ff [open $flist w]

      set flnum [llength $sellist]
      set flct 0
      set extpercent 0
      foreach filind $sellist {

	      incr flct
#	      set extpct [expr 100 / [expr $flnum / $flct]]
	      set extpct [expr [expr 100 * $flct] / $flnum]
	      if {$extpct != $extpercent}  {
	        set extpercent $extpct
	        set $stat "Checking selections  $extpct %"
	        update idletasks
	        }

	set tmp1 [$alist get $filind $filind]
	#  Account for symlinks (different tars say it differently)...
        #  gotta do this first, because it affects locating the filename.
	set tmpi [string first "->" $tmp1]
	set tmpi2 [string first "link to" $tmp1]
	if {$tmpi != -1}  {
	  incr tmpi -1
	  set tmp1 [string range $tmp1 0 $tmpi]
	  set tmp1 "$tmp1\}"
	  }  else  {
	    if {$tmpi2 != -1}  {
	      incr tmpi2 -1
	      set tmp1 [string range $tmp1 0 $tmpi2]
	      set tmp1 "$tmp1\}"
	      }
	  }

        #  Depending on file type, the filename may be the last field,
        #  or the first, or who-knows-what for newly added formats...
        switch    $arcfno        {
          10             -
          11             {
            #  ARJ & RAR have filename at beginning...
	    set file [string trim [lindex [lindex $tmp1 0] 0]]
            }
          2              -
          7              {
            #  Hack for locating spacey Win95-style filenames in a zip...
            #  - this works fine for extract. The viewing logic will have to
            #    wait for a future release.
            set file [string trim [lrange [lindex $tmp1 0] 7 end]]  
            }
          1              -
          3              -
          5              -
          14             -
          18             {
              set tmp "tartype$owner"
              global $tmp
              set tartype [set $tmp]
              set tni $tartype
#             set tni 7
#             if {$GotGtar && $GtRel > "1.11.8"}  {
#               set tni 5
#               }  else  {
#               if {[string trim [lrange [lindex $tmp1 0] $tni end]] == ""}  {
#                 set tni 5
#                 }
#               }
             set file [string trim [lrange [lindex $tmp1 0] $tni end]]
             }
          9              {
             set file [string trim [lrange [lindex $tmp1 0] 0 end]]  
             }
          4              -
          6              {
             if {$arcpgm == "gzip"}  {
               set file [string trim [lrange [lindex $tmp1 0] 3 end]]
               }  else  {
               set file [string trim [lrange [lindex $tmp1 0] 0 end]]
               }
             }
          12             -
          13             -
          17             {
             set file [string trim [lrange [lindex $tmp1 0] 0 end]]  
             }
          15             {
             set file [string trim [lrange [lindex $tmp1 0] 10 end]]  
             }
          16             -
          19             {
             set file [string trim [lrange [lindex $tmp1 0] 6 end]]  
             }
          default        {
            #  Most have filename at the end (*or* it's the only field).
            set file [string trim [lindex [lindex $tmp1 0] end]]
            }
          }

        #------------------
        #  1.0.6 - Account for a major bogosity that occurs if there's a "$" 
        #  in the filename - we get a list instead of a simple string, so we
        #  have to convert it back. (Noticed this trying to browse one of the
        #  jars in the JFC 1.0.1 distribution.)
        if {[string first "\$" $file] != -1}  {
          set tmpi 0
          set tmpi2 [llength $file]
          set tmpf2 ""
          while {$tmpi < $tmpi2}  {
            set tmpf2 "$tmpf2 [lindex $file $tmpi]"
            incr tmpi
            }
          set file $tmpf2
          }
        #  ...and don't include directories 
        set tmpi [string last "/" $file]
	incr tmpi
        if {$tmpi == [string length $file]}  {
          set isdir 1
          }  else  {
          set isdir 0
          }
#  The new handling...

        if {$file != ""}  {
          set tfile $file
# check types...only tar really does the absolute/not name thing, but LHarc
# always mimics tar's default behavior. Zip won't put 'em in that way in
# the first place.
          if {$tarlike && ! [set $apn2] && [string range $tfile 0 0] == "/"}  {
            set tfile [string range $tfile 1 end]
            }  else  {
            if {$arcfno == 15 && [set $jpn2]}  {
              set i [string last "/" $tfile]
              if {$i != -1}  {
                incr i
                set tfile [string range $tfile $i end]
                }
              }
            }
          if {[file exists $tfile]}  {
            #  ...and do the overwrite warning thing here.
#----------------

            #  ...and do the overwrite warning thing here.
            if {$WarnOverResp < 2}  {
              set WarnOverResp [WarnOverWrite "$owner" "$tfile"]
              if {$WarnOverResp == 4}  {
                catch { [close $ff] }
                set ff [open $flist w]
                catch { [close $ff] }
                $statw configure -fg black
                set $stat "   Done   "
                set $stat "Extract Cancelled "
                return 1
                }
              }
            if {$WarnOverResp == 1 || $WarnOverResp == 3}  {
              if {$isdir}  {
#                set flist3 [concat $flist3 $file]
  lappend flist3 [string trim $file]
                }  else  {
                puts $ff $file
                set flist2 [concat $flist2 $file]
#  lappend flist2 [string trim $file]
                }
              }  else  {
                set maybeall 0
#puts "Can't overwrite $file"
#puts "Can't overwrite $file"
	      }
	    }  else  {
            if {$isdir}  {
#              set flist3 [concat $flist3 $file]
  lappend flist3 [string trim $file]
              }  else  {
              puts $ff $file
              set flist2 [concat $flist2 $file]
#  lappend flist2 [string trim $file]
              }
	    }
	  }


        }
    catch { [close $ff] }
  }
#---------------------------

set selall $maybeall
if {$selall}  {
#puts "Doing the selall thing..."
  set file "*"
  set flist2 "*"
  catch {unset flist3}
  set flist3 ""
  set ff [open $flist w]
  puts $ff $flist2
  catch { [close $ff] }
  }

set tmp "sdirl$owner"
set $tmp $flist3

#-------------------------------------
#  The new handling...
#-------------------------------------
#  
#  
#  If there's nothing left in the list, don't call
#  the extractors...
set ll1 0
catch {set ll1 [llength $flist3]}
if {$flist2 == "" && $ll1 == 0}  {
  $statw configure -fg black
  set $stat "   Done   "
  set $stat "Nothing to Extract"
  return 1
  }

  if {$extdirsel} {

    switch    $arcfno        {
      1               -
      5               -
      14              -
      18              {
        #  Extract from Gzipped, Compressed, or Bzipped TAR...
        #  These cd's are temp till we obliterate all the ancient dir changing logic
        catch { cd {$olddir} }
        set rc [ExtTar $owner $arcdir $arcname $seldir $file $flist $lstf $errf]
#        return 1
        }
      2              -
      7              {
        #  Extract from ZIP...
        #  These cd's are temp till we obliterate all the ancient dir changing logic
        catch { cd {$olddir} }
        set rc [ExtZip $owner $arcdir $arcname $seldir $file $flist $lstf $errf]
#        return 1
        }
      3              {
        #  Extract from TAR...
        #  These cd's are temp till we obliterate all the ancient dir changing logic
        catch { cd {$olddir} }
        set rc [ExtTar $owner $arcdir $arcname $seldir $file $flist $lstf $errf]
#        return 1
        }
      4              {
        #  Extract from Gzipped file...
        #  These cd's are temp till we obliterate all the ancient dir changing logic
        catch { cd {$olddir} }
        set rc [ExtGzp $owner $arcdir $arcname $seldir $file $flist $lstf $errf]
#        return 1
        }
      6              {
        #  Extract from Compressed file...
        #  These cd's are temp till we obliterate all the ancient dir changing logic
        catch { cd {$olddir} }
        set rc [ExtCmp $owner $arcdir $arcname $seldir $file $flist $lstf $errf]
#        return 1
        }
      9              {
        #  Extract from AR...
        #  These cd's are temp till we obliterate all the ancient dir changing logic
        catch { cd {$olddir} }
        set rc [ExtAr $owner $arcdir $arcname $seldir $file $flist $lstf $errf]
#        return 1
        }
      10             {
        #  Extract from ARJ...
        catch { cd {$olddir} }
        set rc [ExtArj $owner $arcdir $arcname $seldir $file $flist $lstf $errf]
#        return 1
        }
      11             {
        #  Extract from RAR...
        catch { cd {$olddir} }
        set rc [ExtRar $owner $arcdir $arcname $seldir $file $flist $lstf $errf]
#        return 1
        }
      12             {
        #  Extract from SHN...
        catch { cd {$olddir} }
        set rc [ExtShn $owner $arcdir $arcname $seldir $file $flist $lstf $errf]
#        return 1
        }
      13             -
      17             {
        #  Extract from BZIP...
        catch { cd {$olddir} }
        set rc [ExtBzip $owner $arcdir $arcname $seldir $file $flist $lstf $errf]
#        return 1
        }
      15             {
        #  Extract from LHA...
        catch { cd {$olddir} }
        set rc [ExtLha $owner $arcdir $arcname $seldir $file $flist $lstf $errf]
#        return 1
        }
      16             -
      19             {
        #  Extract from CPIO...
        catch { cd {$olddir} }
        set rc [ExtCpio $owner $arcdir $arcname $seldir $file $flist $lstf $errf]
#        return 1
        }
      default        {
        #  Can't happen, right?
        return -1
        }

      }
      #  End switch...

    }

#-----------------------------------------------------
#  The generic extract-error check is added here,
#  instead of in the individual routines.
#  Are there any special case checks needed other than
#  for "ignore gzip trailing garbage message"???
#
#  gzip & bzip bugs noted below
#  ***  compress needs research, not accounted for yet.
#  lharc and arj fail to set an error code.
#  cpio & rar have to have hacks.
#
#  This means that ar, zip and tar (at least GNU tar) are
#  the only really clean programs.
#
#-----------------------------------------------------

#----------------------------------
#  RBW - relocated code...
#  General extract error check...
#----------------------------------

      if {$rc != 0} {
        set ignerr 0

        switch $arcfno          {
        1               -
        3               -
        5               -
        14              -
        18              {
          # All kinds of tars
          set ignerr 0
          }
        4               -
        13              -
        17              {
          # Gzip & friends
          #  Note: gzip (4) -- at least as recently as 1.3.5, and as far back
          #  as 1.2.4 -- does not write its error message to stderr if it
          #  can't create the output file; it writes it to stdout.
          #  bzip/bzip2 (13 & 17) also have this problem.
          #  This is brain-damaged. If it were able to write the file, it would
          #  be writing the error message into the output file; but since it
          #  can't, we can never see the error message. Bad, bad, bad. Bad.
          #  So, what do we do here? Put our own message in errf explaining
          #  that gzip/bzip is buggy and just shot itself in the foot? Yeah.
          set ignerr 0
          #  Write our own stderr message...
          set errfltxt "  *** Broken application!\n  $arcpgm does not write an error message to stderr that \
            $PgmName can capture.\n  It attempts to write error messages to \
            stdout, which is where\n  the failed file extraction was directed. \
            Therefore, there is no way\n  to determine what error occurred.\n"
          set ef ""
          set gotnoerrf 0
          if {[file exists $errf]}  {
            if {[file size $errf] == 0}  {
              set gotnoerrf 1
              }
            }  else  {
            set gotnoerrf 1
            }
          if {$gotnoerrf}  {
            catch {set ef [open $errf w]}
            if {$ef != ""}  {
              catch {puts $ef $errfltxt}
              catch {close $ef}
              }
            }
          }
        11              {
          #  Rar
          #  unrar writes error message to stdout, not stderr, like gzip and
          #  bzip. This would be OK, since we don't extract to stdout.
          #  Unfortunately, it also writes a lot of ascii art garbage
          #  that we're not about to display. It does return an error code.
          #  We have to try to remove the dreck from stdout and write it to
          #  stderr. This is ugly.
          set ignerr 0
          set ef ""
          set of ""
          set gotnoerrf 0
          set gotlstf 0
          if {[file exists $errf]}  {
            if {[file size $errf] == 0}  {
              set gotnoerrf 1
              }
            }  else  {
            set gotnoerrf 1
            }
          if {[file exists $lstf]}  {
            if {[file size $lstf] > 0}  {
              set gotlstf 1
              }
            }
          if {$gotlstf && $gotnoerrf}  {
            catch {set of [open $lstf r]}
            if {$of != ""}  {
              catch {set ef [open $errf w]}
              #  If we can open stderr file, write out -> err.
              if {$ef != ""}  {
                set errfltxt ""
                set gotdreck 0
                while {[ gets $of line ] > -1}  {
                  if {[string last "" $line] != -1}  {
                    set gotdreck 1
                    }  else  {
                    if {[string last "" $line] != -1}  {
                      #  Last line of garbage has a bunch of these.
                      set ind [string last "" $line]
                      incr ind
                      set line [string range $line $ind end]
                      #  2.50, at least, ends with this...
                      set ind [string last "\[0m" $line]
                      incr ind 3
                      set line [string range $line $ind end]
                      set gotdreck 0
                      }
                    }
                  if {! $gotdreck}  {
                    set errfltxt "$errfltxt\n $line"
                    }
                  }
                catch {puts $ef $errfltxt}
                catch {close $ef}
                }
              catch {close $of}
              }
            }

          }
        16              -
        19              {
          #  Cpio (& Rpm)
          #  cpio (at least the GNU version) writes an error message to stderr,
          #  but it doesn't set an error return code. Hence, in order to get
          #  here we do some special checking in the ExtCpio function to
          #  see if something's been written to errf, and set a "synthetic"
          #  return code if so.
          set ignerr 0
          }
        10              {
          #  Arj
          #  unarj doesn't put out an error message *or* set an error return
          #  value. There's not much we can do about this one. We'll never
          #  even get here, and there's nothing we could do if we did.
          set ignerr 0
          }
        15              {
          #  LHarc
          #  Same as unarj; it doesn't set an error return value *or* write
          #  an error message. Not very useful. We'll never get here.
          set ignerr 0
          }
        default         {
          set ignerr 0
          }
        }



        if {! $ignerr}  {
          incr TmpNo
          set tno $TmpNo
          if {! $TkzG(DseFlag)}  {
            if {$TkzG(Portable)}  {
              catch {file copy -force $lstf $Home/TkzLst$MyPid-$tno}
              catch {file copy -force $errf $Home/TkzErr$MyPid-$tno}
              }  else  {
              catch {exec cp $lstf $Home/TkzLst$MyPid-$tno}
              catch {exec cp $errf $Home/TkzErr$MyPid-$tno}
              }
            }
          set ErrArgs [list "$Home/TkzLst$MyPid-$tno" "$Home/TkzErr$MyPid-$tno" $lstf $errf $arcpgm]
          $statw configure -bg black
          set $stat "Done"
          GErrMsgBox 91
#  Clean up...
          if {$TkzG(Portable)}  {
            catch { [file delete -force $lstf $errf $flist] }
            }  else  {
            catch { [exec rm $lstf $errf $flist] }
            }


          return -1
          }
        }
#----------------------------------

#-----------------------------------------------------
#  End of new error check.
#-----------------------------------------------------


#-------------------------------------
#  All the stuff below here should 
#  eventually disappear...
#  As soon as we get the error catching logic back
#  up to par, delete it.
#-------------------------------------
#  Done.
#-------------------------------------

  #  NewStuff-1
  #  Update the main File list if it's pointing to...aww, hell, just
  #  update the darned thing anyway, just in case.
  #  One of these days, we should put in a directory list list - all
  #  dir windows would register/unregister themselves...maybe next week...
  #  set tmp "CurDirmain"
  #  global $tmp
  #  set curdir [set $tmp]
  #  set mainl "main"
  #  UpdDirList $mainl $curdir
  #
  #  **  Better idea...refresh everything in the global list
  #

  }
  RefDirs $seldir
return 1
}


#----------------------------------------------------
#  Find Func  --  search for a string in the
#    directory list (new in 1.1)
#----------------------------------------------------
proc FindFunc {owner}  {
set thisproc "FindFunc"
global TempDir MyPid PgmName ErrArgs MenuHelp
global MainBg MainFg MainButBg WhoBg ArcWin WinList
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg DSlidBg
global EntBg EntFg SelBg SelFg
global TkzG

#puts "$thisproc:  entered for $owner"

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 62
  return 1
  }

#--------------------------------------
set WBg $TwBg(0)
set WButBg $TwButBg(0)
set WButFg $TwButFg(0)
set WEntBg $EntBg(0)
set WEntFg $EntFg(0)
set WSelBg $SelBg(0)
set WSelFg $SelFg(0)
set WFg $TwFg(0)
set lbg $TwLFg(0)
set lfg $TwLFg(0)


#set owner "main"

#-------------------------------------------------------------------
#  Make some unique names for us...
set this "Fnds"
set thiswin "$owner$this"
set WinName ".$thiswin"
#set owner $thiswin

#-------------------------------
set findall "findall$thiswin"
set sforw "sforw$thiswin"
set swrap "swrap$thiswin"
set findarg "findarg$thiswin"
global $findall
global $sforw
global $swrap
global $findarg
set $findall 0
set $sforw 1
set $swrap 0
set $findarg ""

set howfind "howfind$thiswin"
global $howfind
set $howfind 2
#-------------------------------

if [catch {toplevel $WinName}] {
  raise $WinName
  } else {
#  Build the window...
  set wintitle "$PgmName: Find"
  wm title $WinName $wintitle
  set topf [frame $WinName.top -bg $WBg -highlightbackground $WBg]
  set buttons [frame $topf.but -bg $WBg -highlightbackground $WBg]
  set opts [frame $topf.opts -bg $WBg -highlightbackground $WBg]
  set namef [frame $WinName.top.namef -bg $WBg -highlightbackground $WBg]

  set cmd "eval FindInDir $owner $thiswin"
  button $buttons.findit -text "Find" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
  bind $buttons.findit <3> {ShowHelp 62}
  set cmd "KillFindWin $thiswin"
  button $buttons.quit -text "Cancel" -command $cmd \
    -bg $WButBg -fg $WButFg -highlightbackground $WButBg
#  bind $buttons.quit <3> {ShowHelp 42a}
#  Gotta intercept wm killing the window with this command too
  wm protocol $WinName "WM_DELETE_WINDOW" $cmd
  wm protocol $WinName "WM_SAVE_YOURSELF" $cmd

  label $namef.tag -text "Find string:  " -relief flat -bg $WBg -fg $WFg
  entry $namef.str -text " " -relief sunken -bg $WEntBg -fg $WEntFg -width 30 \
  -font "-*-fixed-bold-*-*-*-*-*-*-*-*-*-*-1" -state disabled

set cmd ""
  radiobutton $opts.findall -variable $howfind -value 1 -text "Find all" \
    -bg $WBg -fg $WFg -highlightbackground $WBg -command $cmd
  radiobutton $opts.forw -variable $howfind -value 2 -text "Find forward" \
    -bg $WBg -fg $WFg -highlightbackground $WBg -command $cmd
  radiobutton $opts.back -variable $howfind -value 3 -text "Find backward" \
    -bg $WBg -fg $WFg -highlightbackground $WBg -command $cmd

  checkbutton $opts.wrap -variable $swrap -text "Wrap search" \
    -bg $WBg -fg $WFg -highlightbackground $WBg -command $cmd

  if {$TkzG(Windows)}  {
    $opts.findall configure -selectcolor $WBg
    $opts.forw configure -selectcolor $WBg
    $opts.back configure -selectcolor $WBg
    $opts.wrap configure -selectcolor $WBg
    }
$opts.forw select


  pack $buttons.findit $buttons.quit -side left
  pack $namef.tag $namef.str -side left -expand no
  pack $opts.findall $opts.forw $opts.back $opts.wrap -side left

  pack $namef -side bottom -anchor w -padx 8 -pady 8
  pack $opts -side bottom
  pack $buttons -side bottom 
  pack $topf -side bottom -anchor center -expand yes -fill both -ipady 4

  set cmd "FindInDir $owner $thiswin"
  bind $namef.str <Return> $cmd
  $namef.str configure -textvariable $findarg -state normal

#  RBW - 08/31/1999 - this doesn't belong in the list...
#  ?? Something more to do here...
#AddToList $owner "FLList"

  }

return 0
}


#  ****  Needs arcname dirname
#        - needs to disable/enable buttons...see SelectAll/SelectNone
#-----------------------------------------------------
#  FindInDir   --  Find a string in the directory list
#-----------------------------------------------------
proc FindInDir {owner thiswin} {
global FLList
global TkzG

set thisproc "FindInDir"
#set thiswin $owner
set arcbody "$owner.body"
set alist "$arcbody.alist"
set buttons "$owner.top.but"



set howfind "howfind$thiswin"
set swrap "swrap$thiswin"
global $howfind
global $swrap
set hf [set $howfind]
set wrap [set $swrap]
set found 0


set anc [.$alist index anchor]
set lsize [.$alist size]
if {$anc == $lsize}  {
  set anc 0
  }
set fndfrst $anc
set sellist [.$alist curselection]
#puts "Anchor = $anc, size = $lsize.  Selected items:  $sellist"
.$alist selection clear 0 end
DisableDirButtons $owner

set tmp "findarg$thiswin"
global $tmp
set findarg [set $tmp]
#puts "$thisproc called for $owner/$thiswin - looking for \"$findarg\""
#puts "howfind = $hf,  wrap = $wrap"

#-------------------
switch  $hf  {
  1       {
      set i1 0
      set i2 $lsize
      while {$i1 < $i2}  {
        set tmp [.$alist get $i1]
	if {[string first $findarg $tmp] != -1}  {
          .$alist selection set $i1 $i1
          set found 1
          if {$i1 < $fndfrst}  {
            set fndfrst $i1
            }
          }
        incr i1
        }
      }
  2       {
      set i1 $anc
      incr i1
      set i2 $lsize
      while {$i1 < $i2}  {
        if {[string first $findarg [.$alist get $i1]] != -1}  {
          .$alist selection set $i1 $i1
          .$alist selection anchor $i1
          set fndfrst $i1
          set found 1
	  break
          }
        incr i1
        }
      if {! $found && $wrap}  {
        set i1 0
	set i2 $anc
        while {$i1 <= $i2}  {
          if {[string first $findarg [.$alist get $i1]] != -1}  {
            .$alist selection set $i1 $i1
            .$alist selection anchor $i1
            set fndfrst $i1
            set found 1
            break
            }
          incr i1
          }
        }
if {! $found}  {
  set anc $lsize
  incr anc -1
  }
      }
  3       {
      set i1 $anc
      incr i1 -1
      set i2 0
      while {$i1 >= $i2}  {
        if {[string first $findarg [.$alist get $i1]] != -1}  {
          .$alist selection set $i1 $i1
          .$alist selection anchor $i1
          set fndfrst $i1
          set found 1
	  break
          }
        incr i1 -1
        }
      if {! $found && $wrap}  {
        set i1 $lsize
	set i2 $anc
        incr i1 -1
        while {$i1 >= $i2}  {
          if {[string first $findarg [.$alist get $i1]] != -1}  {
            .$alist selection set $i1 $i1
            .$alist selection anchor $i1
            set fndfrst $i1
            set found 1
            break
            }
          incr i1 -1
          }
        }
if {! $found}  {
  set anc 0
  }
      }

  }
.$alist see $fndfrst
if {! $found}  {
  .$alist selection anchor $anc
  }  else  {
  EnableDirButtons $owner
  }

#  If something was found, enable buttons...
#-------------------



#KillFindWin $thiswin

return 1
}


#---------------------------------------------------
#  KillFindWin   --  Destroy the Find window
#---------------------------------------------------
proc KillFindWin {owner} {
global FLList
global TkzG

set body "$owner.body"

#  Gotta look for a find window, and kill it if it exists.
#  - see KillArc for the model....
#PluckFromList $body "FLList"
destroy .$owner

return
}


#----------------------------------------------------
#  WhatsThis  --  Utility function to pop up a
#    window identifying the type of a selected file.
#----------------------------------------------------
proc WhatsThis {owner}  {
global MainSelected ErrArgs
set thisproc "WhatsThis"


if {! $MainSelected}  {
  return 1
  }
set win ".$owner"
set dirn [ GetCurDir "$owner" ]
if {[$win.list2.arclist curselection] == ""}  {
  return -1;
  }
set arcn [$win.list2.arclist get [$win.list2.arclist curselection]]; \
if {$dirn == "/"}  {
  set dirn ""
  }  else  {
  set l [string length $dirn]
  incr l -1
  if {[string range $dirn $l end] == "/"}  {
    incr l -1
    set dirn [string range $dirn 0 $l]
    }
  }
set l [string length "$dirn/$arcn"]
incr l
set rc [catch {exec file $dirn/$arcn} tmp]
set tmp [string range $tmp $l end]


#  Temp --  we should pop up a nicer window to display this info
# puts "$thisproc:  $dirn/$arcn?    It's a file, Sir. \nMore specifically:\n  $tmp\n"
set ErrArgs [list "What is $arcn?" $tmp]
GErrMsgBox 62

return
}


#----------------------------------------------------
#  WhatsThis2  --  Utility function to pop up a
#    window identifying the type of a selected file.
#----------------------------------------------------
proc WhatsThis2 {owner dirname arcname}  {
global MainSelected ErrArgs
set thisproc "WhatsThis2"


set alist ".$owner.body.alist"
if {[$alist curselection] == ""}  {
  return -1
  }

TmpExt $owner $dirname $arcname
set tmp "TVDir$owner"
global $tmp
set tmpd [set $tmp]
set tmp "Flist2$owner"
global $tmp
set flist2 [set $tmp]
set flist ""

if {[llength $flist2] == 0}  {
  return
  }  else  {
  if {[llength $flist2] > 1}  {
    set whatwhat "What are these?"
    }  else  {
    set whatwhat "What is [lindex $flist2 0]?"
    }
  }
set cmd ""
lappend cmd "exec" "file"
foreach file $flist2  {
  lappend cmd "$file"
  }

set where [pwd]
cd $tmpd
set rc [catch {set erc [eval $cmd]} tmp]
cd $where


#  Temp --  we should pop up a nicer window to display this info
#set tmp "What's this?    It's a file, Sir. \nMore specifically:\n  Stuff\n"
set ErrArgs [list "$whatwhat" "\n$tmp"]
GErrMsgBox 62

return
}




#------------------------------------------------------------
#  BuildMbrList  --  build list of selected members to act on
#------------------------------------------------------------
proc BuildMbrList {owner func tno arcfno} {
global TempDir GotGtar GtRel
global TkzG
#global WarnOverWrite

set WarnOverResp 0
set alist ".$owner.body.alist"
set sellist [$alist curselection]
set flist "$TempDir/TkzFlst$tno"
catch {unset flist2}
if {$func == "extract"}  {
  set extracting 1
  }  else  {
  set extracting 0
  }

#  Build a list of members to act on
set ff [open $flist w]

set flnum [llength $sellist]
set flct 0
set extpercent 0
#-------------------------
foreach filind $sellist {

  incr flct
  if {$extracting}  {
    set extpct [expr [expr 100 * $flct] / $flnum]
    if {$extpct != $extpercent}  {
      set extpercent $extpct
      set $stat "Checking selections  $extpct %"
      update idletasks
      }
    }

  set tmp1 [$alist get $filind $filind]
  #  Account for symlinks (different tars say it differently)...
  #  gotta do this first, because it affects locating the filename.
  set tmpi [string first "->" $tmp1]
  set tmpi2 [string first "link to" $tmp1]
  if {$tmpi != -1}  {
    incr tmpi -1
    set tmp1 [string range $tmp1 0 $tmpi]
    set tmp1 "$tmp1\}"
    }  else  {
    if {$tmpi2 != -1}  {
      incr tmpi2 -1
      set tmp1 [string range $tmp1 0 $tmpi2]
      set tmp1 "$tmp1\}"
      }
    }

  #  Depending on file type, the filename may be the last field,
  #  or the first, or who-knows-what for newly added formats...
  switch    $arcfno        {
    10             -
    11             {
      #  ARJ & RAR have filename at beginning...
      set file [string trim [lindex [lindex $tmp1 0] 0]]
      }
    2              -
    7              {
       #  Hack for locating spacey Win95-style filenames in a zip - part 1...
       set file [string trim [lrange [lindex $tmp1 0] 7 end]]  
       }
    1              -
    3              -
    5              -
    14             -
    18             {
       set tmp "tartype$owner"
       global $tmp
       set tartype [set $tmp]
       set tni $tartype
#       set tni 7
#       if {$GotGtar && $GtRel > "1.11.8"}  {
#         set tni 5
#         }  else  {
#         if {[string trim [lrange [lindex $tmp1 0] $tni end]] == ""}  {
#           set tni 5
#           }
#         }
       set file [string trim [lrange [lindex $tmp1 0] $tni end]]
       }
    9              {
       set file [string trim [lrange [lindex $tmp1 0] 0 end]]  
       }
    15              {
       set file [string trim [lrange [lindex $tmp1 0] 10 end]]  
       }
    16              -
    19              {
       set file [string trim [lrange [lindex $tmp1 0] 6 end]]  
       }
    default        {
      #  Most have filename at the end (*or* it's the only field).
      set file [string trim [lindex [lindex $tmp1 0] end]]
      }
    }

#------------------
#  1.0.6 - Account for a major bogosity that occurs if there's a "$" 
#  in the filename - we get a list instead of a simple string, so we
#  have to convert it back. (Noticed this trying to browse one of the
#  jars in the JFC 1.0.1 distribution.)
if {[string first "\$" $file] != -1}  {
  set tmpi 0
  set tmpi2 [llength $file]
  set tmpf2 ""
  while {$tmpi < $tmpi2}  {
    set tmpf2 "$tmpf2 [lindex $file $tmpi]"
    incr tmpi
    }
  set file $tmpf2
  }
  #  ...and don't include directories 
#----------------
  if {$extracting}  {
    set tmpi [string last "/" $file]
    incr tmpi
    if {$file != "" && $tmpi != [string length $file]}  {

      if {[file exists $file]}  {
        #  ...and do the overwrite warning thing here.
        if {$WarnOverResp < 2}  {
          set WarnOverResp [WarnOverWrite "$owner" "$file"]
          if {$WarnOverResp == 4}  {
            catch { [close $ff] }
            set ff [open $flist w]
            catch { [close $ff] }
            return 1
            }
          }
        if {$WarnOverResp == 1 || $WarnOverResp == 3}  {
          puts $ff $file
          lappend flist2 [string trim $file]
          }
        }  else  {
        puts $ff $file
        lappend flist2 [string trim $file]
        }

      }
    }  else  {
    puts $ff $file
    lappend flist2 [string trim $file]
    }
#----------------


  }
    catch { [close $ff] }



#-------------------------


return 1
}





#----------------------------------------------------
#  UpdExtDir  --  Update the Extract-to dir from the 
#    filelist entry the user double-clicked on
#----------------------------------------------------
proc UpdExtDir {owner}  {
global CurExtDir ExtDirSel
global TkzG

set thisproc "UpdExtDir"

KillViewButtons
set arcbody ".$owner"
set l1 [$arcbody.list1.dirlist curselection]
if {$l1 == ""}  {
  return 1
  }
set dirn [$arcbody.list1.dirlist get [$arcbody.list1.dirlist curselection]]
set seldir [UpdDirList "$owner" "$dirn"]

set tmp "ExtDir$owner"
global $tmp
set $tmp $seldir

set CurExtDir $seldir
set ExtDirSel 0


return seldir
}

#----------------------------------------------------
#  UpdExtDir2  --  Update the Extract-to dir from the
#    entry field, the user just hit enter
#----------------------------------------------------
proc UpdExtDir2 {owner}  {
global CurExtDir ExtDirSel
global TkzG

set thisproc "UpdExtDir2"

KillViewButtons
set arcbody ".$owner"

set dirn [.$owner.top.hdr.where get]
set seldir [UpdDirList "$owner.body" "$dirn"]

set tmp "ExtDir$owner.body"
global $tmp
set $tmp $seldir

set CurExtDir $seldir
set ExtDirSel 0


return seldir
}





proc SelDir {owner} {
global TkzG
set thisproc "SelDir"

if {$TkzG(Debug)}  {
#  puts "$thisproc:    Entered with arg owner = $owner."
#  puts "           Setting dir selected, destroying $owner."
  }
#  RBW - experimental stuff - insure any dir entered manually is caught
#  before file extraction.
UpdExtDir2 $owner

set tmp "ExtDirSel$owner"
global $tmp
set $tmp 1
destroy .$owner

return 1
}


#----------------------------------------------------
#  UpdCraDir  --  update the directory to create a 
#    new archive in
#----------------------------------------------------
proc UpdCraDir {owner}  {
global CurCraDir
global TkzG

set thisproc "UpdCraDir"

KillViewButtons
set arcbody ".$owner"
set tmpd "CraDir$owner"
global $tmpd
set cradir [set $tmpd]
set l1 [$arcbody.list1.dirlist curselection]
if {$l1 == ""}  {
  return $cradir
  }
set dirn [$arcbody.list1.dirlist get $l1]
set cradir [UpdDirList "$owner" "$dirn"]

set tmpd "CraDir$owner"
global $tmpd
set $tmpd $cradir

set CurCraDir $cradir

return $cradir
}


#----------------------------------------------------
#  UpdCraDir2  --  update the directory to create a 
#    new archive in
#----------------------------------------------------
proc UpdCraDir2 {owner}  {
global CurCraDir
global TkzG

set thisproc "UpdCraDir"

KillViewButtons
#set arcbody ".$owner"
set dirn [.$owner.top.namef.dir get]
set cradir [UpdDirList "$owner.body" "$dirn"]

set tmp "CraDir$owner.body"
global $tmp
set $tmp $cradir

set CurCraDir $cradir

return $cradir
}



#----------------------------------------------------
#  GErrMsgBox  --  general error msg box
#    -- cleaned up and made properly reentrant...
#       split the modal stuff out into another func.
#----------------------------------------------------
proc GErrMsgBox {gerrno} {
global PgmName ErrArgs TkzVer TmpNo MainBg MainFg MainButBg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg
global TkzG
set thisproc "GErrMsgBox"

#  Defaults...
set maxerr 100
set quitword "OK"
set quitbg "Red"
set yesword "Yes"
incr TmpNo
set tno $TmpNo
global action
set action 0
set wnum 0
set wbg $TwBg($wnum)
set wfg $TwFg($wnum)
set wbutbg $TwButBg($wnum)
set wbutfg $TwButFg($wnum)

switch $gerrno {

  1              {
    #  Error trying to read the archive...
    set arcname [lindex $ErrArgs 0]
    set winname ".badname"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Wrong or Unknown File Type -"
    set winaspect 300
    set NoGots "$TkzG(NoGotPgms)$TkzG(NoGotPgms2)"
    if {$NoGots != ""}  {
      set whatsmissing "\n    (We were unable to locate the following programs, or compatible versions thereof, \
      on your system:\n		$NoGots\nThis could possibly be the cause.)"
      }  else  {
      set whatsmissing ""
      }
    set errtext "    Sorry, but '$arcname' does not appear to be a type of file supported by \
        $PgmName version $TkzVer. $whatsmissing\
	\n\n    If you think \
	you have a file of a standard type that we should recognize, please E-mail the author at tkzip@woodsway.com \
	with a brief description."
    }

  2              {
    #  For trying to enter /proc...
#    set quitbg $MainButBg
    set winname ".noproc"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Proc -"
    set winaspect 600
    set errtext "    '/proc' is a special filesystem used for accessing internal OS kernel data.\
      It is not a normal directory, and there are no archives there. \
      $PgmName will not enter it."
    }

  3              {
    #  Unable to locate archive pgm...
    set pgmname [lindex $ErrArgs 0]
    set winname ".nopgm"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Archive Program '$pgmname' Missing -"
    set winaspect 600
    set errtext "    The program '$pgmname' is needed to read this type of archive, \
      and could not be located on this system."
    }

  4              {
    #  User-defined viewer not entered...
    set winname ".noview"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- User-Defined Viewer Not Specified -"
    set winaspect 600
    set errtext "    You selected the User-Defined Viewer, but did not enter the program name. \
      Please enter the name of the binary executable or script \
      you wish to use for a viewer (you may enter a full path name if necessary)."
    }

  5              {
    #  No E-mail address...
    set what     [lindex $ErrArgs 0]
    set winname ".noid"
    set wintitle "$PgmName:    --  No E-mail Address"
    set winhdr "- No E-mail Address -"
    set winaspect 600
    set errtext "    We cannot E-mail the $what form without your E-mail address. \
    Please enter your user id and hostname in the fields provided.\
    \n\n    (If we were able to determine the address of the machine you are running on, then \
    we pre-entered that information. However, some systems do not respond nicely to a polite \
    request for a fully qualified domain name.)"
    }

  6              {
    #  Function not implemented yet...
    #  This text needs to be revised, in case this ever gets called. It really
    #  means the function isn't implemented for this type of archive.
    set quitbg $MainButBg
    set funcname [lindex $ErrArgs 0]
    set winname ".nofunc"
    set wintitle "$PgmName:    --  $funcname"
    set winhdr "- $funcname Not Implemented Yet -"
    set winaspect 600
    set errtext "    $funcname is not yet implemented in $PgmName version $TkzVer. \
      \n\n    This is a pre-release beta version, and there are several pieces still missing. \
      The button you just pushed is one of them. It is scheduled to be connected by release 1.0.0. "
    }

  7              {
    #  Nothing selected to view...
    set quitbg $MainButBg
    set arcname [lindex $ErrArgs 0]
    set winname ".novsel"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Nothing Selected to View -"
    set winaspect 600
    set errtext "    You requested to view the selected item from '$arcname', but there is nothing selected. \
      \nClick on the item you wish to view and try again (or just double-click the item.) "
    }

  8              {
    #  Nothing selected to view...
    set quitbg $MainButBg
    set winname ".noasel"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Nothing Selected to View -"
    set winaspect 600
    set errtext "    You requested to view the selected archive, but there is nothing selected. \
      \nClick on the item you wish to view and try again (or just double-click the item.) "
    }

  9              {
    #  Info - we saved reg or bug form...
    set quitbg $MainButBg
    set filename [lindex $ErrArgs 0]
    set what     [lindex $ErrArgs 1]
    set winname ".fsaved"
    set wintitle "$PgmName:    --  $what Form Saved"
    set winhdr "- $what Form Saved -"
    set winaspect 600
    set errtext "    The $what form for $PgmName version $TkzVer has been saved as $filename. "
    }

  10              {
    #  Info - we sent reg or bug form...
    set quitbg $MainButBg
    set author   [lindex $ErrArgs 0]
    set what     [lindex $ErrArgs 1]
    set winname ".fsent"
    set wintitle "$PgmName:    --  $what Form Sent"
    set winhdr "- $what Form Sent -"
    set winaspect 600
    set errtext "    The $what form for $PgmName version $TkzVer has been sent to $author. "
    }

  11              {
    #  E-mail is fubar...
    set author   [lindex $ErrArgs 0]
    set what     [lindex $ErrArgs 1]
    set winname ".fnotsent"
    set wintitle "$PgmName:    --  $what Failed"
    set winhdr "- $what Failed -"
    set winaspect 600
    set errtext "    The attempt to E-mail the $what form for $PgmName version $TkzVer to $author \
      failed."
    }

  12              {
    #  Error, but only partial...
    set arcname  [lindex $ErrArgs 0]
    set errfl    [lindex $ErrArgs 1]
    #  Non-portable...
    set errfltxt ""
    if {$TkzG(Portable)}  {
      if {[file size $errfl] > 0}  {
        set ef ""
        catch {set ef [open $errfl r]}     
        if {$ef != ""}  {
          while {[ gets $ef line ] > -1}  {
            set errfltxt "$errfltxt$line"
            }
          }
        catch {close $ef}
        }
      }  else  {
      set errfltxt [exec cat $errfl]
      }
    set winname ".direrr"
    set wintitle "$PgmName:    --  Error Reading Archive Directory"
    set winhdr "- Error Reading $arcname -"
    set winaspect 300
    set errtext "    An error occurred trying to read the directory of $arcname. The file is probably corrupted, but \
      may be partially usable. The following is the text of the error message(s) returned.\n\n-------------------------------- \
      \n$errfltxt\n--------------------------------\n\n    If you \
      attempt to extract any items that may show up in the partial directory list, they may or may not extract successfully. \
      The extracted file(s) may be OK, even though the extract returns an error. Unfortunately, there is no way for $PgmName \
      to determine this. You will have to examine them to make that determination."
    }

  13              {
    #  Can't find mail agent...
    set author   [lindex $ErrArgs 0]
    set what     [lindex $ErrArgs 1]
    set winname ".fnotsent"
    set wintitle "$PgmName:    --  $what Failed"
    set winhdr "- $what Failed -"
    set winaspect 600
    set errtext "    The attempt to E-mail the $what form for $PgmName version $TkzVer to $author \
      failed because $PgmName was unable to locate a standard AT&T style mail command on your system. \
      Save the form as a file instead, and E-mail that via your standard method."
    }

  14              {
    #  Nothing selected to delete...
    set quitbg $MainButBg
    set winname ".nodasel"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Nothing Selected to Delete -"
    set winaspect 600
    set errtext "    You requested to delete the selected archive, but there is nothing selected. \
      \nClick on the item you wish to delete and try again. "
    }

  15              {
    #  Nothing selected to view...
    set quitbg $MainButBg
    set winname ".noupddev"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Attempt to Update Device -"
    set winaspect 600
    set errtext "    $PgmName does not support updating, creation, or deletion of files on a device."
    }

  16              {
    #  For trying to enter a TkZip dir...
    set dirname [lindex $ErrArgs 0]
    set winname ".notdir"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- $dirname -"
    set winaspect 600
    set errtext "    '$dirname' is a directory used by $PgmName for temporary files (or internal\
      configuration information). Since these files are apt to disappear or move without warning,\
      you would probably not enjoy trying to view them.\
      \n    $PgmName would definitely not enjoy having you try to update them, so it will not enter this directory."
    }

  17              {
    #  For trying to enter a nonexistent dir...
    set dirname [lindex $ErrArgs 0]
    set winname ".nodir"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- $dirname -"
    set winaspect 600
    set errtext "    '$dirname' does not exist. This version of $PgmName does not implicitly create new directories. "
    }

  18              {
    #  Error, but only partial...
    set arcname    [lindex $ErrArgs 0]
    set tarname    [lindex $ErrArgs 1]
    set winname ".duptar"
    set wintitle "$PgmName:    --  Duplicate Archive in Cache"
    set winhdr "- $tarname Currently in Cache -"
    set winaspect 600
    set errtext "    Another archive is currently open containing a tar with the\
      same name as the one contained in $arcname.\n\
      \n    $arcname cannot be opened until you close the other archive, because\
      this would cause the cached copy of $tarname to be overwritten."
    }






  61              {
    #  Can't install executable and Extras into same directory...
#    set whathdr [lindex $ErrArgs 0]
#    set what    [lindex $ErrArgs 1]
    set winname ".badinstd"
    set wintitle "$PgmName:    --  Bad Install Dir"
    set winhdr "- Conflicting Install Directories! -"
    set winaspect 500
    set errtext "    The Install Root and Binary Dir cannot be the\
      same directory.\n"
    }

  62              {
    #  Not an error, "What's This?" info...
    set whathdr [lindex $ErrArgs 0]
    set what    [lindex $ErrArgs 1]
    set winname ".whatsit"
    set wintitle "$PgmName:    --  What's This?"
    set winhdr "- $whathdr -"
    set winaspect 500
    set errtext "    $what\n"
    }

  63              {
    #  Unable to read drive (MS Windows)...
    set drvname [lindex $ErrArgs 0]
    set what    [lindex $ErrArgs 1]
    set drvmsg  [lindex $ErrArgs 2]
    set winname ".baddrv"
    set wintitle "$PgmName:    --  Drive error!"
    set winhdr "- Error accessing drive $drvname -"
    set winaspect 500
    set errtext "    $PgmName was unable to read drive $drvname. (The most common cause\
      for this error is a poorly configured network drive mapping.) The error message\
      returned by Windows was:\
      \n\n    $drvmsg\n"
    }

  64              {
    #  Can't open windows while changing cache...
    set winname ".cachechg"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Cache Change in Progress -"
    set winaspect 600
    set errtext "    You cannot open files while a Cache Change operation is\
      in progress. Either complete the operation, or cancel it, before attempting\
      to open any files, which requires that the cache directory be in a stable\
      condition."
    } 

  65              {
    #  Don't send license req rept w/o name/address/no. of users...
    set winname ".badmail"
    set wintitle "$PgmName:    --  Incomplete License Form"
    set winhdr "- Incomplete License Form -"
    set winaspect 800
    set errtext "    If you want to send a license request via e-mail, you need\
      to enter your name, address, and the number of users you wish to license."
    }

  66              {
    #  Don't send bug rept w/o description...
    set winname ".badmail"
    set wintitle "$PgmName:    --  Newbie Alert!"
    set winhdr "- Newbie Alert! -"
    set winaspect 800
    set errtext "    You're attempting to send a Bug Report. Don't you think it\
      would be a nice idea to enter a description of the problem...?"
    }

  67              {
    #  Info - can't access directory...
    set quitbg $MainButBg
    set dirname     [lindex $ErrArgs 0]
    set what        [lindex $ErrArgs 1]
    set whynot      [lindex $ErrArgs 2]
    set winname ".noenter"
    set wintitle "$PgmName:    --  can't $what directory"
    set winhdr "- Can't $what directory $dirname -"
    set winaspect 600
    set errtext "    Permission to $what directory $dirname was denied. "
    }

  68              {
    #  Info - we saved reg or bug form...
    set quitbg $MainButBg
    set what     [lindex $ErrArgs 0]
    set winname ".fprinted"
    set wintitle "$PgmName:    --  $what Form Printed"
    set winhdr "- $what Form Printed -"
    set winaspect 600
    set errtext "    The $what form for $PgmName version $TkzVer has been printed. "
    }


  69              {
    #  Don't send reg w/o reading directions...
    set winname ".badmail"
    set wintitle "$PgmName:    --  Newbie Alert!"
    set winhdr "- Newbie Alert! -"
    set winaspect 800
    set errtext "    You were asked to read the directions before sending a\
      Registration request or Bug Report. Please do so before trying this again."
    }


  70              {
    #  No mail w/o return addr...
    set winname ".badmail"
    set wintitle "$PgmName:    --  No E-mail"
    set winhdr "- No E-mail Address -"
    set winaspect 600
    set errtext "    You cannot send a Registration request or Bug Report without entering\
      a return e-mail address. Now, think about it...what good would that do?."
    }


  71              {
    #  Small screen warning... (obsolete)
    set scrw [lindex $ErrArgs 0]
    set scrh [lindex $ErrArgs 1]
    set winname ".smalscr"
    set wintitle "$PgmName:    --  Small Screen"
    set winhdr "- Small Screen Warning -"
    set winaspect 600
    set minw 800
    set minh 800
    set errtext "    This version ($TkzVer) of $PgmName has some windows that will\
      not entirely fit on your screen at the current resolution ($scrw x $scrh). A minimum\
      screen size of $minw x $minh is recommended.\
      \n    The System Info, Set Appearance, and Register windows may cause problems,\
      or at least annoyance, at the current resolution."
    }


  72              {
    #  Install complete...
    set instlog [lindex $ErrArgs 0]
    set winname ".instdone"
    set wintitle "$PgmName:    --  Install Done"
    set winhdr "- Installation Complete -"
    set winaspect 600
    set errtext "    Installation has finished for $PgmName version $TkzVer. The install log\
      has been saved as $instlog."
    }


  73              {
    #  Can't use "$*" with multiple or spacey filenames...
    set viewpgm [lindex $ErrArgs 0]
    set winname ".badvtag"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Illegal \"$*\" Tag -"
    set winaspect 600
    set errtext "    The \"$*\" tag used in your viewer definition for $viewpgm\
      cannot be used if you select multiple files or a filename containing embedded\
      spaces. (This tag is nearly obsolete, and has very limited application; its\
      use is discouraged.)"
    }


  74              {
    #  Converted old config to current release...
    set oldrel [lindex $ErrArgs 0]
    set winname ".updaterc"
    set wintitle "$PgmName:    --  Config File Update"
    set winhdr "- Old Config File Updated -"
    set winaspect 600
    set errtext "    A version $oldrel configuration file has been upgraded to\
      version $TkzVer."
    }


  75              {
    #  Converted a real old config to current release...
    set oldrel [lindex $ErrArgs 0]
    set dirname [lindex $ErrArgs 1]
    set oldoptfile [lindex $ErrArgs 2]
    set winname ".updaterc"
    set wintitle "$PgmName:    --  Config File Update"
    set winhdr "- Old Config File Updated -"
    set winaspect 600
    set errtext "    A $oldrel version configuration file has been upgraded to\
      the $TkzVer format. The old file ($oldoptfile) has been left in case you wish to\
      use it with an earlier version of $PgmName. If you do not, you should delete it. \
      The new configuration files are located in directory $dirname."
    }


  76              {
    #  Invalid MIME type...
    set winname ".badmime"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Invalid MIME Type Entry -"
    set winaspect 600
    set errtext "    The MIME type entry must have a viewer program specified, and it must\
      have either a tag (the unique identifying string returned by the file command) or a\
      file extension."
    }

  77              {
    #  Nothing selected to edit...
    set winname ".notsel"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Nothing Selected to Edit -"
    set winaspect 600
    set errtext "    You must select an entry from the MIME type list in order to edit or\
      delete an entry."
    } 

  78              {
    #  Tape Pos failed...
    set filename [lindex $ErrArgs 0]
    set winname ".notpos"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Tape Positioning Failed -"
    set winaspect 600
    set errtext "    Unable to position tape for $filename. Either you do not have a working\
      version of the mt command on your system, or it does not speak a dialect that $PgmName\
      understands."
    } 

  79              {
    #  Gotta close all windows before changing cache...
    set oldname [lindex $ErrArgs 0]
    set newname [lindex $ErrArgs 1]
    set winname ".cachec"
    set wintitle "$PgmName:    --  Cache Changed!"
    set winhdr "- Cache Changed -"
    set winaspect 600
    set errtext "    The cache directory has been successfully changed to $newname.\n      The old cache\
      ($oldname) has been deleted."
    } 

  80              {
    #  Gotta close all windows before changing cache...
    set oldname [lindex $ErrArgs 0]
    set winname ".nocachec"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Can't Change Cache -"
    set winaspect 600
    set errtext "    You must close all the other open $PgmName windows before changing the cache directory.\
      \n      This is necessary to empty the current cache ($oldname.)"
    } 

  81              {
    #  Can't create the new cache directory...
    set oldname [lindex $ErrArgs 0]
    set newname [lindex $ErrArgs 1]
    set winname ".nocache"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Can't Create Cache Directory -"
    set winaspect 600
    set errtext "    $newname could not be created for the cache directory. $PgmName is continuing to use the\
      old cache directory. The current cache is $oldname."
    } 

  82              {
    #  Can't add directory and suppress pathnames...
    set filename [lindex $ErrArgs 0]
    set winname ".nodirjpn"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Can't Add Directory -"
    set winaspect 600
    set errtext "    You cannot add a directory with the \"No Path Names\" option set. Think about it. \"No Path\
      Names\" directs us to strip the directory path component off all the filenames you selected.\n      Now, what\
      you selected is nothing but a directory path...do you see where we're heading with this?"
    } 

  83              {
    #  Can't compress into self...
    set filename [lindex $ErrArgs 0]
    set winname ".nodupc2"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Compress to Self -"
    set winaspect 600
    set errtext "    $PgmName does not allow compressing a file into itself. To compress $filename,\
      try using a standard suffix, or a different name."
    } 

  84              {
    #  Function not supported...
    set func [lindex $ErrArgs 0]
    set pgm [lindex $ErrArgs 1]
    set winname ".nofunc"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Function not Supported -"
    set winaspect 600
    set errtext "    There is no $func function supported by the $pgm program."
    } 

  85              {
    #  Extract failed...
    set filename [lindex $ErrArgs 0]
    set winname ".novext2"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Cpio View Failed -"
    set winaspect 600
    set errtext "    $filename cannot be extracted for viewing. cpio does not give\
      us the ability to extract a file with an absolute pathname (beginning with a \"/\")\
      to a temporary file for viewing."
    } 

  86              {
    #  Shorten Heuristic used...
    set filename [lindex $ErrArgs 0]
    set option [lindex $ErrArgs 1]
    set winname ".shnheur"
    set wintitle "$PgmName:    --  Not to Worry!"
    set winhdr "- Shorten Heuristic -"
    set winaspect 400
    set errtext "    $PgmName had to tinker with the Shorten options to create $filename. The option used was $option.\n\n    "
    } 

  87              {
    #  Delete failed...
    set lstname [lindex $ErrArgs 0]
    set errname [lindex $ErrArgs 1]
    set filename [lindex $ErrArgs 2]
    #  Non-portable...
    set errfltxt ""
    if {$TkzG(Portable)}  {
      if {[file size $errname] > 0}  {
        set ef ""
        catch {set ef [open $errname r]}     
        if {$ef != ""}  {
          while {[ gets $ef line ] > -1}  {
            set errfltxt "$errfltxt$line"
            }
          }
        catch {close $ef}
        }
      }  else  {
      set errfltxt [exec cat $errname]
      }
    set winname ".nodel"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Delete from Archive Failed -"
    set winaspect 300
    set errtext "    Attempt to delete member(s) from $filename failed. The command output has \nbeen saved in $lstname and $errname.\n\n    The \
      following is the text of the error message(s) returned.\n\n-------------------------------- \
      \n$errfltxt\n--------------------------------\n\n    "
    } 

  88              {
    #  Add failed...
    set lstname [lindex $ErrArgs 0]
    set errname [lindex $ErrArgs 1]
    set filename [lindex $ErrArgs 2]
    #  Non-portable...
    set errfltxt ""
    if {$TkzG(Portable)}  {
      if {[file size $errname] > 0}  {
        set ef ""
        catch {set ef [open $errname r]}     
        if {$ef != ""}  {
          while {[ gets $ef line ] > -1}  {
            set errfltxt "$errfltxt$line"
            }
          }
        catch {close $ef}
        }
      }  else  {
      set errfltxt [exec cat $errname]
      }
    set winname ".noadd"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Add toArchive Failed -"
    set winaspect 300
    set errtext "    Attempt to add member(s) to $filename failed. The command output has \nbeen saved in $lstname and $errname.\n\n    The \
      following is the text of the error message(s) returned.\n\n-------------------------------- \
      \n$errfltxt\n--------------------------------\n\n    "
    } 

  89              {
    #  Create failed...
    set lstname [lindex $ErrArgs 0]
    set errname [lindex $ErrArgs 1]
    set filename [lindex $ErrArgs 2]
    #  Non-portable...
    set errfltxt ""
    if {$TkzG(Portable)}  {
      if {[file size $errname] > 0}  {
        set ef ""
        catch {set ef [open $errname r]}     
        if {$ef != ""}  {
          while {[ gets $ef line ] > -1}  {
            set errfltxt "$errfltxt$line"
            }
          }
        catch {close $ef}
        }
      }  else  {
      set errfltxt [exec cat $errname]
      }
    set winname ".nocre"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Archive Creation Failed -"
    set winaspect 300
    set errtext "    Archive creation for $filename failed. The command output has \nbeen saved in $lstname and $errname.\n\n    The \
      following is the text of the error message(s) returned.\n\n-------------------------------- \
      \n$errfltxt\n--------------------------------\n\n    "
    } 

  90              {
    #  Extract failed...
    set viewname [lindex $ErrArgs 0]
    set filename [lindex $ErrArgs 1]
    set winname ".noview"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- View Failed -"
    set winaspect 600
    set errtext "    The external program  $viewname  could not be invoked to view  $filename. \n    It is\
      most likely not present on your system, or not in your path."
    } 

  91              {
    #  Extract failed...
    set lstname [lindex $ErrArgs 0]
    set errname [lindex $ErrArgs 1]
    set lstname2 [lindex $ErrArgs 2]
    set errname2 [lindex $ErrArgs 3]
    set arcpgm [lindex $ErrArgs 4]
    #  Non-portable...
    set errfltxt ""


    #  First try stderr...
    if {$TkzG(Portable)}  {
      if {[file size $errname2] > 0}  {
        set ef ""
        catch {set ef [open $errname2 r]}     
        if {$ef != ""}  {
          while {[ gets $ef line ] > -1}  {
            set errfltxt "$errfltxt$line"
            }
          }
        catch {close $ef}
        }
      }  else  {
      set errfltxt [exec cat $errname2]
      }

    if {$errfltxt == ""}  {
#puts "No stderr available..."
      #  OK, then try stdout...
      #  Only works for Rar, I think, and that rather badly.
      #  Until we can figure out how to strip unrar's stupid ascii art
      #  crap, ExtractItems will write its own generic extract-failed
      #  message to stderr, as with gzip/bzip, and this path won't
      #  be taken.
      if {$TkzG(Portable)}  {
        if {[file size $lstname2] > 0}  {
          set ef ""
          catch {set ef [open $lstname2 r]}     
          if {$ef != ""}  {
            while {[ gets $ef line ] > -1}  {
              set errfltxt "$errfltxt$line"
              }
            }
          catch {close $ef}
          }
        }  else  {
        set errfltxt [exec cat $lstname2]
        }

      }




    if {$TkzG(DseFlag)}  {
      set wesavedit ""
      }  else  {
      set wesavedit "The command output has been saved in $lstname and $errname."
      }
    set winname ".noext"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Extract Failed -"
    set winaspect 300
#    set errtext "    The Extract failed. $wesavedit\n\n    The \
#      following is the text of the error message(s) returned by $arcpgm.\n\n-------------------------------- \
#      \n$errfltxt\n--------------------------------\n\n    In some cases (most commonly a \
#      premature eof), the files you wanted may have been successfully extracted. $PgmName does not attempt to make \
#      that determination for you, because, even though a file may have been extracted, $PgmName has no way to verify \
#      its validity or integrity."
    set errtext "    The Extract failed. $wesavedit\n\n    \
      In some cases (most commonly a \
      premature eof), the files you wanted may have been successfully extracted. \
      $PgmName does not attempt to make \
      that determination for you, because, even though a file may have been \
      extracted, $PgmName has no way to verify \
      its validity or integrity.\n\n    \
      The \
      following is the text of the error message(s) returned by $arcpgm.\n\n-------------------------------- \
      \n$errfltxt\n--------------------------------\n\n    \
      "
    } 

  92              {
    #  View extract failed...
    set viewname [lindex $ErrArgs 0]
    set filename [lindex $ErrArgs 1]
    set winname ".novext"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- View Failed -"
    set winaspect 600
    set errtext "    $filename could not be extracted for viewing."
    } 

  93              {
    #  Rar Extract failed...
    set lstname [lindex $ErrArgs 0]
    set errname [lindex $ErrArgs 1]
    set lstname2 [lindex $ErrArgs 2]
    set errname2 [lindex $ErrArgs 3]
    #  unrar writes everything to stdout, nothing to stderr...
    set errfltxt ""
    if {$TkzG(Portable)}  {
      if {[file size $lstname2] > 0}  {
        set ef ""
        catch {set ef [open $lstname2 r]}     
        if {$ef != ""}  {
          while {[ gets $ef line ] > -1}  {
            set errfltxt "$errfltxt$line"
            }
          }
        catch {close $ef}
        }
      }  else  {
      set errfltxt [exec cat $lstname2]
      }
    if {$TkzG(DseFlag)}  {
      set wesavedit ""
      }  else  {
      set wesavedit "The command output has been saved in $lstname and $errname."
      }
    set winname ".noext"
    set wintitle "$PgmName:    --  Oops!"
    set winhdr "- Extract Failed -"
    set winaspect 300
    set errtext "    The Extract failed. $wesavedit\n\n    The \
      following is the text of the error message(s) returned.\n\n-------------------------------- \
      \n$errfltxt\n--------------------------------\n\n    If the archive is a \
      multi-part rar file, all the parts must be in the same source directory \
      as the file you originally opened. This is the most common cause of this \
      error."
    } 

  
  default        {
    #  A real bad thing just happened...
    set winname ".unkerr"
    set wintitle "$PgmName:    --  PROGRAM BUG:  Unknown Error ($gerrno) Raised"
    set winhdr "- Unknown Error Condition -"
    set winaspect 300
    set errtext "    An error condition (error code = $gerrno) has occurred for which no error handling \
      routine exists. This is a program bug, and generally considered a Bad Thing.\n    If you will \
      E-mail the author a brief description of what you were doing when this error occurred, he will \
      shamefacedly fix the bug for the next release. Please include the error number when reporting \
      this problem.\n    Registered users may receive the corrected version by E-mail."
    }

  }


set winname "$winname$tno"

if [catch {toplevel $winname}] {
  destroy $winname
  toplevel $winname
  }

wm title $winname $wintitle
frame $winname.f -bg $quitbg -highlightbackground $quitbg
frame $winname.f.f2 -width 20 -bg $quitbg -highlightbackground $quitbg
frame $winname.f.f3 -bg white
set cmd "destroy $winname"

button $winname.f.f2.quit -bg $wbutbg -fg $wbutfg -highlightbackground $wbutbg \
 -width 3 -text "$quitword" \
  -command $cmd
label $winname.f.f3.hdr -bg white -fg black \
  -font "-*-$TkzG(NonameFont)-bold-*-*-*-*-200-*-*-*-*-*-1"\
  -text $winhdr
message $winname.f.f3.msg -bg white -fg red -justify left -aspect $winaspect \
  -text $errtext 

pack $winname.f.f2.quit -pady 3 -expand no
pack $winname.f.f3.hdr -pady 6 
pack $winname.f.f3.msg -pady 6 -expand yes
#pack $winname.f.f2 $winname.f.f3 -side left
pack $winname.f.f2 -side left -padx 8 -pady 6 -expand no
pack $winname.f.f3 -side right
pack $winname.f

set rc 0

return $rc
}



#-----------------------------------------------------
#  GModMsgBox  --  general modal msg box
#    -- for the things where you have to answer yes-no
#    -- note that multiple concurrent instances of these
#       will get handled in a LIFO manner
#-----------------------------------------------------
proc GModMsgBox {owner gerrno} {
global PgmName ErrArgs TkzVer TmpNo MainBg MainFg MainButBg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg
global TkzG
set thisproc "GModMsgBox"

#  Defaults...
set maxerr 100
set quitword "No"
set quitbg "Red"
set yesword "Yes"
set wnum 0
set wbg $TwBg($wnum)
set wfg $TwFg($wnum)
set wbutbg $TwButBg($wnum)
set wbutfg $TwButFg($wnum)

set yesall  "Yes to all"
set noall   "No to all"
set giveup  "Cancel"

incr TmpNo
set tno $TmpNo

set act "Act$owner"
global $act
set action 0
set $act action


switch $gerrno {

  101              {
    #  Overwrite warning...
    set filename [lindex $ErrArgs 0]
    set winname ".ovwarn$owner$tno"
    set wintitle "$PgmName:    --  Overwrite Warning"
    set winhdr "  -  Overwriting Existing File!  -  "
    set winaspect 600
    set errtext "    File '$filename' already exists. Overwrite anyway?"
    } 

  102              {
    #  Debug warning...
    set dbdata $ErrArgs
    set winname ".dbwarn$owner$tno"
    set wintitle "$PgmName:    --  Debug Pause"
    set winhdr "-  Debug Pause  -"
    set winaspect 800
    set errtext "    Pausing for Debug. Debug data:\n\n  $dbdata \n\n    Continue?"
    } 
  
  103              {
    #  Delete Viewer warning...
    set viewname [lindex $ErrArgs 0]
    set winname ".vdwarn$owner$tno"
    set wintitle "$PgmName:    --  Delete Viewer Warning"
    set winhdr "-  Delete Viewer?  -"
    set winaspect 600
    set errtext "    Do you really wish to delete '$viewname' from the viewer list?"
    } 
  
  104              {
    #  Delete File warning...
    set filename [lindex $ErrArgs 0]
    set winname ".adwarn$owner$tno"
    set wintitle "$PgmName:    --  Delete File Warning"
    set winhdr "-  Delete File?  -"
    set winaspect 600
    set errtext "    Do you really wish to delete '$filename'?"
    } 

  105              {
    #  Overwrite warning...
    set filename [lindex $ErrArgs 0]
    set winname ".crwarn$owner$tno"
    set wintitle "$PgmName:    --  Overwrite Warning"
    set winhdr "-  Overwriting Existing File!  -"
    set winaspect 600
    set errtext "    File '$filename' already exists. Overwrite anyway?\
      \n\n    Please not that if you reply \"Yes\" the existing file will be deleted,\
      even if you cancel the Create Archive dialogue before you finish creating the new file."
    } 

  106              {
    #  Compress this file? query...
    set filename1 [lindex $ErrArgs 0]
    set filename2 [lindex $ErrArgs 1]
    set winname ".comprq$owner$tno"
    set wintitle "$PgmName:    --  Compress File?"
    set winhdr "-  Compress File  -"
    set winaspect 600
    set errtext "    Compress file '$filename1' as '$filename2'?    \n\n"
    } 
  
  107              {
    #  Delete File warning...
    set filename [lindex $ErrArgs 0]
    set winname ".adwarn$owner$tno"
    set wintitle "$PgmName:    --  Delete File Warning"
    set winhdr "-  Delete File?  -"
    set winaspect 600
    set errtext "    Do you really wish to delete '$filename'?"
    } 

  
  default        {
    #  Never heard of it...
    GErrMsgBox $gerrno
    return 0
    }

  }
  #  End switch...


if [catch {toplevel $winname}] {
  destroy $winname
  toplevel $winname
  }

wm title $winname $wintitle
frame $winname.f -bg $quitbg -highlightbackground $quitbg
frame $winname.f.f2 -width 20 -bg $quitbg -highlightbackground $quitbg
frame $winname.f.f3 -bg white

set cmd "set $act 0"
button $winname.f.f2.quit -bg $wbutbg -fg $wbutfg -highlightbackground $wbutbg \
  -width 8 -text "$quitword" \
  -command $cmd
set cmd "set $act 1"
button $winname.f.f2.doit -bg $wbutbg -fg $wbutfg -highlightbackground $wbutbg \
  -width 8 -text "$yesword" \
  -command $cmd

if {$gerrno == 101  || $gerrno == 107}  {
  set cmd "set $act 3"
  button $winname.f.f2.yall -bg $wbutbg -fg $wbutfg -highlightbackground $wbutbg \
    -width 8 -text "$yesall" \
    -command $cmd
  set cmd "set $act 2"
  button $winname.f.f2.nall -bg $wbutbg -fg $wbutfg -highlightbackground $wbutbg \
    -width 8 -text "$noall" \
    -command $cmd
  set cmd "set $act 4"
  button $winname.f.f2.getout -bg $wbutbg -fg $wbutfg -highlightbackground $wbutbg \
    -width 8 -text "$giveup" \
    -command $cmd
  }

label $winname.f.f3.hdr -bg white -fg black \
  -font "-*-$TkzG(NonameFont)-bold-*-*-*-*-200-*-*-*-*-*-1"\
  -text $winhdr
message $winname.f.f3.msg -bg white -fg red -justify left -aspect $winaspect \
  -text $errtext 

pack $winname.f.f2.doit -pady 3 -expand no
pack $winname.f.f2.quit -pady 3 -expand no
if {$gerrno == 101 || $gerrno == 107}  {
pack $winname.f.f2.yall -pady 3 -expand no
pack $winname.f.f2.nall -pady 3 -expand no
pack $winname.f.f2.getout -pady 3 -expand no
  }
pack $winname.f.f3.hdr -pady 6 
pack $winname.f.f3.msg -pady 6 -expand yes
#pack $winname.f.f2 $winname.f.f3 -side left
pack $winname.f.f2 -side left -padx 8 -pady 6 -expand no
pack $winname.f.f3 -side right
pack $winname.f

tkwait var $act
set action [set $act]
destroy $winname
unset $act

return $action

}




#-----------------------------------------------------------------------------
#  WarnOverWrite  --  Warn of overwriting an existing file -
#-----------------------------------------------------------------------------
proc WarnOverWrite {owner file}  {
global ErrArgs
global TkzG

set reply $TkzG(OvOpt)
if {$reply && $TkzG(OvWarn)}  {
  set ErrArgs [list $file]
  set action [GModMsgBox $owner 101]
  set reply $action
#  if {! $action}  {
##    puts "User said to don't do that."
#    set reply 0
#    }

  }
return $reply
}






#-----------------------------------------------------------------------------
#  Help  --  Very quick & very dirty
#-----------------------------------------------------------------------------
proc ShowHelp {context}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer MenuHelp
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg
global DSlidBg NumWins HelpTrail HelpGeom HelpPos HelpNav IconsOk
global clicky clicky1 clicky2 clickybg1 clickybg2
global TkzG


set thisproc "ShowHelp"

if {$MenuHelp && $context == 1}  {
  set MenuHelp 0
  ShowHelp 17
  return 1
  }

#set hbg "FloralWhite"
set bar ".main.list1.diry"
set wnum 102
set hbg $TwBg($wnum)
set hfg $TwFg($wnum)
set hlbg $TwLBg($wnum)
set hlfg $TwLFg($wnum)
set hbutbg $TwButBg($wnum)
set hbutfg $TwButFg($wnum)
set sbg $SlidBg($wnum)
set tcol $TrCol($wnum)

if {$sbg != "UseTk"}  {
  if {$sbg == "UseDefault"}  {
    set sbg $DSlidBg
    }  else  {
    set sbg $SlidBg($wnum)
    }
  }  else  {
  set tmp [$bar configure -bg]
  set sbg [lindex $tmp 3]
  }
if {$tcol != "UseTk"}  {
  if {$tcol == "UseBg"}  {
    set tcol $hbg
    }  else  {
    set tcol $TrCol($wnum)
    }
  }  else  {
  set tmp [$bar configure -troughcolor]
  set tcol [lindex $tmp 3]
  }




set win ".help"
set wintitle "$PgmName: Help"

set MaxHelp 65
if {$context > 0 && $context <= $MaxHelp}  {
  set context2 $context
  }  else  {
  set context2 999
  }


#if [catch {toplevel $win} rc]  {
#  set HelpGeom [wm geometry $win]
#  destroy $win
#  if [catch {toplevel $win} rc]  {
#    return -1
#    }
#  }  else  {
#  set HelpGeom ""
#  }
#  A much nicer way...
set HelpGeom ""
set helptext "$win.ht1"
set topl ""
set wsize ""
if [catch {toplevel $win} rc]  {
  raise $win
  set i [expr $HelpPos - 1]
  set dummy [lindex $HelpTrail $i]
  set oldcon [lindex $dummy 0]
  set helph1 [lindex [$helptext configure -height] 4]
  set helpp1 [$helptext yview]
  set helpt1 [list $oldcon $helph1 $helpp1]
  $helptext configure -state normal
  $helptext delete 0.1 end
  set buttons "$win.f2.but"
  # focus $win
  }  else  {

#-------------
  #  Build the window...
  # Define our widgets
  wm title $win $wintitle
  #  If we're cycling through help windows, try to keep 'em still...
  #  (obsolete...)
#  if {$HelpGeom != ""}  {
#    set i [string first "+" $HelpGeom]
#    if {$i == -1}  {
#      set i [string first "-" $HelpGeom]
#      }
#    if {$i != -1}  {
#      set HelpGeom [string range $HelpGeom $i end]
#      wm geometry $win $HelpGeom
#      }
#    }

  text $win.ht1
  scrollbar $win.sby
  frame $win.f2 


  set buttons [frame $win.f2.but]
  set cmd "BackHelp $win"
  button $buttons.hb1 -bg $hbutbg -fg $hbutfg \
    -state disabled -command $cmd
  set cmd "ForwardHelp $win"
  button $buttons.hb2 -bg $hbutbg -fg $hbutfg \
    -state disabled -command $cmd

  if {$IconsOk}  {
    $buttons.hb1 configure -image BakBut
    $buttons.hb2 configure -image ForBut
    }  else  {
    $buttons.hb1 configure -text "Back"
    $buttons.hb2 configure -text "Forward"
    }
  set cmd "KillHelp $win"
  button $buttons.hb3 -text "Dismiss" -bg $hbutbg -fg $hbutfg -command $cmd


  # Tell the window mgr how to put 'em together
  pack $buttons.hb1 $buttons.hb2 $buttons.hb3 -side left -anchor center

  pack $win.f2 -side top -anchor center -fill x 
  pack $buttons -side top
  pack $win.sby -side right -fill y
  pack $win.ht1 -fill both -expand yes
  $win.ht1 configure -fg black
#  $win.ht1 configure -height 20
#------------- end building new window...
  }


#-------------------
#  Help navigation...
  set tmp [llength $HelpTrail]
  if {! $HelpNav}  {
#    set HelpPos $tmp
#----------------

#----------------
    set tmp $HelpPos
    incr tmp -1
    set HelpTrail [lrange $HelpTrail 0 $tmp]
    if {$HelpPos > 0}  {
    #  Update last window's info...
    set i [expr $HelpPos - 1]
    set HelpTrail [lreplace $HelpTrail $i $i $helpt1]
    }
    set helph1 "24"
    set helpp1 [list 0 1]
    incr HelpPos
    set helpt [list $context $helph1 $helpp1]
#    set HelpTrail [string trim "$HelpTrail $context"]
    lappend HelpTrail $helpt
    }  else  {
    set i [expr $HelpPos - 1]
    set helpt1 [lindex $HelpTrail $i]
    set helpg1 [lindex $helpt1 1]
#    set i [string first "+" $helpg1]
#    if {$i == -1}  {
#      set i [string first "-" $helpg1]
#      }
#    incr i -1
#    set wsize [string range $helpg1 0 $i]
    set wsize $helpg1
    set helpp1 [lindex $helpt1 2]
    set topl [lindex $helpp1 0]
    }
#  set HelpNav 0
  set helpb 0
  set helpf 0

  if {$HelpTrail != "" && $HelpPos > 1}  {
    set helpb 1
    if {$IconsOk}  {
      BakBut configure -foreground black
      }
    $buttons.hb1 configure -state normal
    }  else  {
    $buttons.hb1 configure -state disabled
    }
  if {$HelpTrail != "" && $HelpPos < $tmp}  {
    set helpf 1
    if {$IconsOk}  {
      ForBut configure -foreground black
      }
    $buttons.hb2 configure -state normal
    }  else  {
    $buttons.hb2 configure -state disabled
    }


#-------------------

  # Now set up the text
  # Define some styles
#  set clicky1 "Red4"
#  set clicky2 "Green4"
  $win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
  $win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
  $win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*
  $win.ht1 tag configure reallybig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-180-*-*-*-*-*-*
  $win.ht1 tag configure cbig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* -justify center
  $win.ht1 tag configure creallybig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-180-*-*-*-*-*-* -justify center
  $win.ht1 tag configure center -justify center
  $win.ht1 tag configure heading -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-240-*-*-*-*-*-* -justify center
  $win.ht1 tag configure raised -relief raised -borderwidth 3
  $win.ht1 tag configure hilite -foreground red
  $win.ht1 tag configure italic -font -*-$TkzG(NonameFont)-*-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*



switch $context2  {

	1		{

    		  set text "    $PgmName is a graphical front end to most of the popular (and some fairly\
    		    obscure) archiving and compression utilities found on Unix systems. It runs under all\
    		    releases of Tcl/Tk back to 7.4/4.0 (though some features are disabled under Tk releases\
    		    prior to 4.2). \
		    \n    Context Help is available via a Button-3 (right button) click on most buttons and\
		    menu items in the main windows.\n"

		  $win.ht1 insert end "\n$PgmName\n\n" heading
		  $win.ht1 insert end "$text" italic

                  #  Explain Command Line
                  Help1a $win 0


                  #  Explain Main Window
                  Help1b $win 0

		  $win.ht1 insert end "\n\nThe Buttons" cbig
		  $win.ht1 insert end "\n    (For help on individual buttons or menu items, right-click (button 3) on the\
		    button or menu item - except for trivial buttons like \"OK\" or \"Cancel\".)" normal

                  #  Explain Exit
                  Help01 $win 0

                  #  Explain the File menu
                  Help02a $win 0

                  #  Explain the Options menu
                  Help07 $win 0

                  #  Explain the Help menu
                  Help15 $win 0

                  #  Explain Entry Field
                  Help1c $win 0
                  #  Explain Archive Directory Window
                  Help1d $win 0

		  $win.ht1 insert end "\n\nThe Buttons" cbig
		  $win.ht1 insert end "\n\nClose        " big
		  $win.ht1 insert end "\n    Does just what you would expect it to. Closes the archive view." normal 
		  $win.ht1 insert end "\n\nSelect All   " big
		  $win.ht1 insert end "\n    Do you really need to ask? Selects all files in the current archive. Actually, it toggles between\
		    \"Select All\" and \"Deselect All\"." normal 
		  $win.ht1 insert end "\n\nView         " big
		  $win.ht1 insert end "\n    Has the same effect as double-clicking an entry in the file list. Invokes an external viewing\
		    program for the selected item. If more than one item in the list is selected, it will only spawn a viewer for the first\
		    selected file." normal 
		  $win.ht1 insert end "\n\nExtract      " big
		  $win.ht1 insert end "\n    Extracts all selected items from the archive. Opens a directory selection window for you to\
		    choose the directory into which you wish to extract the files. " normal 


                  Help24 $win 0
                  Help25 $win 0
                  #  Explain Select Viewer
                  Help26 $win 0

                  #  Explain Entry Fields
                  Help1e $win 0

		}

	default   {
                set helpcmd "Help$context2 $win 1"
                eval $helpcmd
		}

	}

# Set the other attributes

if {$topl != ""}  {
  $helptext yview moveto $topl
  $helptext configure -height $wsize
  }
set HelpNav 0
set ycmd "$win.sby set"
$win.ht1 configure -bg $hlbg -fg $hlfg -wrap word -state disabled \
  -yscroll $ycmd 
$win.f2 configure -bg $hbg
set ycmd "$win.ht1 yview"
$win.sby configure -command $ycmd

set wno 102
ConfigureScrollbar $win.sby $wno 0

return 1
}


#-----------------------------------------------------------------------------
#  KillHelp  --  Kill the Help window
#-----------------------------------------------------------------------------
proc KillHelp {win}  {
global HelpTrail HelpGeom HelpPos HelpNav
global TkzG

set HelpTrail ""
set HelpGeom ""
set HelpPos 0
set HelpNav 0
destroy $win

return
}


#-----------------------------------------------------------------------------
#  BackHelp  --  Cycle to previous Help window
#-----------------------------------------------------------------------------
proc BackHelp {win}  {
global HelpTrail HelpPos HelpNav
global TkzG


set thisproc "BackHelp"
set HelpNav 1
set i [llength $HelpTrail]
if {$i < 2 || $HelpPos < 2}  {
  KillHelp $win
  return
  }
#-------------
set helptext "$win.ht1"
set i [expr $HelpPos - 1]
set dummy [lindex $HelpTrail $i]
set oldcon [lindex $dummy 0]
set helph1 [lindex [$helptext configure -height] 4]
set helpp1 [$helptext yview]
set helpt1 [list $oldcon $helph1 $helpp1]
set HelpTrail [lreplace $HelpTrail $i $i $helpt1]
#-------------
#  Last entry is where we are...back up 2.
incr HelpPos -1
set i [expr $HelpPos - 1]
set helpt [lindex $HelpTrail $i]
set context [lindex $helpt 0]

ShowHelp $context

return
}


#-----------------------------------------------------------------------------
#  ForwardHelp  --  Cycle to next Help window
#-----------------------------------------------------------------------------
proc ForwardHelp {win}  {
global HelpTrail HelpPos HelpNav
global TkzG


set thisproc "ForwardHelp"
set HelpNav 1
set i [llength $HelpTrail]
if {$HelpPos > $i}  {
#  KillHelp $win
  return
  }
#-------------
set helptext "$win.ht1"
set i [expr $HelpPos - 1]
set dummy [lindex $HelpTrail $i]
set oldcon [lindex $dummy 0]
set helph1 [lindex [$helptext configure -height] 4]
set helpp1 [$helptext yview]
set helpt1 [list $oldcon $helph1 $helpp1]
set HelpTrail [lreplace $HelpTrail $i $i $helpt1]
#-------------
#  Last entry is where we are...move up 1.
incr HelpPos 
set i [expr $HelpPos - 1]
set helpt [lindex $HelpTrail $i]
set context [lindex $helpt 0]

ShowHelp $context

return
}


#-----------------------------------------------------------------------------
#  Help 1a  --  Explain the Command Line
#-----------------------------------------------------------------------------
proc Help1a {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help1a"

if {$only}  {
  $win.ht1 configure -height 16
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*
$win.ht1 tag configure cbig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* -justify center
$win.ht1 tag configure creallybig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-180-*-*-*-*-*-* -justify center

$win.ht1 insert end "\nCommand Line" creallybig
$win.ht1 insert end "\n    The program has a few command line arguments that should rarely be\
  needed (except for filename)." normal 
$win.ht1 insert end "\n\n$PgmName   --version   --debug --adm --ForceInstall --pipein  \
  --iconic --nomain --LastCloseExits   filename" cbig

$win.ht1 insert end "\n\n--version,  -v        " big
$win.ht1 insert end "\n    Echoes the current version to stdout and exits." normal 
$win.ht1 insert end "\n\n--debug        " big
$win.ht1 insert end "\n    Causes the undocumented Debug Mode option to be inserted in the\
  Options menu. It does not actually turn on debugging, it just enables it.\
  \n    Debug Mode is release dependent, and is not intended for use other than in consultation\
  with the author to try to diagnose problems. Turning on Debug Mode may cause apparent\
  capricious behavior in otherwise sensible program functions, as well as unwanted clutter in\
  your home directory." normal 
$win.ht1 insert end "\n\n--adm           " big
$win.ht1 insert end "\n    Enables SysAdmin functions. You must actually be the SysAdmin (root)\
  for them to work." normal 
$win.ht1 insert end "\n\n--ForceInstall  " big
$win.ht1 insert end "\n    Causes $PgmName's AutoInstall function to run without user intervention,\
  installing $PgmName's files in the default locations. This has the same effect as setting the\
  ForceInstall option under the Options menu." normal 
$win.ht1 insert end "\n\n--pipein        " big
$win.ht1 insert end "\n    Causes $PgmName to attempt to read an archive file from stdin and\
  open it. This feature is rarely useful, and its behavior is inconsistent: it has been known\
  to fail unpredictably. Its use is not recommended, and it will likely be removed from a\
  future release." normal 
$win.ht1 insert end "\n\n--iconic        " big
$win.ht1 insert end "\n    Causes the main window to be iconified on startup. If\
  a filename was given, the archive directory window is not created iconic, just\
  the main window." normal 
$win.ht1 insert end "\n\n--nomain        " big
$win.ht1 insert end "\n    If a filename was given, only the archive directory\
  window for that file is created; the main window does not appear. If no file\
  was specified for opening, this argument has no effect." normal 
$win.ht1 insert end "\n\n--LastCloseExits" big
$win.ht1 insert end "\n    When the last archive directory window is closed, $PgmName\
  automatically exits. (--nomain implicitly sets --LastCloseExits.)" normal 

$win.ht1 insert end "\n\nfilename        " big
$win.ht1 insert end "\n    If a file name is given on the command line, the program opens an\
  archive directory window for that file." normal 


return 1
}


#-----------------------------------------------------------------------------
#  Help 1b  --  Explain Main Window
#-----------------------------------------------------------------------------
proc Help1b {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help1b"

if {$only}  {
  $win.ht1 configure -height 10
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*
$win.ht1 tag configure cbig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* -justify center
$win.ht1 tag configure creallybig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-180-*-*-*-*-*-* -justify center

$win.ht1 insert end "\n\nMain Window" creallybig
$win.ht1 insert end "\n    The main screen provides a scrolling directory/file list from which you select\
  the archive which you want to operate on. Double-click on the file you want to look at to open it. You may\
  open as many archive view windows as you wish.\
  \n    Single-clicking with Button-1 (left button) selects an item. A Button-3 click will pop up a\
  \"What's This?\" window that itentifies the type of file that is selected." normal 
#$win.ht1 insert end "\n\nThe Buttons" cbig
#$win.ht1 insert end "\n    (For help on individual buttons or menu items, right-click (button 3) on the\
#  button or menu item - except for trivial buttons like \"OK\" or \"Cancel\".)" normal

return 1
}


#-----------------------------------------------------------------------------
#  Help 1c  --  Explain Main Window Entry Field
#-----------------------------------------------------------------------------
proc Help1c {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help1c"

if {$only}  {
  $win.ht1 configure -height 10
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*
$win.ht1 tag configure cbig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* -justify center
$win.ht1 tag configure creallybig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-180-*-*-*-*-*-* -justify center

$win.ht1 insert end "\n\nMain Window Entry Fields" cbig
$win.ht1 insert end "\n\nCurrent Directory:       " big
$win.ht1 insert end "\n    This field is updated as you navigate through the directory tree, but if\
  you get impatient (\"Hell, I just want to get to '/'\") or really like typing long pathnames,\
  just enter a directory name here and hit enter." normal
 
return 1
}


#-----------------------------------------------------------------------------
#  Help 1d  --  Explain Archive Directory Window
#-----------------------------------------------------------------------------
proc Help1d {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help1d"

if {$only}  {
  $win.ht1 configure -height 10
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*
$win.ht1 tag configure cbig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* -justify center
$win.ht1 tag configure creallybig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-180-*-*-*-*-*-* -justify center

$win.ht1 insert end "\n\nArchive Directory Window" creallybig
$win.ht1 insert end "\n    This provides a scrolling list from which you select\
  the files on which you want to operate. Double-click on a file you want to look\
  at to view it.
  \n    Single-clicking with Button-1 (left button) selects an item. To select multiple items,\
  either drag-select a contiguous range of items or select items with Ctl-Button-1.\
  A Button-3 click will pop up a \"What's This?\" window that itentifies the type(s) of file(s)\
  selected.\
  \n    To locate one or more directory entries containing a given string, click\
  on the directory list with Button 2 (middle button) to pop up a Find dialogue.\
  \n    (Due to limitations of the MS Windows environment, Windows users must use Button-3 (right\
  button), and click on the background of the upper part of the window - above the directory list -\
  to activate the Find function)" normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 1e  --  Explain Archive Directory Entry Fields
#-----------------------------------------------------------------------------
proc Help1e {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global clicky clicky1 clicky2 clickybg1 clickybg2
global TkzG
set thisproc "Help1e"

if {$only}  {
  $win.ht1 configure -height 16
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure normlink26 -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*
$win.ht1 tag configure cbig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* -justify center
$win.ht1 tag configure creallybig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-180-*-*-*-*-*-* -justify center
$win.ht1 tag bind normlink26 <1> "ShowHelp 26"

$win.ht1 insert end "\n\nArchive Directory Entry Fields" cbig
$win.ht1 insert end "\n\nViewer       " big
$win.ht1 insert end "\n    A descriptive name for the viewer. When this field says \"User defined\", both fields are made\
  enterable, and you may enter the viewer of your choosing. If you do not enter a descriptive name, the name of the binary\
  will be used by default." normal 
$win.ht1 insert end "\n\nExecutable   " big
$win.ht1 insert end "\n    The actual name of the executable binary. If you hit Enter (Return) while in this field, this viewer\
  will be added to the " normal 

$win.ht1 insert end "\"Select Viewer\"" normlink26 

$win.ht1 insert end " menu. Otherwise, this viewer will be used only so long as it appears in this field, but\
  will be forgotten when you select another viewer.\n    The viewer selection is unique to each opened window. Changing the\
  selection for one window does not alter the selected viewer for other windows. However, the\
  selection menu is global: adding a viewer updates the menu for all windows. If you Save Options,\
  any additions you have made to the viewer list will be saved." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 01  --  Explain Exit (sheesh!)
#-----------------------------------------------------------------------------
proc Help01 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help01"

if {$only}  {
  $win.ht1 configure -height 7
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*

$win.ht1 insert end "\n\nExit        " big
$win.ht1 insert end "\n    Does just what you would expect it to. Closes all windows and terminates the program." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 02a  --  Explain the File menu
#-----------------------------------------------------------------------------
proc Help02a {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help02a"

$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*

$win.ht1 insert end "\n\nFile        " big

Help02 $win 0
Help03 $win 0
Help04 $win 0
Help05 $win 0
Help06 $win 0

return 1
}


#-----------------------------------------------------------------------------
#  Help 02  --  Explain Exit again
#-----------------------------------------------------------------------------
proc Help02 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help02"

if {$only}  {
  $win.ht1 configure -height 6
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Exit              " bold
$win.ht1 insert end "\n      Just like the main Exit button." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 03  --  Explain New Archive
#-----------------------------------------------------------------------------
proc Help03 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global clicky clicky1 clicky2 clickybg1 clickybg2
global TkzG
set thisproc "Help03"

if {$only}  {
  $win.ht1 configure -height 18
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure normlink24 -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure normlink20 -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure normlink34 -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure em -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure italic -font -*-$TkzG(NonameFont)-*-I-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag bind normlink24 <1> "ShowHelp 24"
$win.ht1 tag bind normlink20 <1> "ShowHelp 20"
$win.ht1 tag bind normlink34 <1> "ShowHelp 34"

$win.ht1 insert end "\n  New Archive    " bold
$win.ht1 insert end "\n      Opens a Create Archive dialogue. First, you will be\
  presented with a \"Name That File\" window.\
  Check the type of archive you want to create, and enter the name you want to\
  give it. Double-clicking on a name in the file list causes that name to be\
  inserted into the name entry field (with the standard name extension appended).\
  You will be warned if the name you picked\
  is a file that already exists."

$win.ht1 insert end "\n    Express Compress: " em

$win.ht1 insert end "To create a simple compressed file, just check the type,\
  double-click on the name of the file you want to compress,\
  then click the \"Create\" button. This will bypass the rest of\
  the archive creation dialogue and just create a compressed version of the file\
  with the standard name extension."

$win.ht1 insert end "\n    If you proceed with the archive creation dialogue,\
  you will then get a directory list of an \"empty\"\
  archive or compressed file (it doesn't actually exist at this point), with only\
  the " normal

$win.ht1 insert end "\"Add\"" normlink24

$win.ht1 insert end " and " normal

$win.ht1 insert end "\"Close\"" normlink20

$win.ht1 insert end " buttons active. Use the Add function to select one or\
  more files, as appropriate, to archive or compress. If you close the window without\
  adding anything, your new file will not be created.\
  \n    You may find that $PgmName has played games with the name you selected. This\
  is because it tries to mimic the behavior (whether desirable or not) of the target\
  archiving programs. If you try to create a tar called \"Some-old-goofy-stuff\", then\
  that's what $PgmName will call it, because tar is perfectly happy with that. But, if\
  you try to create a zip by the same name, $PgmName will call it \"Some-old-goofy-stuff.zip\",\
  because that's what zip will change the name to. (No, you can't override this behavior.\
  Get a job.)\n      If the " normal

$win.ht1 insert end "\"Use Standard Name Extensions\"" normlink34

$win.ht1 insert end " option is checked, $PgmName will\
  always enforce standard naming conventions. Also, all names entered by double-clicking in\
  the file list get standard extensions, regardless of the state of this option." normal 

$win.ht1 insert end "\n    Warning: " em

$win.ht1 insert end "If you choose the name of an existing file for your new archive,\
  and respond \"Yes, delete it\" to the warning message you get, the existing file\
  is deleted immediately. Even if you later cancel the dialogue without creating\
  the new archive, the old file is gone forever. Be careful."

$win.ht1 insert end "\n    Note: " em

$win.ht1 insert end "Creation, updating, or deletion of archive files on a device (" normal
$win.ht1 insert end "e.g.," italic
$win.ht1 insert end " /dev/rmt0 or /dev/fd0) is not supported in $PgmName Release\
  $TkzVer.\n" normal

return 1
}


#-----------------------------------------------------------------------------
#  Help 04  --  Explain Open Archive
#-----------------------------------------------------------------------------
proc Help04 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help04"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Open Archive      " bold
$win.ht1 insert end "\n      Opens a view window for the currently selected archive, displaying its directory contents\
  in a scrolling window. Has the same effect as double clicking on the filename. \n      $PgmName will attempt to\
  determine the type of archive file it is, and invoke the appropriate\
  program to read it." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 05  --  Explain Delete Archive
#-----------------------------------------------------------------------------
proc Help05 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help05"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Delete Archive    " bold
$win.ht1 insert end "\n      Deletes the currently selected file.\n      Note that this is a simple utility file\
  delete function. The file need not be an archive of any sort. No check is made of the file type: any kind of\
  file can be deleted." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 06  --  Explain Show Sys Info
#-----------------------------------------------------------------------------
proc Help06 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help06"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Show System Info      " bold
$win.ht1 insert end "\n      Opens a window showing various system configuration information, such as the $PgmName release\
  and build date, and the Tcl/Tk release you're using. Among other things, it shows a\
  checklist of which of the archive programs needed by $PgmName were or were not located on your system." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 07  --  Explain the Options menu
#-----------------------------------------------------------------------------
proc Help07 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help07"

$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*

$win.ht1 insert end "\n\nOptions     " big

Help08 $win 0
Help09 $win 0
Help10 $win 0
Help11 $win 0
Help12 $win 0
Help13 $win 0
Help27 $win 0
Help28 $win 0
Help29 $win 0
Help30 $win 0
Help31 $win 0
Help32 $win 0
Help33 $win 0
Help34 $win 0
Help35 $win 0
Help36 $win 0
Help44 $win 0
Help47 $win 0
Help14 $win 0
#Help37 $win 0
Help45 $win 0
Help46 $win 0
Help48 $win 0
Help49 $win 0
Help38 $win 0
Help39 $win 0
Help40 $win 0
Help41 $win 0
Help43 $win 0
Help50 $win 0
Help52 $win 0
Help60 $win 0
Help61 $win 0
Help42 $win 0
Help62 $win 0
Help63 $win 0
#		  $win.ht1 insert end "\n\n      There may be other checkbuttons on the menu as placeholders, but as of this release, they have no\
#		    effect, and should be permanently greyed out." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 08  --  Explain Show Archives Only
#-----------------------------------------------------------------------------
proc Help08 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help08"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Show Archives Only" bold
$win.ht1 insert end "\n      Toggles the file list view between displaying all files and displaying only files with commonly\
  recognized archive type extensions. An archive need not have a recognizable extension to be selected and viewed,\
  but this option limits the file list display to recognizable file names.\
  \n      This option has no effect when you enter the /dev directory. Instead the list is constrained to display only those\
  raw devices the program recognizes as commonly used archive devices, like rmt0, fd0, etc." normal 


return 1
}


#-----------------------------------------------------------------------------
#  Help 09  --  Explain Warn of Overwrites
#-----------------------------------------------------------------------------
proc Help09 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help09"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Warn of Overwrites" bold
$win.ht1 insert end "\n      When set, this causes a warning window to pop up whenever extracting a file would overwrite an\
  existing file. Setting this option unsets the \"Never Overwrite\" option. The two are mutually exclusive." normal 


return 1
}


#-----------------------------------------------------------------------------
#  Help 10  --  Explain Never Overwrite
#-----------------------------------------------------------------------------
proc Help10 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help10"

if {$only}  {
  $win.ht1 configure -height 10
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Never Overwrite Existing Files" bold
$win.ht1 insert end "\n      When set, extract quietly passes over any existing files that it would otherwise overwrite. Setting\
  this option unsets the \"Warn of Overwrites\" option.\n      This option is currently unconditional: there are no refinements\
  like \"only overwrite older/newer files.\" These niceties are for a future release." normal 


return 1
}


#-----------------------------------------------------------------------------
#  Help 11  --  Explain ITG
#-----------------------------------------------------------------------------
proc Help11 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help11"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Ignore Gnu \"trailing garbage\" Message" bold
$win.ht1 insert end "\n      Gnu gzip sometimes produces a message about \"ignoring trailing garbage\" when reading from a\
  device. Setting this option will cause $PgmName not to pop up a warning box when this occurs.\n      The option\
  makes no difference, operationally. It is purely cosmetic. The archive is perfectly usable in\
  either case, but the message sometimes alarms novices and annoys experienced users. This option is set on by default." normal 


return 1
}


#-----------------------------------------------------------------------------
#  Help 12  --  Explain Improved Tar Detection
#-----------------------------------------------------------------------------
proc Help12 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help12"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Improved Tar Detection" bold
$win.ht1 insert end "\n      Some brain-damaged Unices do not respond gracefully\
  to $PgmName's method of identifying a tar. If $PgmName fails to recognize tars,\
  set this option to make it try extra hard. This option is set off by default,\
  as it has been known to cause problems with some non-GNU tars." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 13  --  Explain Don't Probe
#-----------------------------------------------------------------------------
proc Help13 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help13"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Don't Probe Compressed Files" bold
$win.ht1 insert end "\n      By default, $PgmName will examine compressed files to see whether they contain a tar, and if so, will\
  open up the directory of the tar instead of showing you the contents of the compressed file. Unfortunately, this makes it a bit\
  awkward if all you want to do is uncompress the tar; in fact, you can't do it. Check this option to change that." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 14  --  Explain Save Options
#-----------------------------------------------------------------------------
proc Help14 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help14"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Save Options" bold
$win.ht1 insert end "\n      Clicking this button will cause various program options, including the present configuration of the\
  viewer list, to be written to the user's configuration file, \$Home/.$PgmName/$PgmName.rc. This file, if it exists, is read at startup to\
  override any default options." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 15  --  Explain Help
#-----------------------------------------------------------------------------
proc Help15 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help15"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*

$win.ht1 insert end "\n\nHelp        " big
$win.ht1 insert end "\n      Many items under the Help menu are cross-linked. Single click on any\
  text highlighted in red to follow the link. (Hint:  if you customize the appearance of the Help\
  windows, red might not be a good choice for the list/text background color, since the links will\
  become unreadable.)\
  \n      Context Help can also be obtained by Button-3 (right button) clicking most\
  buttons and menu items in the main and archive directory windows." normal 

Help16 $win 0
Help51 $win 0
Help17 $win 0
Help18 $win 0
Help19 $win 0
Help54 $win 0
Help64 $win 0
Help65 $win 0

return 1
}


#-----------------------------------------------------------------------------
#  Help 16  --  Explain Help About
#-----------------------------------------------------------------------------
proc Help16 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help16"

if {$only}  {
  $win.ht1 configure -height 6
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  About             " bold
$win.ht1 insert end "\n      The obligatory legalese. Pops up the first time you run $PgmName (or if you\
  delete \$Home/.$PgmName/$PgmName.rc)." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 17  --  Explain Help Help - isn't this going a bit far...?
#-----------------------------------------------------------------------------
proc Help17 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help17"

if {$only}  {
  $win.ht1 configure -height 6
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Help              " bold
$win.ht1 insert end "\n      Pops up the whole Help file, unindexed. Not for the\
  faint of heart. Recommended for insomniacs." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 18  --  Explain Help Register
#-----------------------------------------------------------------------------
proc Help18 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help18"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Register $PgmName    " bold
$win.ht1 insert end "\n      Opens an entry window for entering a registration form. You may elect to send the completed form to the\
  author via Internet E-mail, or to save it as a text file." normal

return 1
}


#-----------------------------------------------------------------------------
#  Help 19  --  Explain Help Bug Report
#-----------------------------------------------------------------------------
proc Help19 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help19"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Bug Report/Comment    " bold
$win.ht1 insert end "\n      Opens an entry window for sending a bug report or comment to the author. \
  You may elect to send the completed form via Internet E-mail, or to save it as a text file to send via some other means." normal

return 1
}


#-----------------------------------------------------------------------------
#  Help 20  --  Explain Close button
#-----------------------------------------------------------------------------
proc Help20 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help20"

if {$only}  {
  $win.ht1 configure -height 6
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*

$win.ht1 insert end "\n\nClose        " big
$win.ht1 insert end "\n    Does just what you would expect it to. Closes the archive view." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 21  --  Explain Select All button
#-----------------------------------------------------------------------------
proc Help21 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help21"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*

$win.ht1 insert end "\n\nSelect All   " big
$win.ht1 insert end "\n    Do you really need to ask? Selects all files in the current archive. Actually, it toggles between\
  \"Select All\" and \"Deselect All\"." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 22  --  Explain View button
#-----------------------------------------------------------------------------
proc Help22 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global clicky clicky1 clicky2 clickybg1 clickybg2
global TkzG
set thisproc "Help22"

if {$only}  {
  $win.ht1 configure -height 10
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure normlink39 -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*
$win.ht1 tag bind normlink39 <1> "ShowHelp 39"

$win.ht1 insert end "\n\nView         " big
$win.ht1 insert end "\n    Has the same effect as double-clicking an entry in the file list. Invokes an external viewing\
  program for the selected item. If more than one item in the list is selected, it will only spawn a viewer for the first\
  selected file, unless the " normal 

$win.ht1 insert end "\"View Multiple Files\"" normlink39

$win.ht1 insert end " option is set." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 23  --  Explain Extract button
#-----------------------------------------------------------------------------
proc Help23 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help23"

if {$only}  {
  $win.ht1 configure -height 15
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*

$win.ht1 insert end "\n\nExtract      " big
$win.ht1 insert end "\n    Extracts all selected items from the archive. Opens a directory selection window for you to\
  choose the directory into which you wish to extract the files.\n" normal 

Help23a $win 0
Help23b $win 0


return 1
}


#-----------------------------------------------------------------------------
#  Help 23a  --  Explain Extract options
#-----------------------------------------------------------------------------
proc Help23a {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help23a"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n    Extract Options  " bold
$win.ht1 insert end "\n    Checkboxes for various extraction options are available\
  where suitable to the type of archive.\
  \n    \"Absolute Pathnames\", \"Absolute Pathnames\", and \"No Pathnames\" are\
  mutually exclusive. \"Absolute Pathnames\" means that files will be extracted\
  with their full pathnames, including a leading \"/\". \"No Path Names\" means\
  that files will be extracted with directory names stripped off.\
  If neither of these options is checked, files will be extracted with a full\
  pathname, but no leading \"/\".\n" normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 23b  --  Explain Extract control buttons
#-----------------------------------------------------------------------------
proc Help23b {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help23b"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n    Extract Control Buttons  " bold
$win.ht1 insert end "\n    After you have selected the directory into which you\
  wish to extract the files, click the \"Extract\" button to extract them, or\
  click the \"Cancel\" to leave without doing anything." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 24  --  Explain Add button
#-----------------------------------------------------------------------------
proc Help24 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help24"

if {$only}  {
  $win.ht1 configure -height 20
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure italicn -font -*-$TkzG(NonameFont)-*-I-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n\nAdd          " big
$win.ht1 insert end "\n    Opens an Add Members dialogue to allow you to build a\
  selection list of files to add to the archive. Normally, this function is only\
  available for archive type files, which contain multiple members. You cannot\
  add \"members\" to simple compressed files: they don't have members.\
  \n    An exception to this rule is the creation of a new archive. In this case,\
  you are presented with a directory list of an \"empty\" archive or compressed file,\
  and the \"Add\" button should be the only button active. This allows you to select\
  one or more files, as appropriate, to archive or compress.\n" normal 

Help24c $win 0

$win.ht1 insert end "    Note: " em

$win.ht1 insert end "Creation, updating, or deletion of archive files on a device (" normal
$win.ht1 insert end "e.g.," italicn
$win.ht1 insert end " /dev/rmt0 or /dev/fd0) is not supported in $PgmName Release\
  $TkzVer.\n" normal

Help24a $win 0
Help24b $win 0

  $win.ht1 insert end "\n    Warning: " bold

  $win.ht1 insert end "Note that $PgmName does not attempt to prevent your adding members with\
  duplicate names to a tar. Different implementations of tar may vary in their ability\
  to deal with this situation, but as a general rule you are not likely to be\
  pleased with the results if you try it.  \n" normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 24a  --  Explain Add options
#-----------------------------------------------------------------------------
proc Help24a {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help24a"

if {$only}  {
  $win.ht1 configure -height 15
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n    Add Options  " bold
$win.ht1 insert end "\n    Checkboxes for various Add options are available\
  where suitable to the type of archive.\
  \n    \"Absolute Pathnames\", \"Relative Pathnames\", and \"No Pathnames\" are\
  mutually exclusive. \"Absolute Pathnames\" means that files will be added with their\
  full pathnames, including a leading \"/\". \"Relative Pathnames\" means that\
  files will be added with no leading \"/\", and pathnames relative to the current\
  directory. \"No Path Names\" means that files will be added with no directory names.\
  If none of these options is checked, files will be added with a full pathname, but\
  no leading \"/\".\
  \n    \"Recurse Subdirectories\" is really only an available option for zip, but will appear\
  checked or not, depending on the behavior of the archive program being used.\n" normal

return 1
}


#-----------------------------------------------------------------------------
#  Help 24b  --  Explain Add control buttons
#-----------------------------------------------------------------------------
proc Help24b {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help24b"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n    Add Control Buttons  " bold
$win.ht1 insert end "\n    Select the files you want to add using the mouse,\
  then click the \"Add to Archive\" button to add them to the archive. Or, click\
  \"Cancel\" to leave without doing anything.\n" normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 24c  --  Explain no defer-till-close updating
#-----------------------------------------------------------------------------
proc Help24c {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help24c"

if {$only}  {
  $win.ht1 configure -height 4
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure italic -font -*-$TkzG(NonameFont)-*-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "    Note:  " bold 
$win.ht1 insert end "Archive update operations (Add and Delete) are " normal 
$win.ht1 insert end "immediate. " italic 
$win.ht1 insert end "There is no \"defer commit till close\" style of updating\
  in $PgmName Release $TkzVer.\n" normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 25  --  Explain Delete button
#-----------------------------------------------------------------------------
proc Help25 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help25"

if {$only}  {
  $win.ht1 configure -height 13
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*
$win.ht1 tag configure italicn -font -*-$TkzG(NonameFont)-*-I-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n\nDelete       " big
$win.ht1 insert end "\n    Deletes all selected items from the archive. This\
  function is only available for archive type files, which contain multiple members,\
  not for simple compressed files. \
  \n    The function is also not available if the relevant archiving utility does\
  not support a reliable delete function (tar, for example).\n" normal 

Help24c $win 0

$win.ht1 insert end "    Note: " em

$win.ht1 insert end "Creation, updating, or deletion of archive files on a device (" normal
$win.ht1 insert end "e.g.," italicn
$win.ht1 insert end " /dev/rmt0 or /dev/fd0) is not supported in $PgmName Release\
  $TkzVer.\n" normal

return 1
}


#-----------------------------------------------------------------------------
#  Help 26  --  Explain Select Viewer button
#-----------------------------------------------------------------------------
proc Help26 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global clicky clicky1 clicky2 clickybg1 clickybg2
global TkzG
set thisproc "Help26"

if {$only}  {
  $win.ht1 configure -height 18
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure normlink46 -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure normlink1e -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*
$win.ht1 tag bind normlink46 <1> "ShowHelp 46"
$win.ht1 tag bind normlink1e <1> "ShowHelp 1e"

$win.ht1 insert end "\n\nSelect Viewer" big
$win.ht1 insert end "\n    Presents a menu of some common viewing programs, and allows you to enter one of your own\
  choosing. This program will be used for viewing files from an archive if $PgmName can't\
  recognize their type based on the MIME types file, or if the " normal

$win.ht1 insert end "\"Automatic Viewer Selection\"" normlink46

$win.ht1 insert end " option is turned off.\
  \n      The program must be able to accept a filename or list of filenames as a command line argument. You may\
  specify program options like \"-xyz\".\n      $PgmName will append the filename(s) at the end of the command line you\
  specify.\
  \n      If you need something trickier, like \"-bMyFilename\", you can use the special variable symbol \"\$*\",\
  which will be replaced by the filename (for our example, the command you enter would look like\
  \"mypgm -b\$*\"). This technique has limited uses, and suffers from certain restrictions.\
  It cannot be used with a list of filenames, or with filenames containing embedded spaces.\
  \n      This manual viewer selection list is sometimes referred to as the \"old style viewer\
  list\", because in older versions of $PgmName it was the only means of viewer selection.\
  The newer, MIME style selection is much more convenient and flexible, but manual\
  selection has been retained to allow you occasionally to force the use of an arbitrary\
  viewing program that is different from the one you normally associate with a given\
  file type. (To do this, you turn off the \"Automatic Viewer Selection\" option\
  and select a viewer from this list.)\
  \n      The first entry in the list is considered the Default viewer. This is the viewer that\
  is implicitly selected when an archive window first opens, and it is the fallback default viewer\
  for files selected from the main window if you have \"Use Default Viewer for All Files\"\
  (and/or \"Use MIME for All Files\") set.\
  \n    To add a viewer to the menu, click on the last\
  item (\"User defined\") and use the " normal

$win.ht1 insert end "entry fields on the archive directory window" normlink1e

$win.ht1 insert end " to enter the name of the executable and\
  a descriptive name (which will appear on the menu). To delete an item, Button-2-click (Middle Button) on the item.\
  \n    Viewer list updates are global - they will be reflected in the viewer menus for all\
  open windows. Also, when you delete an entry, if any open windows had that viewer selected,\
  they will have their selections reset to the first entry in the updated list.\
  \n    Note that if you tear off this menu, it will not reflect updates made to the selection list from other\
  windows until you destroy the tear off and click the \"Select Viewer\" button again." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 27  --  Explain Warn on Viewer Delete
#-----------------------------------------------------------------------------
proc Help27 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global clicky clicky1 clicky2 clickybg1 clickybg2
global TkzG
set thisproc "Help27"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure normlink26 -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag bind normlink26 <1> "ShowHelp 26"

$win.ht1 insert end "\n  Warn on Viewer Delete" bold
$win.ht1 insert end "\n      By default, an attempt to delete an item from the " normal 

$win.ht1 insert end "manual viewer selection menu" normlink26

$win.ht1 insert end " (button-2 or \"middle-button\"\
  click) will cause a confirmation request to pop up. Unchecking this option suppresses that." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 28  --  Explain Warn on Archive Delete
#-----------------------------------------------------------------------------
proc Help28 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help28"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Warn on Archive Delete" bold
$win.ht1 insert end "\n      By default, an attempt to delete an archive file altogether\
  will cause a confirmation request to pop up. Unchecking this option suppresses that." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 29  --  Explain Warn on Archive Member Delete
#-----------------------------------------------------------------------------
proc Help29 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help29"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Warn on Member Delete" bold
$win.ht1 insert end "\n      By default, an attempt to delete a member from an archive\
  will cause a confirmation request to pop up. Unchecking this option suppresses that." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 30  --  Explain Clean Old Directories
#-----------------------------------------------------------------------------
proc Help30 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help30"

if {$only}  {
  $win.ht1 configure -height 14
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Clean Old Temp Files" bold
$win.ht1 insert end "\n      If $PgmName terminates abnornally, temporary files may be left\
  in your home directory. If this option is set, $PgmName will check for these when it starts\
   up, and delete any that it finds. This option is set on by default.\
   \n      This is not 100% foolproof for a one-time shot, but it usually catches them on the first\
   try. $PgmName uses a temp directory that contains the pid of the current process in its name. When it\
   searches for stale directories, it will ignore any containing the pid of an active process, which\
   might not be $PgmName (it doesn't assume that you haven't renamed $PgmName to something else, so it does not\
   try to match the program name of a running process)." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 31  --  Explain Clean Old Error Files
#-----------------------------------------------------------------------------
proc Help31 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help31"

if {$only}  {
  $win.ht1 configure -height 9
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Clean Old Error Files" bold
$win.ht1 insert end "\n      If $PgmName encounters certain errors - usually i/o errors reading or writing\
  an archive file - it may leave a copy of the error message(s) returned by the archive program in\
  your home directory, in a file with a name of the form TkzErrnnn-nn.\
  If this option is set, $PgmName will check for these when it starts\
  up, and delete any that it finds. This option is set on by default." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 32  --  Explain Don't Save Error Files
#-----------------------------------------------------------------------------
proc Help32 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help32"

if {$only}  {
  $win.ht1 configure -height 9
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Don't Save Error Files" bold
$win.ht1 insert end "\n      Instructs $PgmName not to save copies of error messages returned by\
  archive programs in your root directory. They can occasionally be useful in diagnosing a problem,\
  but often prove to be more of an annoyance than a help, so the option is set on by default." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 33  --  Explain Save Options on Exit
#-----------------------------------------------------------------------------
proc Help33 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help33"

if {$only}  {
  $win.ht1 configure -height 6
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  SaveOptions on Exit" bold
$win.ht1 insert end "\n      Instructs $PgmName to save the current options on exit. What did\
  you think it meant?" normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 34  --  Explain Standard Names
#-----------------------------------------------------------------------------
proc Help34 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global clicky clicky1 clicky2 clickybg1 clickybg2
global TkzG
set thisproc "Help34"

if {$only}  {
  $win.ht1 configure -height 10
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure normlink03 -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag bind normlink03 <1> "ShowHelp 03"

$win.ht1 insert end "\n  Use Standard Name Extensions" bold
$win.ht1 insert end "\n      Instructs $PgmName to use the commonly accepted file name\
  extensions (\".tar.gz\", \".Z\", etc.) when " normal

$win.ht1 insert end "creating a new archive." normlink03

$win.ht1 insert end " Recommended in most\
  cases, this option is set on by default.\n      In some cases, $PgmName will enforce\
  these conventions anyway, since the archive programs will force them." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 35  --  Explain GNU/Linux tgz convention
#-----------------------------------------------------------------------------
proc Help35 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help35"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  GNU/Linux tgz Convention" bold
$win.ht1 insert end "\n      Instructs $PgmName to use the GNU/Linux style of naming\
  gzipped tars, with an extension of \".tgz\" instead of \".tar.gz\". This option is set off by default." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 36  --  Try to explain the Shorten Heuristic
#-----------------------------------------------------------------------------
proc Help36 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help36"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Shorten Heuristic (experimental)" bold
$win.ht1 insert end "\n      Instructs $PgmName to try to analyze errors that occur when attempting\
  to create a shortened file, alter the program options accordingly, and try again." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 37  --  Try to explain Disable Colormap Hack
#-----------------------------------------------------------------------------
proc Help37 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help37"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Disable Colormap Hack" bold
$win.ht1 insert end "\n      $PgmName normally uses some colors that do not work well in a\
  dithered 256-color visual mode: some of the screens become virtually illegible. So, it\
  checks your current visual, and if it detects less than a 16-bit color mode, uses a reduced\
  set of colors.\n      Unfortunately, the original technique used was error-prone, and has been replaced\
  in release 0.7.0 with new code that has been little tested. So, the \"Disable Colormap Hack\" Hack\
  is provided temporarily to disable that behavior, should it cause problems." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 38  --  Explain Fast-Clean
#-----------------------------------------------------------------------------
proc Help38 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help38"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Fast-Clean View Files" bold
$win.ht1 insert end "\n      For viewing, $PgmName extracts a file to a temporary file, which is passed\
  to the external viewing program. With this option set, these files will be deleted as soon as you close the view\
  window from which they were selected. This may cause a problem with some 'viewers' -- say, for example, you\
  selected a sound clip or a MPEG to play, and then quickly close the archive window. This option is set off\
  by default for this reason.\n      Note that all temporary files will be deleted when you terminate $PgmName,\
  regardless of what external programs may have been invoked." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 39  --  Explain View Multiple Files
#-----------------------------------------------------------------------------
proc Help39 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help39"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  View Multiple Files" bold
$win.ht1 insert end "\n      $PgmName normally allows one file to be selected for viewing at one time.\
  If more than one file is selected, only the first one will be passed to the viewer program.\n      Setting\
  this option will allow the entire list of selected files to be passed to the viewer. The viewer must be able\
  to accept a list of file names on the command line. $PgmName has no way to verify this, so know the characteristics\
  of your viewer programs." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 40  --  Explain Compresson Options
#-----------------------------------------------------------------------------
proc Help40 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help40"

if {$only}  {
  $win.ht1 configure -height 13
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Compression Options" bold
$win.ht1 insert end "\n      Most compression programs have an option to let you adjust the balance\
  between speed and degree of compression. The options \"Max Speed\", \"Medium\", and \"Max Compression\"\
  select the lowest, middle, and highest compression settings, respectively, used by the various compression\
  utilities.\n      \"Default\" feeds no option to the program, and lets it take its default. For most uses,\
  the default is the best. Most programs slightly favor compression, and the additional processing overhead\
  used for maximum compression often yields disappointing decreases in the size of the resulting file." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 41  --  Explain Use Pathnames when Viewing
#-----------------------------------------------------------------------------
proc Help41 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help41"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Use Pathnames when Viewing" bold
$win.ht1 insert end "\n      When you invoke an external viewer program, $PgmName normally passes\
  the list of filenames to it with the path stripped off, since it invokes the program from the\
  directory where these temporary files reside. Some programs can't figure this out, so if you use\
  one of these, set this option on." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 42  --  Explain Cache Directory
#-----------------------------------------------------------------------------
proc Help42 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help42"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Change Cache Directory" bold
$win.ht1 insert end "\n      Allows you to set the directory where $PgmName builds its temporary cache directory. By default,\
   $PgmName builds it in your home directory. In most cases, you should trust the wisdom of this decision, and not mess with\
   this setting.\n      This option is provided for cases where your home directory resides on a file system that is getting\
   dangerously close to full. It allows you to change to a directory on a different file system with more free space. The\
   directory must already exist; and, obviously, it should be one to which no other users have write privileges.\n      When\
   you change this setting, the existing cache directory is removed. You must close any open archive windows before performing this\
   operation. \n      If you save your options, $PgmName will\
   continue using the new location the next time it starts; otherwise, it will revert to the previous location." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 42a  --  Explain Change Cache control buttons
#-----------------------------------------------------------------------------
proc Help42a {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help42a"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n    Change Cache Control Buttons  " bold
$win.ht1 insert end "\n    After you have selected the directory where you\
  want $PgmName to build its cache directories, click the \"Change Cache\"\
  button to make the change, or click the \"Cancel\" to leave without doing\
  anything." normal 

return 1
}


##-----------------------------------------------------------------------------
##  Help 43  --  Explain Allow Extract of Directories
##-----------------------------------------------------------------------------
#proc Help43 {win only}  {
#global WhoBg MainButBg MainBg MainFg PgmName TkzVer
#set thisproc "Help43"
#
#if {$only}  {
#  $win.ht1 configure -height 12
#  }
#$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
#$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
#
#$win.ht1 insert end "\n  Allow Extract of Directories" bold
#$win.ht1 insert end "\n      Ordinarily, $PgmName will ignore directory entries in the selected list of filenames to\
#  extract. The philosophy is that if you selected specific files, you probably didn't intend to select the whole directory,\
#  which is the effect of passing just the directory name to tar. However, this can occasionally cause a problem, so setting this\
#  option on will cause $PgmName not to filter out directory entries.\n      If you have a tar that contains some empty directories\
#  (i.e., a directory name entry but no files belonging to that directory), then that directory will not get created with $PgmName's\
#  default handling. Occasionally you may run into a software package that depends on empty directories' being created, and their\
#  make or install procedures will fail. In this case, you need to set this option on.\n      Unfortunately, this practice bumps heads\
#  with an inelegant \"feechur\" of GNU tar, which gets confused if passed a list of filenames containing a directory name and then the\
#  individual filenames in that directory. $PgmName will not use the list mode of GNU tar if this option is set, and extraction is much\
#  slower. " normal 
#
#return 1
#}


#-----------------------------------------------------------------------------
#  Help 43  --  Explain Open in Start Directory
#-----------------------------------------------------------------------------
proc Help43 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help43"

if {$only}  {
  $win.ht1 configure -height 10
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Open in Start Directory" bold
$win.ht1 insert end "\n      $PgmName normally starts by opening a directory view of\
   your home directory, unless it is started with a filename argument. This is quite\
   reasonable when you start $PgmName from a file manager or a window manager menu.\
   \n      However, some users like to start it from a command line, and would like\
   for it to start up in the directory from which they started it. This option makes\
   it do that." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 44  --  Explain Set Appearance
#-----------------------------------------------------------------------------
proc Help44 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help44"

if {$only}  {
  $win.ht1 configure -height 10
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Set Appearance" bold
$win.ht1 insert end "\n      This will pop up a dialogue for customizing various aspects of $PgmName's appearance,\
  such as the colors used in the different windows and the look of the scrollbars.\
  \n      (The custom color setting dialogue requires at least Tk 4.2; with earlier\
  versions of Tk, most of the buttons will simply have no effect.)" normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 45  --  Explain Use $PAGER for Default Viewer
#-----------------------------------------------------------------------------
proc Help45 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help45"

if {$only}  {
  $win.ht1 configure -height 14
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Use \$PAGER for Default Viewer" bold
$win.ht1 insert end "\n      Many systems use the convention of setting an environment variable\
  called \$PAGER to a default program for viewing plain text files. If you set this option on, and\
  you have \$PAGER defined, $PgmName will use it as the default viewing program. It will add the\
  program to the beginning of your list of viewers, if it is not already in the list, with a\
  descriptive name of \"\$PAGER\"; If it is\
  already in the list, it will be moved to the first entry, which is the default viewer.\
  The menus of all open archive directory windows will be updated by this operation, but the currently\
  selected viewer will not be changed.\
  \n      Unsetting the option will cause the \$PAGER default entry to be removed from your viewer\
  list (if it is identified with a descriptive name of \"\$PAGER\", indicating that the entry was\
  placed in the list by $PgmName and not by you). The menus of all open archive directories will be\
  updated by this operation. Any windows in which the \$PAGER default entry was selected will have\
  their selections updated to the new first-in-list default viewer.\
  \n      If \$PAGER is not defined in your system, setting this option will have no effect. The option\
  is on by default." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 46  --  Explain Automatic Viewer Selection
#-----------------------------------------------------------------------------
proc Help46 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global clicky clicky1 clicky2 clickybg1 clickybg2
global TkzG
set thisproc "Help46"

if {$only}  {
  $win.ht1 configure -height 16
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure normlink47 -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag bind normlink47 <1> "ShowHelp 47"

$win.ht1 insert end "\n  Automatic Viewer Selection" bold
$win.ht1 insert end "\n      Setting this option will cause $PgmName automatically to try to determine the\
  type of file(s) you have selected from an archive for viewing, and to use an appropriate program\
  for the type of file. Only if it cannot identify the file type, or does not know what program to\
  associate with it, will it use the viewer you currently have selected from the manual viewer\
  selection list. The option is\
  on by default. \n      Automatic viewer selection for archive and compressed files is handled internally by\
  $PgmName. In other words, it uses itself as the viewer. \n      For all other files, the association of a file\
  type with a viewing program is controlled by the MIME types file. Select the " normal

$win.ht1 insert end "\"Edit MIME Types\"" normlink47 

$win.ht1 insert end " option to edit\
  this list.\n      Turn this option off if you want to force $PgmName to use a program other than the one you\
  normally associate with a particular file - for example, if you wish to use your favorite hex editor instead of\
  $PgmName to open an archive file within another archive.\
  \n      Note that if you have the \"View Multiple Files\" option set, and arbitrarily select a lot of files to view,\
  you may get several different programs spawned at once. $PgmName will, however, group the selected files by type,\
  and pass all the filenames of a particular type to a single invocation of the associated viewer." normal

return 1
}


#-----------------------------------------------------------------------------
#  Help 47  --  Explain Edit MIME Types
#-----------------------------------------------------------------------------
proc Help47 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global clicky clicky1 clicky2 clickybg1 clickybg2
global TkzG
set thisproc "Help47"

if {$only}  {
  $win.ht1 configure -height 18
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure normlink46 -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure normlink48 -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag bind normlink46 <1> "ShowHelp 46"
$win.ht1 tag bind normlink48 <1> "ShowHelp 48"

$win.ht1 insert end "\n  Edit MIME Types" bold
$win.ht1 insert end "\n      Clicking this button will open the dialogue for editing the MIME\
  types file. \n      $PgmName lets you associate a viewing program with a file type in two ways:\
  by specifying how the file command will identify the file, and by specifying an arbitrary file\
  \"extension\" with which the file name typically ends, like \".au\" or \".jpg\". \n      The edit\
  window presents a list of all the MIME types known to $PgmName, and 4 entry fields for editing the\
  currently selected type. Double click on a type or highlight it and press the \"Edit\" button to change\
  an entry, or press the \"New\" button to enter a new type. \n      The \"MIME Type:\" field should contain a\
  standard MIME type designation, like \"image/jpeg\", if one exists. However, no content or format rules\
  are enforced, since you may encounter files for which no standard designation exists. Also, $PgmName is not a\
  mail reader, so it is not parsing MIME headers. Therefore, the field is effectively free form. In fact, it is\
  not even required at present. \n      The \"Viewer:\" field contains the name of the\
  executable you want associated with this type of file, including full path name, if needed. The syntax is the same\
  as for the old-style manual viewer selection: you can specify program flags, and you can use the special token\
  \"\$*\" to indicate the position in the command string where the filename(s) should be placed.\
  \n      The\
  \"Extension:\" field contains the file extension for this type of file.\
  \n      The \"File tag:\" field contains\
  a unique string (case-sensitive) that occurs in the file command's identification of this type of\
  file. \
  \n      You must enter at least a Viewer name, and either a file tag or an extension (you can enter\
  both). \n      Use of the filename extension technique is deprecated except for certain types of files for which the\
  file command is not effective. Where file will give an unambiguous identification, using the file probe technique\
  is preferred. If you enter both a file tag and an extension, $PgmName will give precedence to the file tag, falling\
  back to the extension if there is no match on the file tag.\
  \n      When you have finished editing an entry press the \"Update\" or \"Add\" button to allow\
  the entry to take effect. Press the \"Save\" button to update the MIME types file, or the\
  changes you made will not be in effect the next time you run $PgmName. (If you have\
  the \"Save Options on Exit\" option set, however, the changes *will* be saved when you\
  quit $PgmName. Note, however, that the \"Save Options\" button on the Options menu does not implicitly\
  save the MIME types too.)\
  \n      To specify the position in the list where you want a new entry added, single click on an entry to select\
  it. The new entry will be added before the selected entry. If no entry is selected, the new entry will be added\
  at the end of the list. To clear the current selection, press the \"Reset\" button. To delete an entry, click on an\
  entry to select it, then press the \"Delete\" button.\
  \n    NOTE: If you edit the MIME types without explicitly saving them, and then turn off both the " normal

$win.ht1 insert end "\"Automatic Viewer Selection\"" normlink46

$win.ht1 insert end " and the " normal 

$win.ht1 insert end "\"Use MIME for All Files\"" normlink48

$win.ht1 insert end " options, your unsaved updates will be lost. Turning off both these\
  options causes $PgmName to destroy its internal copy of the list, so that it will have no knowledge of MIME types\
  until you turn one of them back on. (If both options were already off before you started editing, this does not happen;\
  a fresh copy will be loaded for you to edit, and it will be preserved when you turn the options back on.\
  It is the act of turning both options off that causes the current list to be purged.)" normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 48  --  Explain Use MIME for All Files
#-----------------------------------------------------------------------------
proc Help48 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global clicky clicky1 clicky2 clickybg1 clickybg2
global TkzG
set thisproc "Help48"

if {$only}  {
  $win.ht1 configure -height 14
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure normlink49 -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag bind normlink49 <1> "ShowHelp 49"

$win.ht1 insert end "\n  Use MIME for All Files" bold
$win.ht1 insert end "\n      This option allows the MIME viewing logic to be\
  used for files selected from the main file list window. Normally MIME viewing\
  is used only to view files within an archive; but if you set this option on,\
  $PgmName will spawn an external viewer for any file selected from the main\
  window, if the file is of a type identified in the MIME types list\
  (and not an archive or compressed file that $PgmName would recognize). The option\
  is off by default.\n      Note\
  that the old-style manual viewer selection list is not used for this feature, unless the " normal 

$win.ht1 insert end "\"Use Default Viewer for All Files\"" normlink49

$win.ht1 insert end " option is also set. If it is, the default viewer\
  (the first in the list) will be used as a fallback, if the file type is not\
  recognized." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 49  --  Explain Use Default Viewer for All Files
#-----------------------------------------------------------------------------
proc Help49 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global clicky clicky1 clicky2 clickybg1 clickybg2
global TkzG
set thisproc "Help49"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure normlink48 -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag bind normlink48 <1> "ShowHelp 48"

$win.ht1 insert end "\n  Use Default Viewer for All Files" bold
$win.ht1 insert end "\n      This option extends the " normal

$win.ht1 insert end "\"Use MIME for All Files\"" normlink48

$win.ht1 insert end " option\
  by causing it to fall back to the default viewer (the first entry in the old-style\
  manual viewer selection list) if it doesn't recognize the type of a file. It can also be used independently\
  of \"Use MIME for All Files\". The option is off by default." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 50  --  Explain Button-3 Viewer Delete
#-----------------------------------------------------------------------------
proc Help50 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global clicky clicky1 clicky2 clickybg1 clickybg2
global TkzG
set thisproc "Help50"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure normlink26 -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag bind normlink26 <1> "ShowHelp 26"

$win.ht1 insert end "\n  Button-3 Viewer Delete" bold
$win.ht1 insert end "\n      In earlier versions of $PgmName, the " normal 

$win.ht1 insert end "manual viewer selection menu" normlink26

$win.ht1 insert end " had mouse button 3, or \"right button\" bound to the Delete Viewer function. This was\
  somewhat confusing, because everywhere else button 3 is bound to context Help. As of Release\
  0.9.6, the Delete Viewer function is now bound to mouse button 2 (the middle button), and\
  button 3 does nothing.\
  \n      However, if you have a misbehaving mouse, or a 2-button mouse and an X-server that\
  doesn't properly handle 3-button emulation, turn this option on to bind button 3 to the\
  Delete Viewer function. This option is off by default." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 51  --  Explain Help Index
#-----------------------------------------------------------------------------
proc Help51 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help51"

if {$only}  {
  $win.ht1 configure -height 6
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  HelpIndex" bold
$win.ht1 insert end "\n      Pops up a clickable index to the Help file. Click on\
  any non-black text to get Help on that item." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 52  --  Explain Remember Symlinks
#-----------------------------------------------------------------------------
proc Help52 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help52"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Remember Symlinks" bold
$win.ht1 insert end "\n      Causes $PgmName directory navigation to remember the path\
  by which you arrived at a particular directory, and to navigate up the tree by\
  the original names, so that if you traversed sybolic links, you will navigate\
  upward via the same route. In other words, \"..\" is interpreted relative to\
  \"how you got there\", rather than relative to the real name of the current\
  directory. This is the default behavior as of Release 0.9.11.\
  \n      Prior to 0.9.11, if you followed a symlink into a directory, that\
  directory's name was immediately interpreted as its real name,\
  $PgmName promptly forgot the symlink name, and you could not\
  follow the same path back up the tree. Since each of these modes of navigation is useful\
  at times, unsetting this option will restore the old behavior." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 53  --  Explain Uninstall
#-----------------------------------------------------------------------------
proc Help53 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help53"

if {$only}  {
  $win.ht1 configure -height 16
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Uninstall" bold
$win.ht1 insert end "\n      Use this button to uninstall the package contained in\
  an archive. It will uninstall all selected files; the normal procedure would be\
  to click \"Select All\" and then click \"Uninstall\", but you can selectively\
  uninstall parts of a package. "
set text "Warning: "
$win.ht1 insert end $text bold
set text "Careless or indiscriminate use of this feature can seriously damage your\
  system."
$win.ht1 insert end $text normal

$win.ht1 insert end "\n      A directory selection window will open up. Use it to navigate to the\
  directory that will be the root of the uninstall operation, if the files in the\
  archive have relative path names. Note that it doesn't matter what directory you're\
  in if the pathnames are absolute; they will be interpreted relative to the root\
  directory regardless.\
  \n      Click the \"Test\" button to get a report of what would be done if you tried\
  to uninstall the package, noting what files could not be found, if any, and\
  what files $PgmName would attempt to delete if you tried the uninstall.\
  Click the \"Uninstall\" button to uninstall for real.\
  \n      In either case, a window will pop up with a status report for the operation,\
  listing what files were (or would have been) deleted, and any for which deletion\
  failed (due to the file's not being found, or a failed delete operation).\
  This report is appended to a file in your home directory called\
  $PgmName-Uninstall-Log.\
  \n      Note that $PgmName does not try to go to superhuman lengths to analyze your\
  directory structure in the \"Test\" mode. In particular, it will not try to determine\
  whether a directory would be empty by the time it tries to delete it. If the directory\
  exists, it will say it will be deleted.\
  The main purpose of Test mode is to determine whether there are components of\
  the package that have gotten lost.\
  \n      Also be aware that $PgmName will not delete a non-empty directory. This is not\
  an option, because I don't want it deleting things like /usr/local/bin or\
  /usr/X11/lib. " normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 53a  --  Explain Uninstall control buttons
#-----------------------------------------------------------------------------
proc Help53a {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help53a"

if {$only}  {
  $win.ht1 configure -height 8
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n    Uninstall Control Buttons  " bold
$win.ht1 insert end "\n    Click the \"Test\" button to view a report of what\
  would be done if you attempted the uninstall - i.e., what files would be\
  deleted and what files were not found.\
  \n    Click the \"Uninstall\" button to perform the actual delete.\
  \n    Click the \"Cancel\" to leave without doing anything." normal 

return 1
}



#-----------------------------------------------------------------------------
#  Help 54  --  Explain README
#-----------------------------------------------------------------------------
proc Help54 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help54"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  View the current README" bold
$win.ht1 insert end "\n      Displays the current README file, which may contain\
   last minute release-specific information that is not the normal Help text. " normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 55  --  Explain Use TkZip Logo
#-----------------------------------------------------------------------------
proc Help55 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help55"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Use $PgmName Logo" bold
$win.ht1 insert end "\n      The $PgmName logo that appears in the main window makes\
  the program look much nicer than it does otherwise, but causes startup to be a\
  bit slow. This is because Tk does not handle transparent gifs natively, so the\
  transparent bitmap has to be built bit by bit in interpreted code. As of Release\
  1.0, this accounts for about 25% of the startup time.\
  (Yes, the image needs\
  to be transparent, or it could look really silly if you change the color scheme\
  of the main window.)\
  \n      If you find startup annoyingly slow, or just prefer a more ascetic look,\
  uncheck this option, and plain text will be used instead of the logo the next time\
  you start $PgmName. (The main window isn't refreshed on the spot when you change\
  the option, because the overhead of building the image has alreadly been incurred;\
  there's no performance benefit to be gained by switching and rebuilding the\
  window.) " normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 56  --  Explain Never Install
#-----------------------------------------------------------------------------
proc Help56 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help56"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Never Install" bold
$win.ht1 insert end "\n      This Sysadmin option inhibits $PgmName's AutoInstall\
  feature. Normally, $PgmName will automatically open the Install dialogue the first\
  time the program is run, or the first time a new release is run. This option\
  prevents that, and overrides all other Installation options.\
  \n      The option is not intended for normal use, but for use by package\
  installers with installation procedures/scripts external to $PgmName." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 57  --  Explain Root Install
#-----------------------------------------------------------------------------
proc Help57 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help57"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Root Install" bold
$win.ht1 insert end "\n      This Sysadmin option restricts $PgmName's AutoInstall\
  feature to be runnable only by root. Normally, any user can install a private\
  copy of $PgmName (in directories to which the user has access, of course) without\
  requiring that it be made available system-wide. Setting this option\
  effectively prevents that.\
  \n      The option is not intended for normal use, but for use by package\
  installers with installation procedures/scripts external to $PgmName." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 58  --  Explain Install on Upgrade
#-----------------------------------------------------------------------------
proc Help58 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help58"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Install on Upgrade" bold
$win.ht1 insert end "\n      This Sysadmin option causes $PgmName's AutoInstall\
  feature to run whenever the program detects that its release is newer than the\
  user's config file. It is on by default. Turning it off suppresses AutoInstall\
  when $PgmName upgrades your config file to a newer release.\
  \n      In a shared environment, it is recommended that all users but the System\
  Administrator responsible for installing $PgmName turn this option off. (This is\
  the default for normal users.) " normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 59  --  Explain Force Install
#-----------------------------------------------------------------------------
proc Help59 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global InstBinDir
global TkzG
set thisproc "Help59"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Force Install" bold
$win.ht1 insert end "\n      This Sysadmin option causes $PgmName to perform its\
  AutoInstall function without asking where you would like things installed. It\
  puts things in its default locations: the executable is installed in\
  $InstBinDir, and the bitmaps and other extra files are installed in\
  $TkzG(TkzDir).\
  \n      You must run as root for this option to work. The same behavior can be\
  caused by invoking $PgmName with the command line flag \"--ForceInstall\" - again,\
  you must run as root, or the flag will be ignored.\
  \n      The option is not intended for normal use, but for use by package\
  installers with installation procedures/scripts external to $PgmName." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 60  --  Explain Use GNU Tar
#-----------------------------------------------------------------------------
proc Help60 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global InstBinDir
global TkzG
set thisproc "Help60"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Use GNU Tar Features" bold
$win.ht1 insert end "\n      This option (on by default) instructs $PgmName to\
  use special features of GNU tar, if it is present on the system. This normally\
  results in the most efficient processing. These features include the ability to\
  specify a file containing the list of filenames to extract, and the ability to\
  extract files to stdout.\
  \n      However, there are certain times when this may produce undesirable results.\
  In particular, GNU tar has been known to misbehave when extracting an individual\
  directory using the -T option (filename list is in a file): the entire archive is\
  extracted instead of just the directory you wanted. This misfeature is known to\
  exist in releases 1.12 and earlier of GNU tar.\
  \n      To suppress the use of the unique GNU features, set this option off." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 61  --  Explain Prefer GNU Tar
#-----------------------------------------------------------------------------
proc Help61 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global InstBinDir
global TkzG
set thisproc "Help61"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Prefer GNU Tar" bold
$win.ht1 insert end "\n      This option (on by default) instructs $PgmName that,\
  if it finds GNU tar installed on your system under a special name, like \"gtar\",\
  it should use that version rather than the one called \"tar\".
  \n      Note that setting this option does not imply \"Use GNU Tar Features\";\
  that option must be set separately." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 62  --  Explain Set GNU Tar Name
#-----------------------------------------------------------------------------
proc Help62 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global InstBinDir
global TkzG
set thisproc "Help62"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Set GNU Tar Name" bold
$win.ht1 insert end "\n      Pops up a dialogue to allow you to set an alternate\
  name by which GNU tar is known.\
  \n      This function is for those who chose to leave their vendor-supplied tar\
  under the name of \"tar\", and install GNU tar under a different name (commonly\
  \"gtar\").
  \n      In order to make this setting permanent, don't forget to click the \"Save\
  Options\" button before exiting, if you don't have the \"Save Options on Exit\"\
  option set." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 63  --  Explain Set GNU Tar Name
#-----------------------------------------------------------------------------
proc Help63 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global InstBinDir
global TkzG
set thisproc "Help63"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Ignore Drive Errors" bold
$win.ht1 insert end "\n      (MS Windows only) Sometimes when trying to build a list\
  of available drives, TkZip will encounter a permission error trying to access a\
  network drive. Ordinarily when this happens it will pop up an error message box.\
  \n      Setting this option suppresses the message - only in the case where the error\
  is encountered in building the drive list. This allows you to navigate through the\
  file system without being constantly distracted by the error popup.\
  \n      The option does not cause the error to be ignored at other times. If, for\
  example, you type the name of the drive in the entry field, the error message will\
  not be suppressed." normal 

return 1
}



#-----------------------------------------------------------------------------
#  Help 64  --  Explain FAQ
#-----------------------------------------------------------------------------
proc Help64 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help64"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  View the current FAQ" bold
$win.ht1 insert end "\n      Displays the current FAQ file. If you have\
   questions about $PgmName, look here first. Somebody may well have asked\
   the same thing already." normal 

return 1
}



#-----------------------------------------------------------------------------
#  Help 65  --  Explain License Info
#-----------------------------------------------------------------------------
proc Help65 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help65"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  License Info" bold
$win.ht1 insert end "\n      Displays $PgmName license information. If you have\
   an unlicensed version, it displays information about licensing terms. If you\
   have a licensed version, it displays information from your license file." normal 

return 1
}


#-----------------------------------------------------------------------------
#  Help 999  --  Explain absolutely nothing
#-----------------------------------------------------------------------------
proc Help999 {win only}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global TkzG
set thisproc "Help999"

if {$only}  {
  $win.ht1 configure -height 12
  }
$win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
$win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*

$win.ht1 insert end "\n  Ho Help Available" bold
$win.ht1 insert end "\n      Sorry, but no Help is available for the selected\
   item. " normal 

return 1
}




#-----------------------------------------------------------------------------
#  SetHelp  --  A menu was Button-3-clicked - this will get driven before the
#      command explicitly bound to the menubutton, so indicate that this is
#      really a Help request. Whew!
#      Also, save the state of radio buttons, which aren't a simple toggle.
#      They haven't been touched yet, but they will be, maybe.
#-----------------------------------------------------------------------------
proc SetHelp {}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global MenuHelp
global ShCompOpt
global TkzG
set thisproc "SetHelp"

set ShCompOpt $TkzG(CompOpt)

set MenuHelp 1
return 1
}


#-------------------------------------------------------------------------------
#  UnSetHelp  --  A menu was Button-1-clicked - this will get driven before the
#      command implicitly bound to the menubutton, so in case a help request
#      was pending, make it not be so. This is needed because nothing really
#      gets bound to the cascade line, although the book says it does. Sheeeesh!
#-------------------------------------------------------------------------------
proc UnSetHelp {}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global MenuHelp
global TkzG
set thisproc "UnSetHelp"

set MenuHelp 0
return 1
}

#-------------------------------------------------------------------------------
#  CheckHelp  --  A togglable menubutton was clicked - these can't be bound like 
#  normal widgets, but they can to a command. Hence the hack to see whether this
#      was a Button-1 or Button-3 click. If Help, we have to reset the option
#      flag - it got toggled no matter which button was clicked.
#-------------------------------------------------------------------------------
proc CheckHelp {context}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer
global MenuHelp ShIgnITG ShDesperation ShNoProbe
global VDWarn ADWarn MDWarn 
global ShCompOpt ExtDirs
global Button3VD
global TkzG
set thisproc "CheckHelp"

switch $context    {

    11       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(IgnITG) $ShIgnITG
          ShowHelp 11
          }  else  {
          set ShIgnITG $TkzG(IgnITG)
          }
        }
    12       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(Desperation) $ShDesperation
          ShowHelp 12
          }  else  {
          set ShDesperation $TkzG(Desperation)
          }
        }
    13       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(NoProbe) $ShNoProbe
          ShowHelp 13
          }  else  {
          set ShNoProbe $TkzG(NoProbe)
          }
        }
    27       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set VDWarn [ToggleOpt "$VDWarn"]
          ShowHelp 27
          }
        }
    28       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set ADWarn [ToggleOpt "$ADWarn"]
          ShowHelp 28
          }
        }
    29       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set MDWarn [ToggleOpt "$MDWarn"]
          ShowHelp 29
          }
        }
    30       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(CldFlag) [ToggleOpt "$TkzG(CldFlag)"]
          ShowHelp 30
          }
        }
    31       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(CleFlag) [ToggleOpt "$TkzG(CleFlag)"]
          ShowHelp 31
          }
        }
    32       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(DseFlag) [ToggleOpt "$TkzG(DseFlag)"]
          ShowHelp 32
          }
        }
    33       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(SavOpt) [ToggleOpt "$TkzG(SavOpt)"]
          ShowHelp 33
          }
        }
    34       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(StdNames) [ToggleOpt "$TkzG(StdNames)"]
          ShowHelp 34
          }
        }
    35       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(GnuLin) [ToggleOpt "$TkzG(GnuLin)"]
          ShowHelp 35
          }
        }
    36       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(ShnHeur) [ToggleOpt "$TkzG(ShnHeur)"]
          ShowHelp 36
          }
        }
    38       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(FastClean) [ToggleOpt "$TkzG(FastClean)"]
          ShowHelp 38
          }
        }
    39       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(MultView) [ToggleOpt "$TkzG(MultView)"]
          ShowHelp 39
          }
        }
    40       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(CompOpt) $ShCompOpt
          ShowHelp 40
          }
        }
    41       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(Vpn) [ToggleOpt "$TkzG(Vpn)"]
          ShowHelp 41
          }
        }
    43       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(OpenStartDir) [ToggleOpt "$TkzG(OpenStartDir)"]
          ShowHelp 43
          }
        }
    45       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(UsePager) [ToggleOpt "$TkzG(UsePager)"]
          ShowHelp 45
          }  else  {
          SetPager
          }
        }
    46       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(IntView) [ToggleOpt "$TkzG(IntView)"]
          ShowHelp 46
          }  else  {
          SetIntView
          }
        }
    48       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(Mime4All) [ToggleOpt "TkzG(Mime4All)"]
          ShowHelp 48
          }  else  {
          SetIntView
          }
        }
    49       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TlzG(DV4All) [ToggleOpt "$TkzG(DV4All)"]
          ShowHelp 49
          }
        }
    50       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set Button3VD [ToggleOpt "$Button3VD"]
          ShowHelp 50
          }  else  {
          SetButton3VD
          }
        }
    52       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(NavLinks) [ToggleOpt "$TkzG(NavLinks)"]
          ShowHelp 52
          }
        }
    55       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(UseMainIcon) [ToggleOpt "$TkzG(UseMainIcon)"]
          ShowHelp 55
          }
        }
    56       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(NoInstall) [ToggleOpt "$TkzG(NoInstall)"]
          ShowHelp 56
          }
        }
    57       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(RootInstall) [ToggleOpt "$TkzG(RootInstall)"]
          ShowHelp 57
          }
        }
    58       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(InstallUpg) [ToggleOpt "$TkzG(InstallUpg)"]
          ShowHelp 58
          }
        }
    59       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(ForceInstall) [ToggleOpt "$TkzG(ForceInstall)"]
          ShowHelp 59
          }
        }
    60       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(UseGtar) [ToggleOpt "$TkzG(UseGtar)"]
          ShowHelp 60
          }
        }
    61       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(PreferGtar) [ToggleOpt "$TkzG(PreferGtar)"]
          ShowHelp 61
          }
        }
    63       {
        if {$MenuHelp}  {
          set MenuHelp 0
          set TkzG(IgnDrvErr) [ToggleOpt "$TkzG(IgnDrvErr)"]
          ShowHelp 63
          }
        }
    default       {
        if {$MenuHelp}  {
#puts "CheckHelp 99!"
          set MenuHelp 0
          }
        }
    }

return 1
}


#-----------------------------------------------------------------------------
#  Help Index  --  A little easier on the eyes than the whole thing
#-----------------------------------------------------------------------------
proc HelpIndex {}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer MenuHelp
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg
global clicky clicky1 clicky2 clickybg1 clickybg2
global DSlidBg NumWins
global TkzG

#  Now why would anyone want context Help on Help Index...?
if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 51
  return 1
  }

#set hbg "FloralWhite"
set bar ".main.list1.diry"
set wnum 102
set hbg $TwBg($wnum)
set hfg $TwFg($wnum)
set hlbg $TwLBg($wnum)
set hlfg $TwLFg($wnum)
set hbutbg $TwButBg($wnum)
set hbutfg $TwButFg($wnum)
set sbg $SlidBg($wnum)
set tcol $TrCol($wnum)

if {$sbg != "UseTk"}  {
  if {$sbg == "UseDefault"}  {
    set sbg $DSlidBg
    }  else  {
    set sbg $SlidBg($wnum)
    }
  }  else  {
  set tmp [$bar configure -bg]
  set sbg [lindex $tmp 3]
  }
if {$tcol != "UseTk"}  {
  if {$tcol == "UseBg"}  {
    set tcol $hbg
    }  else  {
    set tcol $TrCol($wnum)
    }
  }  else  {
  set tmp [$bar configure -troughcolor]
  set tcol [lindex $tmp 3]
  }


set win ".hindex"
set wintitle "$PgmName Help Index"

if [catch {toplevel $win} rc]  {
  raise $win
  #focus $win
  }  else  {
  # Define our widgets
  wm title $win $wintitle
  text $win.ht1 -width 60
  scrollbar $win.sby
  frame $win.f2
  set cmd "destroy $win"
  button $win.f2.hb1 -text "Ok" -bg $hbutbg -fg $hbutfg -command $cmd
  # Tell the window mgr how to put 'em together
  pack $win.f2.hb1
  pack $win.f2 -side top -fill x
  pack $win.sby -side right -fill y
  pack $win.ht1 -fill both -expand yes
  $win.ht1 configure -fg black
  # Now set up the text
  # Define some styles
#  set clicky1 "Red4"
#  set clicky2 "Green4"
  $win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
  $win.ht1 tag configure bold -font -*-$TkzG(SwissFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*
  $win.ht1 tag configure italic -font -*-$TkzG(NonameFont)-*-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
  $win.ht1 tag configure heading -font -*-$TkzG(SwissFont)-Bold-R-Normal-*-*-180-*-*-*-*-*-* -justify center

  $win.ht1 tag configure help1a -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2
  $win.ht1 tag configure help1c -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2
  $win.ht1 tag configure help1e -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2
  $win.ht1 tag configure help01 -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2
  $win.ht1 tag configure help02a -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2
  $win.ht1 tag configure help07 -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2
  $win.ht1 tag configure help15 -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2
  $win.ht1 tag configure help20 -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2
  $win.ht1 tag configure help21 -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2
  $win.ht1 tag configure help22 -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2
  $win.ht1 tag configure help23 -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2
  $win.ht1 tag configure help24 -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2
  $win.ht1 tag configure help25 -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2
  $win.ht1 tag configure help26 -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2
  $win.ht1 tag configure help53 -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* \
    -foreground $clicky2

  $win.ht1 tag configure help1b -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help1d -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1

  $win.ht1 tag configure help02 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help03 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help04 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help05 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help06 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1

  $win.ht1 tag configure help08 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help09 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help10 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help11 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help12 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help13 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help14 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1

  $win.ht1 tag configure help16 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help17 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help18 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help19 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help51 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help54 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help64 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help65 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1

  $win.ht1 tag configure help27 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help28 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help29 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help30 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help31 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help32 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help33 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help34 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help35 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help36 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help37 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help38 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help39 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help40 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help41 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help42 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help43 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help44 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help45 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help46 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help47 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help48 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help49 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help50 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help52 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help60 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help61 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1
  $win.ht1 tag configure help62 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-* \
    -foreground $clicky1


  $win.ht1 tag bind help1a <1> "ShowHelp 1a"
  $win.ht1 tag bind help1b <1> "ShowHelp 1b"
  $win.ht1 tag bind help1c <1> "ShowHelp 1c"
  $win.ht1 tag bind help1d <1> "ShowHelp 1d"
  $win.ht1 tag bind help1e <1> "ShowHelp 1e"

  $win.ht1 tag bind help01 <1> "ShowHelp 01"
  $win.ht1 tag bind help02a <1> "ShowHelp 02a"
  $win.ht1 tag bind help02 <1> "ShowHelp 02"
  $win.ht1 tag bind help03 <1> "ShowHelp 03"
  $win.ht1 tag bind help04 <1> "ShowHelp 04"
  $win.ht1 tag bind help05 <1> "ShowHelp 05"
  $win.ht1 tag bind help06 <1> "ShowHelp 06"

  $win.ht1 tag bind help07 <1> "ShowHelp 07"
  $win.ht1 tag bind help08 <1> "ShowHelp 08"
  $win.ht1 tag bind help09 <1> "ShowHelp 09"
  $win.ht1 tag bind help10 <1> "ShowHelp 10"
  $win.ht1 tag bind help11 <1> "ShowHelp 11"
  $win.ht1 tag bind help12 <1> "ShowHelp 12"
  $win.ht1 tag bind help13 <1> "ShowHelp 13"
  $win.ht1 tag bind help27 <1> "ShowHelp 27"
  $win.ht1 tag bind help28 <1> "ShowHelp 28"
  $win.ht1 tag bind help29 <1> "ShowHelp 29"
  $win.ht1 tag bind help30 <1> "ShowHelp 30"
  $win.ht1 tag bind help31 <1> "ShowHelp 31"
  $win.ht1 tag bind help32 <1> "ShowHelp 32"
  $win.ht1 tag bind help33 <1> "ShowHelp 33"
  $win.ht1 tag bind help34 <1> "ShowHelp 34"
  $win.ht1 tag bind help35 <1> "ShowHelp 35"
  $win.ht1 tag bind help36 <1> "ShowHelp 36"
  $win.ht1 tag bind help44 <1> "ShowHelp 44"
  $win.ht1 tag bind help47 <1> "ShowHelp 47"
  $win.ht1 tag bind help14 <1> "ShowHelp 14"
  $win.ht1 tag bind help45 <1> "ShowHelp 45"
  $win.ht1 tag bind help46 <1> "ShowHelp 46"
  $win.ht1 tag bind help48 <1> "ShowHelp 48"
  $win.ht1 tag bind help49 <1> "ShowHelp 49"
  $win.ht1 tag bind help38 <1> "ShowHelp 38"
  $win.ht1 tag bind help39 <1> "ShowHelp 39"
  $win.ht1 tag bind help40 <1> "ShowHelp 40"
  $win.ht1 tag bind help41 <1> "ShowHelp 41"
  $win.ht1 tag bind help43 <1> "ShowHelp 43"
  $win.ht1 tag bind help50 <1> "ShowHelp 50"
  $win.ht1 tag bind help52 <1> "ShowHelp 52"
  $win.ht1 tag bind help60 <1> "ShowHelp 60"
  $win.ht1 tag bind help61 <1> "ShowHelp 61"
  $win.ht1 tag bind help42 <1> "ShowHelp 42"
  $win.ht1 tag bind help62 <1> "ShowHelp 62"

  $win.ht1 tag bind help15 <1> "ShowHelp 15"
  $win.ht1 tag bind help16 <1> "ShowHelp 16"
  $win.ht1 tag bind help17 <1> "ShowHelp 17"
  $win.ht1 tag bind help18 <1> "ShowHelp 18"
  $win.ht1 tag bind help19 <1> "ShowHelp 19"
  $win.ht1 tag bind help51 <1> "ShowHelp 51"
  $win.ht1 tag bind help54 <1> "ShowHelp 54"
  $win.ht1 tag bind help64 <1> "ShowHelp 64"
  $win.ht1 tag bind help65 <1> "ShowHelp 65"

  $win.ht1 tag bind help20 <1> "ShowHelp 20"
  $win.ht1 tag bind help21 <1> "ShowHelp 21"
  $win.ht1 tag bind help22 <1> "ShowHelp 22"
  $win.ht1 tag bind help23 <1> "ShowHelp 23"
  $win.ht1 tag bind help24 <1> "ShowHelp 24"
  $win.ht1 tag bind help25 <1> "ShowHelp 25"
  $win.ht1 tag bind help53 <1> "ShowHelp 53"
  $win.ht1 tag bind help26 <1> "ShowHelp 26"


  $win.ht1 insert end "\n" normal
  $win.ht1 insert end "Help Index\n" heading
#  set text "    Click on any non-black text to get help on that item.\n\n"
#  $win.ht1 insert end "$text" italic

  set text "\nCommand Line      \n"
  $win.ht1 insert end "$text" bold
  set text "  Starting $PgmName  \n"
  $win.ht1 insert end "$text" help1a

  set text "\nMain Window      \n"
  $win.ht1 insert end "$text" bold
  set text "  Buttons/Menus  \n"
  $win.ht1 insert end "$text" bold
  set text "    Exit        "
  $win.ht1 insert end "$text" help01
  $win.ht1 insert end "\n" normal
  set text "    File        "
  $win.ht1 insert end "$text" help02a
  $win.ht1 insert end "\n" normal
  set text "      Exit              "
  $win.ht1 insert end "$text" help02
  $win.ht1 insert end "\n" normal
  set text "      New Archive    "
  $win.ht1 insert end "$text" help03
  $win.ht1 insert end "\n" normal
  set text "      Open Archive      "
  $win.ht1 insert end "$text" help04
  $win.ht1 insert end "\n" normal
  set text "      Delete Archive    "
  $win.ht1 insert end "$text" help05
  $win.ht1 insert end "\n" normal
  set text "      Show System Info      "
  $win.ht1 insert end "$text" help06
  $win.ht1 insert end "\n" normal

  set text "    Options     "
  $win.ht1 insert end "$text" help07
  $win.ht1 insert end "\n" normal
  set text "      Show Archives Only"
  $win.ht1 insert end "$text" help08
  $win.ht1 insert end "\n" normal
  set text "      Warn of Overwrites"
  $win.ht1 insert end "$text" help09
  $win.ht1 insert end "\n" normal
  set text "      Never Overwrite Existing Files"
  $win.ht1 insert end "$text" help10
  $win.ht1 insert end "\n" normal
  set text "      Ignore Gnu \"trailing garbage\" Message"
  $win.ht1 insert end "$text" help11
  $win.ht1 insert end "\n" normal
  set text "      Improved Tar Detection"
  $win.ht1 insert end "$text" help12
  $win.ht1 insert end "\n" normal
  set text "      Don't Probe Compressed Files"
  $win.ht1 insert end "$text" help13
  $win.ht1 insert end "\n" normal
  set text "      Warn on Viewer Delete"
  $win.ht1 insert end "$text" help27
  $win.ht1 insert end "\n" normal
  set text "      Warn on Archive Delete"
  $win.ht1 insert end "$text" help28
  $win.ht1 insert end "\n" normal
  set text "      Warn on Member Delete"
  $win.ht1 insert end "$text" help29
  $win.ht1 insert end "\n" normal
  set text "      Clean Old Temp Files"
  $win.ht1 insert end "$text" help30
  $win.ht1 insert end "\n" normal
  set text "      Clean Old Error Files"
  $win.ht1 insert end "$text" help31
  $win.ht1 insert end "\n" normal
  set text "      Don't Save Error Files"
  $win.ht1 insert end "$text" help32
  $win.ht1 insert end "\n" normal
  set text "      SaveOptions on Exit"
  $win.ht1 insert end "$text" help33
  $win.ht1 insert end "\n" normal
  set text "      Use Standard Name Extensions"
  $win.ht1 insert end "$text" help34
  $win.ht1 insert end "\n" normal
  set text "      GNU/Linux tgz Convention"
  $win.ht1 insert end "$text" help35
  $win.ht1 insert end "\n" normal
  set text "      Shorten Heuristic (experimental)"
  $win.ht1 insert end "$text" help36
  $win.ht1 insert end "\n" normal
  set text "      Set Appearance"
  $win.ht1 insert end "$text" help44
  $win.ht1 insert end "\n" normal
  set text "      Edit MIME Types"
  $win.ht1 insert end "$text" help47
  $win.ht1 insert end "\n" normal
  set text "      Save Options"
  $win.ht1 insert end "$text" help14
  $win.ht1 insert end "\n" normal
  set text "      Use \$PAGER for Default Viewer"
  $win.ht1 insert end "$text" help45
  $win.ht1 insert end "\n" normal
  set text "      Automatic Viewer Selection"
  $win.ht1 insert end "$text" help46
  $win.ht1 insert end "\n" normal
  set text "      Use MIME for All Files"
  $win.ht1 insert end "$text" help48
  $win.ht1 insert end "\n" normal
  set text "      Use Default Viewer for All Files"
  $win.ht1 insert end "$text" help49
  $win.ht1 insert end "\n" normal
  set text "      Fast-Clean View Files"
  $win.ht1 insert end "$text" help38
  $win.ht1 insert end "\n" normal
  set text "      View Multiple Files"
  $win.ht1 insert end "$text" help39
  $win.ht1 insert end "\n" normal
  set text "      Compression Options"
  $win.ht1 insert end "$text" help40
  $win.ht1 insert end "\n" normal
  set text "      Use Pathnames when Viewing"
  $win.ht1 insert end "$text" help41
  $win.ht1 insert end "\n" normal
  set text "      Open in Start Directory"
  $win.ht1 insert end "$text" help43
  $win.ht1 insert end "\n" normal
  set text "      Button-3 Viewer Delete"
  $win.ht1 insert end "$text" help50
  $win.ht1 insert end "\n" normal
  set text "      Remember Symlinks"
  $win.ht1 insert end "$text" help52
  $win.ht1 insert end "\n" normal
  set text "      Use GNU Tar Features"
  $win.ht1 insert end "$text" help60
  $win.ht1 insert end "\n" normal
  set text "      Prefer GNU Tar"
  $win.ht1 insert end "$text" help61
  $win.ht1 insert end "\n" normal
  set text "      Change Cache Directory"
  $win.ht1 insert end "$text" help42
  $win.ht1 insert end "\n" normal
  set text "      Set GNU Tar Name"
  $win.ht1 insert end "$text" help62
  $win.ht1 insert end "\n" normal

  set text "    Help        "
  $win.ht1 insert end "$text" help15
  $win.ht1 insert end "\n" normal
  set text "      About             "
  $win.ht1 insert end "$text" help16
  $win.ht1 insert end "\n" normal
  set text "      Help Index        "
  $win.ht1 insert end "$text" help51
  $win.ht1 insert end "\n" normal
  set text "      Help              "
  $win.ht1 insert end "$text" help17
  $win.ht1 insert end "\n" normal
  set text "      Register $PgmName    "
  $win.ht1 insert end "$text" help18
  $win.ht1 insert end "\n" normal
  set text "      Bug Report/Comment    "
  $win.ht1 insert end "$text" help19
  $win.ht1 insert end "\n" normal
  set text "      Vies the Current README"
  $win.ht1 insert end "$text" help54
  $win.ht1 insert end "\n" normal
  set text "      View the Current FAQ  "
  $win.ht1 insert end "$text" help64
  $win.ht1 insert end "\n" normal
  set text "      License Info          "
  $win.ht1 insert end "$text" help65
  $win.ht1 insert end "\n" normal

  set text "  Entry Fields  \n"
  $win.ht1 insert end "$text" bold
  set text "    Current Directory"
  $win.ht1 insert end "$text" help1c
  $win.ht1 insert end "\n" normal

  set text "\nArchive directory Window \n"
  $win.ht1 insert end "$text" bold
  set text "  Buttons/Menus  \n"
  $win.ht1 insert end "$text" bold
  set text "    Close       "
  $win.ht1 insert end "$text" help20
  $win.ht1 insert end "\n" normal
  set text "    Select All   "
  $win.ht1 insert end "$text" help21
  $win.ht1 insert end "\n" normal
  set text "    View         "
  $win.ht1 insert end "$text" help22
  $win.ht1 insert end "\n" normal
  set text "    Extract      "
  $win.ht1 insert end "$text" help23
  $win.ht1 insert end "\n" normal
  set text "    Add          "
  $win.ht1 insert end "$text" help24
  $win.ht1 insert end "\n" normal
  set text "    Delete       "
  $win.ht1 insert end "$text" help25
  $win.ht1 insert end "\n" normal
  set text "    Uninstall    "
  $win.ht1 insert end "$text" help53
  $win.ht1 insert end "\n" normal
  set text "    Select Viewer"
  $win.ht1 insert end "$text" help26
  $win.ht1 insert end "\n" normal
  set text "  Entry Fields  \n"
  $win.ht1 insert end "$text" bold
  set text "    Manual Viewer Selection"
  $win.ht1 insert end "$text" help1e
  $win.ht1 insert end "\n" normal




  # Set the other attributes

  set ycmd "$win.sby set"
  $win.ht1 configure -bg $hlbg -fg $hlfg -wrap word -state disabled \
    -yscroll $ycmd 
  $win.f2 configure -bg $hbg
  set ycmd "$win.ht1 yview"
  $win.sby configure -command $ycmd

  set wno 102
  ConfigureScrollbar $win.sby $wno 0

  }


return 1
}




#-----------------------------------------------------------------------------
#  Help About  --  The legalese, etc.
#-----------------------------------------------------------------------------
proc About {}  {
global WhoBg MainButBg MainBg MainFg PgmName TkzVer MenuHelp
global clicky clicky1 clicky2 clickybg1 clickybg2
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg
global DSlidBg NumWins
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 16
  return 1
  }


set licinf "$TkzG(TkzDir)/License"
#set hbg "FloralWhite"
set bar ".main.list1.diry"
set wnum 102
set hbg $TwBg($wnum)
set hfg $TwFg($wnum)
set hlbg $TwLBg($wnum)
set hlfg $TwLFg($wnum)
set hbutbg $TwButBg($wnum)
set hbutfg $TwButFg($wnum)
set sbg $SlidBg($wnum)
set tcol $TrCol($wnum)

if {$sbg != "UseTk"}  {
  if {$sbg == "UseDefault"}  {
    set sbg $DSlidBg
    }  else  {
    set sbg $SlidBg($wnum)
    }
  }  else  {
  set tmp [$bar configure -bg]
  set sbg [lindex $tmp 3]
  }
if {$tcol != "UseTk"}  {
  if {$tcol == "UseBg"}  {
    set tcol $hbg
    }  else  {
    set tcol $TrCol($wnum)
    }
  }  else  {
  set tmp [$bar configure -troughcolor]
  set tcol [lindex $tmp 3]
  }


set win ".about"
set wintitle "$PgmName:  About"

		if [catch {toplevel $win} rc]  {
		  raise $win
		  # focus $win
		  }  else  {
		  # Define our widgets
		  wm title $win $wintitle
		  text $win.ht1
		  scrollbar $win.sby
		  frame $win.f2
		  set cmd "destroy $win"
		  button $win.f2.hb1 -text "Ok" -bg $hbutbg -fg $hbutfg -command $cmd
		  # Tell the window mgr how to put 'em together
		  pack $win.f2.hb1
		  pack $win.f2 -side top -fill x
		  pack $win.sby -side right -fill y
		  pack $win.ht1 -fill both -expand yes
                  $win.ht1 configure -fg black

		  # Now set up the text
		  # Define some styles
		  $win.ht1 tag configure normal -font -*-$TkzG(NonameFont)-*-R-Normal-*-*-120-*-*-*-*-*-*
		  $win.ht1 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
		  $win.ht1 tag configure big -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-*
		  $win.ht1 tag configure reallybig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-180-*-*-*-*-*-*
		  $win.ht1 tag configure cbig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-140-*-*-*-*-*-* -justify center
		  $win.ht1 tag configure creallybig -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-180-*-*-*-*-*-* -justify center
		  $win.ht1 tag configure center -justify center
		  $win.ht1 tag configure heading -font -*-$TkzG(RomanFont)-Bold-R-Normal-*-*-240-*-*-*-*-*-* -justify center
		  $win.ht1 tag configure raised -relief raised -borderwidth 3
		  $win.ht1 tag configure hilite -foreground red
#		  $win.ht1 tag configure italic -font -*-Lucidabright-*-I-Normal-*-*-120-*-*-*-*-*-*
		  $win.ht1 tag configure italic -font -*-$TkzG(NonameFont)-Medium-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
		  $win.ht1 tag configure italic2 -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
		  $win.ht1 tag configure seelic -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-* \
		    -foreground $clicky

		  $win.ht1 insert end "\nAbout $PgmName\n\n" heading

    		  set text "    $PgmName   Copyright  1996, 2002 by Robert Woodside.\
		    \n\n    $PgmName version $TkzVer is\
		    provided as is, without any warranty. While\
		    reasonable efforts have been made to insure that it is stable, no software\
		    is perfect. Some\
                    releases may contain functions that behave strangely or are downright broken.\
                    If I know about them, they will be documented on the $PgmName Web pages\
                    (http://woodsway.com/$PgmName), as will the availability\
                    of fixes.\n"
		  $win.ht1 insert end "$text" italic

		  $win.ht1 insert end "\nLegalese\n" creallybig

                  if {! $TkzG(Licensed)}  {
                    set numusers $TkzG(LicenseUsers)
                    set text "\n    This program is copyrighted shareware. This is an unlicensed,\
                      freely distributable copy of $PgmName version $TkzVer.\
                      Permission to use, copy, and distribute this software\
                      and its documentation  for  any  non-commercial purpose  and without\
                      fee is hereby granted, provided that this copyright and permission\
                      notice appear in all copies of the program and its supporting\
                      documentation. Modification for personal use is also permitted. \n"
                    }  else  {
                    set text "\n    This program is copyrighted shareware. This copy of $PgmName\
                      version $TkzVer is licensed to $TkzG(Licensee), according to the terms of\
                      License number $TkzG(LicenseNumber)."
                    if {$TkzG(LicenseUsers) != 0}  {
                      set text "$text The license is a $TkzG(LicenseUsers)-user license.\n"
                      }  else  {
                      set text "$text The license is an unlimited-use corporate license.\n"
                      }
                    set text "$text\n    Permission to use, copy, and distribute this software and\
                      and its documentation for any non-commercial purpose and without fee is hereby\
                      granted, provided that this copyright and permission notice appear in all copies\
                      of the program and its supporting documentation, and provided further that the\
                     \"License\" and \"License2\" files that accompany this copy of the program are not\
                     redistributed.\n"
                    }
		  $win.ht1 insert end "$text" normal

                  set text "\n    Non-commercial use is interpreted fairly liberally. If you wish to\
                    install your personal copy on your workstation at work for casual use,\
                    this qualifies as non-commercial.\
                    If you are a sysadmin wishing to make it available at your site as an\
                    unsupported tool for casual use, that's fine too.\
                    Licensing for personal or casual use is appreciated, but not required.\n"
		  $win.ht1 insert end "$text" normal

                  set text "\n    If you wish to redistribute it as part of a package for\
                    which you charge a fee, except as noted below, that qualifies as commercial use,\
                    and requires a license from the copyright holder.\
                    If you're a sysadmin wishing to make it a formally\
                    supported tool for your users, you need to contact me about licensing.\
                    If you regularly use it in your work, you should license it.\
                    Commercial, institutional, and government users are expected to license it.\
                    If you are in doubt, contact me."
		  $win.ht1 insert end "$text" normal

		  if {[file exists $licinf]}  {
		  $win.ht1 tag bind seelic <1> "HelpLicense"
                  set text " (More information on licensing can be found under "
		  $win.ht1 insert end "$text" normal
                  set text "Help -> License Info"
		  $win.ht1 insert end "$text" seelic
                  set text ".)\n"
		  $win.ht1 insert end "$text" normal
		    }  else  {
                  set text "\n"
                  $win.ht1 insert end "$text" normal
		    }

                  set text "\n    Distributors of Linux, FreeBSD, or other free Unix variants,\
                    commercial or otherwise, and regardless of medium,\
                    are specifically exempted from the non-commercial restriction above with\
                    respect to inclusion of an unregistered copy of $PgmName with their\
                    distributions, so long as the code is not modified\
                    (except as authorized by the author - usually for compatibility with the\
                    distribution's installation procedures)\
                    and is sourced from an authorized repository (like the TkZip home site),\
                    and the author is duly notified of such distribution.\
                    Additionally, distributions sourced from a standard public ftp site,\
                    such as Sunsite or any of its mirrors, incur no obligation to notify the\
                    author; and CD-Rom or other distributions of the contents of public ftp\
                    sites are considered non-commercial with respect to the use and distribution\
                    of $PgmName.\n"
		  $win.ht1 insert end "$text" normal

                  set text "\n    Robert Woodside and Woodsway Consulting, Inc., disclaim all express\
                    or implied warranties with regard to this software, including, but not\
                    limited to, warranties of merchantability or fitness for any particular\
                    purpose. In no event shall Robert Woodside or Woodsway Consulting, Inc.,  be held\
                    liable for any special, indirect, or consequential damages, or any damages\
                    whatsoever resulting from loss of use, data, or profits, whether in an action\
                    of contract, negligence, or other tortious action, arising from or in\
                    connection with the use or performance of this software.\n"
		  $win.ht1 insert end "$text" italic2


		  # Set the other attributes

		  set ycmd "$win.sby set"
		  $win.ht1 configure -bg $hlbg -fg $hlfg -wrap word -state disabled \
		    -yscroll $ycmd 
		  $win.f2 configure -bg $hbg
		  set ycmd "$win.ht1 yview"
		  $win.sby configure -command $ycmd

  set wno 102
  ConfigureScrollbar $win.sby $wno 0


                  }


return 1
}


#-----------------------------------------------------------------------------
#  HelpReadme  --  Display the current README file
#-----------------------------------------------------------------------------
proc HelpReadme {}  {
global PgmName MenuHelp
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 54
  return 1
  }

set readme "$TkzG(TkzDir)/README"
set relnotes "$TkzG(TkzDir)/ReleaseNotes"
if {[file exists $relnotes]}  {
#  set tag1 [list "Release notes for older releases," "ReleaseNotes file."]
  set tag1 "Release notes for older releases,"
  set tag2 "ReleaseNotes file."
  set tag3 "Help -> View the Current FAQ"
  set tag4 "Improved Tar Detection"
  set cmd1 [list "DisplayList" $relnotes "$PgmName: ReleaseNotes" 0 ".relnote" ""]
  set cmd2 [list "DisplayList" $relnotes "$PgmName: ReleaseNotes" 0 ".relnote" ""]
  set cmd3 "HelpFaq"
  set cmd4 "DoHelpTarDetect"

  set tag1 [list $tag1 $tag2 $tag3 $tag4]
  set cmd1 [list $cmd1 $cmd2 $cmd3 $cmd4]
  set tags [list $tag1 $cmd1]
  }  else  {
  set tags ""
  }

DisplayList  $readme "$PgmName: README" 0 ".readme" $tags

return
}



#-----------------------------------------------------------------------------
#  DoHelp  --  A little wrapper for Help
#-----------------------------------------------------------------------------
proc DoHelp {}  {
  ShowHelp 1
  return 1
  }

#-----------------------------------------------------------------------------
#  DoHelpMIME  --  A little Help wrapper
#-----------------------------------------------------------------------------
proc DoHelpMIME {}  {
  ShowHelp 47
  return 1
  }
#-----------------------------------------------------------------------------
#  DoHelpTarDetect  --  A little Help wrapper
#-----------------------------------------------------------------------------
proc DoHelpTarDetect {}  {
  ShowHelp 12
  return 1
  }

#-----------------------------------------------------------------------------
#  HelpFaq  --  Display the current FAQ file
#-----------------------------------------------------------------------------
proc HelpFaq {}  {
global PgmName MenuHelp
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 64
  return 1
  }

set faqfile "$TkzG(TkzDir)/TkZip-FAQ"
set readme "$TkzG(TkzDir)/README"

if {[file exists $readme]}  {
  set tag1 "README file"
  set tag2 "Help -> Help"
  set tag3 "Edit MIME Types"
  set tag4 "MIME Types dialogue"
  set tag5 "File -> Show System Info"
  set cmd1 [list "DisplayList" $readme "$PgmName: README" 0 ".readme" ""]
  set cmd2 [list "DoHelp"]
  set cmd3 [list "DoHelpMIME"]
  set cmd4 [list "DoHelpMIME"]
  set cmd5 [list "ShowSysInfo"]

  set cmd1 [list $cmd1 $cmd2 $cmd3 $cmd4 $cmd5]
  set tag1 [list $tag1 $tag2 $tag3 $tag4 $tag5]
  set tags [list $tag1 $cmd1]
  }  else  {
  set tags ""
  }


DisplayList  $faqfile "$PgmName: FAQ" 0 ".faqfile" $tags

return
}

#-----------------------------------------------------------------------------
#  HelpLicense  --  Display the License info file
#-----------------------------------------------------------------------------
proc HelpLicense {}  {
global PgmName MenuHelp
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 65
  return 1
  }

set licinf "$TkzG(TkzDir)/License"
if {[file exists "$TkzG(TkzDir)/License2"]}  {
  set licinf "$TkzG(TkzDir)/License2"
  }
set tag1 [list "Help -> About"]
set cmd1 [list "About"]
set tags [list $tag1 $cmd1]
DisplayList  $licinf "$PgmName: License" 0 ".license" $tags

return
}


#-----------------------------------------------------------------------------
#  Register  --  Send a registration form, bug report, or comment
#-----------------------------------------------------------------------------
proc Register {context}  {
global OsName OsVer PgmName TkzVer AuthEmail
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg SelBg SelFg
global DSlidBg EntBg EntFg
global rname raddr1 raddr2 raddr3 rphone ros rcomments
global clicky clicky1 clicky2 clickybg1 clickybg2
global licreq nosend RegGeom printed
global BugOpt MenuHelp
global TkzG




set thisproc "Register"
set wn "reg"
set win ".$wn"
set what "what$wn"
set printed 0

set wno 0
set MainBg $TwBg($wno)
set MainFg $TwFg($wno)
set MainButBg $TwButBg($wno)
set MainButFg $TwButFg($wno)
set LBg $TwLBg($wno)
set LFg $TwLFg($wno)
set WEntBg $EntBg($wno)
set WEntFg $EntFg($wno)
set WSelBg $SelBg($wno)
set WSelFg $SelFg($wno)

set licinf "$TkzG(TkzDir)/License"
if {[file exists $licinf]}  {
  set gotlic 1
  }  else  {
  set gotlic 0
  }

global $what
if {$context == 1}  {
  if {$MenuHelp}  {
    set MenuHelp 0
    ShowHelp 18
    return 1
    }
  set wintitle "$PgmName: Register"
  set $what "Registration"
  }  else  {
  if {$MenuHelp}  {
    set MenuHelp 0
    ShowHelp 19
    return 1
    }
  set wintitle "$PgmName: Bug-Report/Comment"
  set BugOpt 1
  set $what "Bug-Report"
  }

if [catch {toplevel $win} rc]  {
  raise $win
  }  else  {
  wm title $win $wintitle
  wm iconname $win $wintitle

#-------------
if {$RegGeom != ""}  {
  set i [string first "+" $RegGeom]
  if {$i == -1}  {
    set i [string first "-" $RegGeom]
    }
  if {$i != -1}  {
    set RegGeom [string range $RegGeom $i end]
    wm geometry $win $RegGeom
    }
  }
#-------------

set nosend 0
set euser $TkzG(EmUser)
set ehost $TkzG(EmHost)
#  I'm tired of getting e-mail from root@darkstar...
if {[string first "Linux" $OsName] != -1}  {
  if {$TkzG(EmUser) == $TkzG(WhoIAm) && $TkzG(EmHost) == $TkzG(WhereIAm)}  {
    set euser ""
    set ehost ""
    set TkzG(EmUser) ""
    set TkzG(EmHost) ""
    }
  }
if {$euser == "" || $ehost == ""}  {
if {[string first "Linux" $OsName] == -1}  {
    set euser $TkzG(WhoIAm)
    set ehost $TkzG(WhereIAm)
    set TkzG(EmUser) $TkzG(WhoIAm)
    set TkzG(EmHost) $TkzG(WhereIAm)
    }
  }
set rname ""
set raddr1 ""
set raddr2 ""
set raddr3 ""
set rphone ""
set ros "$OsName $OsVer"
set company ""
set numusers ""
set rcomments ""


#label $win.msg -wraplength 6i -justify left -bg $LBg -fg $LFg
set txtf1 [frame $win.txtf1 -bg $LBg -highlightbackground $LBg]
set licf [frame $win.lf -bg $MainBg -highlightbackground $MainBg]
set prtf [frame $win.pf -bg $MainBg -highlightbackground $MainBg]
set msg "$txtf1.msg"
text $msg -wrap word -bg $LBg -fg $LFg \
  -height 11 -state normal

#pack $win.msg -side top

$win configure -bg $MainBg
frame $win.buttons -bg $MainBg

pack $win.buttons -side bottom -fill x -pady 2m
pack $prtf -side bottom -pady 2m
set cmd [list "KillReg" "$win"]
button $win.buttons.dismiss -bg $MainButBg -fg $MainButFg \
  -text "Dismiss" -command $cmd
button $win.buttons.send -bg $MainButBg -fg $MainButFg \
  -disabledforeground red
button $win.buttons.file -bg $MainButBg -fg $MainButFg \
  -text "Save as File"
set cmd [list "PrtReg" "$wn" "$context"]
button $win.buttons.prt -bg $MainButBg -fg $MainButFg \
  -text "Print" -command $cmd

pack $win.buttons.dismiss $win.buttons.send $win.buttons.prt $win.buttons.file \
  -side left -expand 1

foreach i {"e1" "e2" "e3" "r1" "r2" "r3" "r4" "r5" "r6" "r7" "r8"} {
    if {$i == "r7" || $i == "r8"}  {
      if {$licreq}  {
        frame $win.$i -bd 2 -bg $MainBg
        entry $win.$i.entry -relief sunken -width 30 -bg $WEntBg -fg $WEntFg
        label $win.$i.label -width 14 -bg $MainBg -fg $MainFg
        entry $win.$i.entry2 -relief sunken -width 8 -bg $WEntBg -fg $WEntFg
        label $win.$i.label2 -width 11 -bg $MainBg -fg $MainFg
        pack $win.$i.label $win.$i.entry $win.$i.label2 $win.$i.entry2 -side left
        }
      }  else  {
      frame $win.$i -bd 2 -bg $MainBg
      entry $win.$i.entry -relief sunken -width 50 -bg $WEntBg -fg $WEntFg
      label $win.$i.label -width 14 -bg $MainBg -fg $MainFg
      pack $win.$i.label $win.$i.entry -side left
      }
}

frame $win.t -bg $MainBg
label $win.t.l -width 14 -bg $MainBg  -fg $MainFg

$msg tag configure seelic -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-* \
  -foreground $clicky
$msg tag configure bold -font -*-$TkzG(NonameFont)-Bold-R-Normal-*-*-120-*-*-*-*-*-* \
  -justify center
$msg tag bind seelic <1> "HelpLicense"


switch    $context  {
    1    {
      set text "Please read before sending e-mail"
      $msg insert end $text bold
      set text "\n    Use this form to register or license $PgmName. You can e-mail it\
        to the author at $AuthEmail, save it as a file to mail later, or print it.\
        \n    Registration simply gives the author feedback on how many people\
        are using the program, and in what environments. It does not cost anything\
        or incur any obligation.\
        Licensing does (see "
      $msg insert end $text
      set text "License Info"
      if {$gotlic}  {
        $msg insert end $text seelic
        }  else  {
        $msg insert end $text
        }
      set text ")."
      $msg insert end $text

      set text "\n    NOTE: if your Internet connection is via an ISP, please enter your\
        real Internet e-mail\
        address below. I can't reply to 'sillyme@bogus.domain.com'\
        or 'root@Darkstar'."
      $msg insert end $text
      set text "\n    If you wish to print the form, alter the print command below\
        to suit your system. After printing it will be saved for future use."
      $msg insert end $text
      set text "\n    This form will attach a good bit of information about your\
        system. This is not Big Brother watching, it's necessary information that\
        I would have to ask you for anyway if you're reporting a problem. Please don't\
        try to detach it."
      $msg insert end $text 
      $win.buttons.send configure -text "Send Registration Form"
      $win.t.l configure -text "Comments: "
      $msg configure -height 8
      }
    2    {
      set text "Please read before sending e-mail"
      $msg insert end $text bold
      set text "\n    The preferred method of submitting a bug report or general comment is to use this form to E-mail it\
          to the author at $AuthEmail, save it as a file to mail later,\
          or print it."
      $msg insert end $text
      set text "\n    NOTE: if your Internet connection is via an ISP, please enter your\
        real Internet e-mail\
        address below. I can't reply to 'sillyme@bogus.domain.com'\
        or 'root@Darkstar'."
      $msg insert end $text 
      set text "\n    If you wish to print the form, alter the print command below\
        to suit your system. After printing it will be saved for future use."
      $msg insert end $text
      set text "\n    This form will attach a good bit of information about your\
        system. This is not Big Brother watching, it's necessary information that\
        I would have to ask you for anyway if you're reporting a problem. Please don't\
        try to detach it."
      $msg insert end $text 
      $win.buttons.send configure -text "Send Bug Report"
      $win.t.l configure -text "Description: "
      $msg configure -height 8

      }
    }


text $win.t.t -bg $LBg -fg $LFg -height 10 -width 50 -wrap word
BuildScrollbar "$win.t.t" 0 0
pack $win.t.l $win.t.t $win.t.sby -side left -fill y

$win.e1.label configure -text "User:"
$win.e1.entry configure -textvariable TkzG(EmUser)
$win.e2.label configure -text "Host:"
$win.e2.entry configure -textvariable TkzG(EmHost)
$win.r1.label configure -text "Name:"
$win.r1.entry config -textvariable rname
$win.r2.label configure -text "Address:"
$win.r1.entry config -textvariable raddr1
$win.r1.entry config -textvariable raddr2
$win.r1.entry config -textvariable raddr3
#$win.r5.label configure -text "Phone:"
#$win.r5.entry config -textvariable rphone
$win.r6.label configure -text "OS Version:"
$win.r6.entry config -textvariable ros
if {$licreq}  {
  $win.r8.label configure -text "Company:"
  $win.r8.entry config -textvariable company
  $win.r8.label2 configure -text "# of Users:"
  $win.r8.entry2 config -textvariable numusers
  $win.r7.label configure -text "Phone:"
  $win.r7.entry config -textvariable rphon
  $win.r7.label2 configure -text "Zip:"
  $win.r7.entry2 config -textvariable zip
  $msg configure -height 6
  }
label $prtf.prtt -bg $MainBg -fg $MainFg -highlightbackground $MainBg \
  -text "Print Command"
entry $prtf.prte  -bg $WEntBg -fg $WEntFg -highlightbackground $WEntBg \
  -textvariable TkzG(PrtCmd)
pack $prtf.prtt $prtf.prte -side left -padx 4
if {$context == 1}  {
  #  Register...
  set cmd [list "ReqLicense" "$win"]
  checkbutton $licf.lic -variable licreq -text "Request License" \
    -bg $MainBg -fg $MainFg -highlightbackground $MainBg \
    -command $cmd
  pack $licf.lic -side left

#  pack $win.msg $win.e1 $win.e2 $win.r1 $win.r2 $win.r3 $win.r6 $win.t -side top -fill x
  BuildScrollbar "$msg" 0 0
  pack $msg $txtf1.sby -side left -fil y
  pack $txtf1 -side top -fill x
#  pack $win.lic -anchor center
  pack $licf -anchor center
  if {! $licreq}  {
    pack $win.e1 $win.e2 $win.r1 $win.r2 $win.r3 $win.r6 $win.t -side top -fill x
    }  else  {
    pack $win.e1 $win.e2 $win.r1 $win.r8 $win.r2 $win.r3 $win.r7 $win.r6 $win.t -side top -fill x
    }
  }  else  {
  #  Bug Report/comment...
  frame $win.brcf -bg $MainButBg
  button $win.brcf.brb -width 10 -bg $MainButBg -fg $MainButFg \
    -text "Bug/Comment"
  label $win.brtag -bg $MainBg -fg $MainFg -text "Bug Report" \
    -font "-*-*-Bold-*-*-*-*-160-*-*-*-*-*-*"

#  pack $win.msg $win.e1 $win.e2 $win.r1 $win.r2 $win.r3 $win.r6 -side top -fill x
  BuildScrollbar "$msg" 0 0
  pack $msg $txtf1.sby -side left -fil y
  pack $txtf1 -side top -fill x
  pack $win.e1 $win.e2 $win.r1 $win.r2 $win.r3 $win.r6 -side top -fill x
  pack $win.brtag -anchor center
  pack $win.brcf.brb -side top
  pack $win.t $win.brcf -side left -fill x
  set cmd "ToggleRept $wn"
  bind $win.brcf.brb <Button-1> $cmd
#  set cmd "Comment $wn"
#  bind $win.brcf.cb <Button-1> $cmd
  }
#$msg configure -state disabled


set cmd "SendReg $wn 1 $context"
bind $win.buttons.send <Button-1> $cmd
set cmd "SendReg $wn 2 $context"
bind $win.buttons.file <Button-1> $cmd
focus $win.e1.entry
update idletasks
set where [$txtf1.msg yview]
set where [lindex $where 1]
if {$where < 1}  {
  if {$TkzG(EmUser) == "" || $TkzG(EmHost) == ""}  {
    set cmd [list "RegScroll" $win]
    $txtf1.sby configure -command $cmd
    set nosend 1
    }
  }

tkwait window $win

if { $printed || $TkzG(EmUser) != $euser || $TkzG(EmHost) != $ehost}  {
  SaveConfig
  }


		  }
return 1
}

proc ToggleRept {wn}  {
global BugOpt

set BugOpt [ToggleOpt $BugOpt] 
if {$BugOpt}  {
  BugRpt "$wn"
  }  else  {   
  Comment "$wn"
  }
return 1
}

proc RegScroll {wn func num type}  {
global nosend

set bar "$wn.txtf1.sby"
set text "$wn.txtf1.msg"

$text yview $func $num $type
set where [$text yview]
if {[lindex $where 1] == 1}  {
  set nosend 0
  set cmd "$text yview"
  $bar configure -command $cmd
  }

return
}

proc ReqLicense {win}  {
global licreq RegGeom

set RegGeom [wm geometry $win]
destroy $win
Register 1

return
}

proc KillReg {win}  {
global licreq RegGeom

set RegGeom ""
set licreq 0
destroy $win

return
}

proc PrtReg {win context}  {
global licreq printed

SendReg $win 3 $context
set printed 1

return
}

proc BugRpt {wn}  {
global TkzG
set what "what$wn"
global $what
set $what "Bug-Report"
.$wn.brtag configure -text "Bug-Report"
#.$wn.brtag configure -text "     Bug-Report        "
.$wn.buttons.send configure -text "Send Bug Report"
.$wn.t.l configure -text "Description: "
return 1
}

proc Comment {wn}  {
global TkzG
set what "what$wn"
global $what
set $what "Comment"
.$wn.brtag configure -text "Just a Comment"
.$wn.buttons.send configure -text "Send Comments"
.$wn.t.l configure -text "Comments: "
return 1
}

proc SendReg {wn func context}  {
global WhoBg MainButBg MainBg MainFg Home TempDir PgmName TkzVer AuthEmail ErrArgs
global Timehdr rname raddr1 raddr2 raddr3 rphone ros rcomments
global nosend licreq nodesc
global TkzG
set thisproc "SendReg"


if {$nosend && $func == 1}  {
  GErrMsgBox 69
  return -1
  }
set nolic 0
set owner ".$wn"
#  Disable the send button to discourage spam sending...
.$wn.buttons.send configure -relief sunken -state disabled
update idletasks

set whatisit "what$wn"
if {$TkzG(EmUser) == "" || $TkzG(EmHost) == ""}  {
  if {$func == 1}  {
    GErrMsgBox 70
    .$wn.buttons.send configure -relief raised -state normal
    update idletasks
    return -1
    }
  }

global $whatisit
set mailer ""
set mailers "/bin/mail /bin/Mail /usr/bin/Mail /usr/bin/mail"
foreach mailpgm $mailers  {
  if {$mailer == "" && [file exists $mailpgm]}  {
    set mailer $mailpgm
    }
  }

if {$context == 1}  {
  if {$func == 1 || $func == 2}  {
    set fn "$Home/$PgmName-$TkzVer-Registration.txt"
    }  else  {
    set fn "$PgmName-$TkzVer-Registration"
    }

  set subj "Register $PgmName $TkzVer to $TkzG(EmUser)@$TkzG(EmHost)"
  if {! $licreq}  {
    set msghd "\n        Registration Request for $PgmName $TkzVer\n"
    }  else  {
    set msghd "\n        Registration Request for $PgmName $TkzVer\n\
               \n              ****   License Request   ****\n"
    }
  set what "Registration"
  }  
if {$context == 2}  {
  set what [ set $whatisit ]
  if {$func == 1 || $func == 2}  {
    set fn "$Home/$PgmName-$TkzVer-$what.txt"
    }  else  {
    set fn "$PgmName-$TkzVer-$what"
    }

  set subj "$what $PgmName $TkzVer from $TkzG(EmUser)@$TkzG(EmHost)"
  set msghd "\n           $what for $PgmName $TkzVer\n"
  }

bind .$wn.buttons.send <Button-1> ""
set TkzG(EmUser) [ $owner.e1.entry get ]
set TkzG(EmHost) [ $owner.e2.entry get ]
set rname [ $owner.r1.entry get ]

set raddr1 [ $owner.r2.entry get ]
set raddr2 [ $owner.r3.entry get ]
if {$licreq}  {
  set company [ $owner.r8.entry get ]
  set numusers [ $owner.r8.entry2 get ]
  set rphone [ $owner.r7.entry get ]
  set zip [ $owner.r7.entry2 get ]
  }  else  {
  set company ""
  set numusers ""
  set phone ""
  set zip ""
  }
#set raddr3 [ $owner.r4.entry get ]
#set rphone [ $owner.r5.entry get ]

set ros [ $owner.r6.entry get ]
set comments [ $owner.t.t get 1.0 end]
set sysinfo "$TempDir/TkzSysinfo"
set sinf ""
catch {set si [open $sysinfo r]}
while  { [ gets $si line ] > -1 } {
  set sinf "$sinf\n$line"
  }
catch {close $si}

if {$rname == "" || $numusers == ""}  {
  set nolic 1
  }
if {$raddr1 == "" && $raddr2 == ""}  {
  set nolic 1
  }

#set subj "Register $PgmName $TkzVer to $TkzG(EmUser)@$TkzG(EmHost)"
set msg "$msghd \
  \nName:          $rname"
if {$licreq}  {
  set msg "$msg  \nCompany:       $company \
    \nNo. of Users:  $numusers"
  }
set msg "$msg  \nAddress:       $raddr1 \
  \n               $raddr2"
if {$licreq}  {
  set msg "$msg  \nZip:           $zip \
    \nPhone:         $rphone"
  }
set msg "$msg  \nUser id:       $TkzG(EmUser) \
  \nHost:          $TkzG(EmHost) \
  \nOS Version:    $ros \
  \nDate/Time:     $Timehdr \
  \n\n\nComments: \
  \n\n$comments \
  \n\n\n\nAdditional System Information: \
  \n\n$sinf"

if {$func == 1}  {
  if {$TkzG(EmUser) == ""}  {
    set ErrArgs [list $what]
    GErrMsgBox 5
    return -1
    }
  if {$TkzG(EmHost) == ""}  {
    set ErrArgs [list $what]
    GErrMsgBox 5
    return -1
    }
  }

#  func    --  1 = send,  2 = save,  3 = print
#  context --  1 = Register,  2 = Bug Report

switch      $func  {
	1    {
          if {$mailer == ""}  {
            set ErrArgs [list $AuthEmail $what]
            GErrMsgBox 13
            return -1
            }
          #  The old llength test failed if text xontained braces or parens.
          set cmt3 [lindex $comments 2]
          if {$context == 2 && $cmt3 == ""}  {
            GErrMsgBox 66
            .$wn.buttons.send configure -relief raised -state normal
            set cmd "SendReg $wn 1 $context"
            bind .$wn.buttons.send <Button-1> $cmd
            return -1
            }
          if {$context == 1 && $licreq && $nolic}  {
            GErrMsgBox 65
            .$wn.buttons.send configure -relief raised -state normal
            set cmd "SendReg $wn 1 $context"
            bind .$wn.buttons.send <Button-1> $cmd
            return -1
            }
	  set rc [catch {exec echo $msg | $mailer -s "$subj" $AuthEmail} cc]

	  if {$rc == 0}  {
	    set ErrArgs [list $AuthEmail $what]
	    GErrMsgBox 10
	    }  else  {
	    set ErrArgs [list $AuthEmail $what]
	    GErrMsgBox 11
	    }
	  }
	2    {
          catch {set fi [open $fn w]}
          catch {puts $fi $msg}
	  catch {close $fi}
	  set ErrArgs [list $fn $what]
	  GErrMsgBox 9
	  }
	3    {
          catch {set fi [open $fn w]}
          catch {puts $fi $msg}
	  catch {close $fi}
          set cmd "exec $TkzG(PrtCmd) $fn"
          set rc [catch {eval $cmd} dummy] 
          if {$TkzG(Portable)}  {
            catch {file delete -force $fn}
            }  else  {
            catch {exec rm -f $fn}
            }
          set ErrArgs [list $what]
          GErrMsgBox 68
	  }
	}
.$wn.buttons.send configure -relief raised -state normal
update idletasks


return 1
}

#-----------------------------------------------------------------------------
#  ShowSysInfo  --  Tell a little about the environment 
#-----------------------------------------------------------------------------
proc ShowSysInfo {}  {
global PgmName TkzVer TkzDate GotPgmFlags NeededPgmFlags
global GotPgmFlags2 NeededPgmFlags2 NeededPgmFlags3
global OsName OsVer TclVer TkVer MyPid MenuHelp MainFg
global TwBg TwFg TwButBg TwButFg TwLBg TwLFg TrCol SlidBg EntBg EntFg
global DSlidBg NumWins
global TkzG

if {$MenuHelp}  {
  set MenuHelp 0
  ShowHelp 06
  return 1
  }

set thisproc "ShowSysInfo"

set wnum 101
set sibg $TwBg($wnum)
set sifg $TwFg($wnum)
set silbg $TwLBg($wnum)
set silfg $TwLFg($wnum)
set sibutbg $TwButBg($wnum)
set sibutfg $TwButFg($wnum)
set sbg $SlidBg($wnum)
set tcol $TrCol($wnum)

if {$sbg != "UseTk"}  {
  if {$sbg == "UseDefault"}  {
    set sbg $DSlidBg
    }  else  {
    set sbg $SlidBg($wnum)
    }
  }  else  {
  set tmp [.$wname.list1.diry configure -bg]
  set sbg [lindex $tmp 3]
  }
if {$tcol != "UseTk"}  {
  if {$tcol == "UseBg"}  {
    set tcol $sibg
    }  else  {
    set tcol $TrCol($wnum)
    }
  }  else  {
  set tmp [.$wname.list1.diry configure -troughcolor]
  set tcol [lindex $tmp 3]
  }


set wn "sinfo"
set win ".$wn"
set wintitle "$PgmName: SysInfo"
set mailer ""
set mailers "/bin/mail /bin/Mail /usr/bin/Mail /usr/bin/mail"
foreach mailpgm $mailers  {
  if {$mailer == "" && [file exists $mailpgm]}  {
    set mailer $mailpgm
    }
  }

if [catch {toplevel $win} rc]  {
  raise $win
  }  else  {
  wm title $win $wintitle
  wm iconname $win $wintitle

$win configure -bg $sibg
set cmd "KillSysinfo $win"
button $win.b1 -bg $sibutbg -fg $sibutfg -text "OK" -command $cmd

set arc $win.f1
set arc2 $win.f2
set arc3 $win.f3
frame $arc -bg $sibg
frame $arc2 -bg $sibg
frame $arc3 -bg $sibg
label $arc.l1 -text "\nArchive Programs" -bg $sibg -fg $sifg -font "-*-$TkzG(RomanFont)-Bold-R-*-*-*-180-*-*-*-*-*-*" 
text $arc.l2 -width 40 -height 4 -relief flat -bg $sibg -fg $sifg  -highlightbackground $sibg -wrap word
$arc.l2 insert end "    Checked programs appear to be present and functioning compatibly with $PgmName. \
  Programs that are unchecked either couldn't be found on your system, or don't respond in a way that is\
  compatible with this release of $PgmName."
$arc.l2 configure -state disabled
pack $arc.l1 $arc.l2 -side top -fill x -expand no

set i 0
while {[lindex $TkzG(NeededPgms) $i] != ""}  {
  set pgm [lindex $TkzG(NeededPgms) $i]
  checkbutton $arc.$i -width 14 -bg $sibg -fg $sifg -highlightbackground $sibg -text $pgm \
  -disabledforeground $sifg -anchor w -justify left
  pack $arc.$i -side left -fill x -expand yes

  set flag [lindex $NeededPgmFlags $i]
  global $flag
  $arc.$i configure -variable $flag
  if {$TkzG(Debug)}  {
    $arc.$i configure -state normal
    }  else  {
    $arc.$i configure -state disabled
    }
  incr i
  }

set i 0
while {[lindex $TkzG(NeededPgms2) $i] != ""}  {
  set pgm [lindex $TkzG(NeededPgms2) $i]
  checkbutton $arc2.$i -width 14 -bg $sibg -fg $sifg -highlightbackground $sibg -text $pgm \
  -disabledforeground $sifg -anchor w -justify left
  pack $arc2.$i -side left -fill x -expand yes

  set flag [lindex $NeededPgmFlags2 $i]
  global $flag
  $arc2.$i configure -variable $flag
  if {$TkzG(Debug)}  {
    $arc2.$i configure -state normal
    }  else  {
    $arc2.$i configure -state disabled
    }
  incr i
  }

set i 0
while {[lindex $TkzG(NeededPgms3) $i] != ""}  {
  set pgm [lindex $TkzG(NeededPgms3) $i]
  checkbutton $arc3.$i -width 14 -bg $sibg -fg $sifg -highlightbackground $sibg -text $pgm \
  -disabledforeground $sifg -anchor w -justify left
  pack $arc3.$i -side left -fill x -expand yes

  set flag [lindex $NeededPgmFlags3 $i]
  global $flag
  $arc3.$i configure -variable $flag
  if {$TkzG(Debug)}  {
    $arc3.$i configure -state normal
    }  else  {
    $arc3.$i configure -state disabled
    }
  incr i
  }

set topf $win.topf
frame $topf -bg $sibg
set gen "$topf.f2"
frame $gen -bg $sibg
label $gen.l1 -text "\nGeneral" -bg $sibg -fg $sifg -font "-*-$TkzG(RomanFont)-Bold-R-*-*-*-180-*-*-*-*-*-*" 
frame $gen.f1 -bd 2 -bg $sibg
label $gen.f1.l2 -bg $sibg -fg $sifg -justify left -text "OS Version:      "
label $gen.f1.l3 -bg $sibg -fg $sifg -justify left -text "$OsName  $OsVer"
frame $gen.f2 -bg $sibg
label $gen.f2.l4 -bg $sibg -fg $sifg -justify left -text "Tcl/Tk Version:  "
label $gen.f2.l5 -bg $sibg -fg $sifg -justify left -text "$TclVer/$TkVer"
frame $gen.f3 -bg $sibg
label $gen.f3.l6 -bg $sibg -fg $sifg -justify left -text "Pid:  "
label $gen.f3.l7 -bg $sibg -fg $sifg -justify left -text "$MyPid"
 
pack $gen.l1 -side top -fill x
pack $gen.f1.l2 $gen.f1.l3 -side left -expand no -fill none
pack $gen.f2.l4 $gen.f2.l5 -side left -fill none -expand no
pack $gen.f3.l6 $gen.f3.l7 -side left -fill none -expand no
pack $gen.f1 $gen.f2 $gen.f3 -side top -fill none -expand no -anchor w

set tkz "$topf.f3"
frame $tkz -bg $sibg
label $tkz.l1 -text "\n$PgmName" -bg $sibg -fg $sifg -font "-*-$TkzG(RomanFont)-Bold-R-*-*-*-180-*-*-*-*-*-*" 
frame $tkz.f1 -bd 2 -bg $sibg
label $tkz.f1.l1 -bg $sibg -fg $sifg -justify left -text "$PgmName Version:  "
label $tkz.f1.l2 -bg $sibg -fg $sifg -justify left -text "$TkzVer"
frame $tkz.f2 -bd 2 -bg $sibg
label $tkz.f2.l1 -bg $sibg -fg $sifg -justify left -text "Build Date:        "
label $tkz.f2.l2 -bg $sibg -fg $sifg -justify left -text "$TkzDate"
pack $tkz.l1 -side top -fill x
pack $tkz.f1.l1 $tkz.f1.l2 -side left -expand no -fill none -anchor w
pack $tkz.f2.l1 $tkz.f2.l2 -side left -expand no -fill none -anchor w
pack $tkz.f1 $tkz.f2 -side top -fill none -expand no -anchor w

set mailf "$win.f4"
frame $mailf -bg $sibg
if {$mailer == ""}  {
  set canwe "cannot"
  set mailer "Not Found"
  }  else  {
  set canwe "can"
  set mailer "Found    ($mailer)"
  }
label $mailf.l1 -text "\nMail Capability" -bg $sibg -fg $sifg -font "-*-$TkzG(RomanFont)-Bold-R-*-*-*-180-*-*-*-*-*-*" 
text $mailf.l2 -width 40 -height 4 -relief flat -bg $sibg -fg $sifg  -highlightbackground $sibg -wrap word
$mailf.l2 tag configure bold -font -*-$TkzG(NonameFont)-Bold-$TkzG(SlantO)-Normal-*-*-120-*-*-*-*-*-*
$mailf.l2 insert end "    $PgmName uses a very basic technique to send Bug Reports and Registration\
  Forms to the Author, and depends on your having a standard AT&T style mail command available on\
  your system. $PgmName believes that it "
$mailf.l2 insert end "$canwe " bold
$mailf.l2 insert end "send mail this way."
label $mailf.l3 -bg $sibg -fg $sifg -text "Mailer:              $mailer"
$mailf.l2 configure -state disabled
pack $mailf.l1 -side top -fill x -expand no 
pack $mailf.l2 -side top -fill x -expand no
pack $mailf.l3 -side top -fill x -expand yes


pack $win.b1 
#pack $win.l1 -side top -fill x
#pack $win.l2 -side top -fill both -expand no 
#pack $win.f1 -side top -fill x -expand no
pack $gen -side left 
pack $tkz -side right
#pack $gen $tkz -side left -fill x -anchor center
pack $topf -side top -fill x 

#pack $arc.l1 -side left -fill x
#pack $arc.l2 -side top -fill both -expand no 
pack $arc -side top -fill x
pack $arc2 -side top -fill x
pack $arc3 -side top -fill x

pack $mailf -side top -fill x -expand yes



  }


return 1
}

#------------------------------------------------------
#  KillSysInfo  --  in case any special cleanup needed 
#------------------------------------------------------
proc KillSysinfo {win}  {

destroy $win
return 1
}

#------------------------------------------------------
#  DeBug  --   Interactive display or logging
#------------------------------------------------------
proc DeBug {owner msg}  {
global ErrArgs Home
global TkzG

set dblog "$Home/TkzDebuglog"
if {$TkzG(Debugi)}  {
  if {$TkzG(Debugl)}  {
    catch {set db [open $dblog a+]}
    catch {puts $db "$msg"}
    catch {close $db}
    }
  set ErrArgs [list $msg]
  set rc [GModMsgBox $owner 102]
  return $rc
  }  else  {
  if {$TkzG(Debugl)}  {
    catch {set db [open $dblog a+]}
    catch {puts $db "$msg"}
    catch {close $db}
    }
  }
return 1
}




#------------------------------
# Here's the real program...
#   Not very impressive, huh?
#------------------------------

Init
BuildMainFrame
# If cmd line arg specified a file, open up a window for it.
if {$InitFile != ""} {
  update idletasks
  DispArc $CurDir $InitFile 0 0
  }
if {$TkzG(PipeIn)}  {
  update idletasks
  DispArc $TempDir TkzPipe 0 0
  }
if {$TkzG(InitFlag)}  {
  update idletasks
  About
  }

# Thatz all, folks!

