home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / vwinterfac.tcl < prev    next >
Text File  |  1996-08-27  |  3KB  |  117 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cadre Technologies Inc.    1996
  4. #
  5. #      File:           @(#)vwinterfac.tcl    /main/hindenburg/3
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)vwinterfac.tcl    /main/hindenburg/3   27 Aug 1996 Copyright 1996 Cadre Technologies Inc.
  10.  
  11. # Start user added include file section
  12. require stgenerato.tcl
  13. require stfilehand.tcl
  14. require platform.tcl
  15. # End user added include file section
  16.  
  17. require "stinterfac.tcl"
  18.  
  19. Class VWInterface : {STInterface} {
  20.     constructor
  21.     method destructor
  22.     method startST
  23. }
  24.  
  25. constructor VWInterface {class this name} {
  26.     set this [STInterface::constructor $class $this $name]
  27.     # Start constructor user section
  28.     $this fileHandler [STFileHandler new]
  29.     $this generator [STGenerator new]
  30.     # End constructor user section
  31.     return $this
  32. }
  33.  
  34. method VWInterface::destructor {this} {
  35.     # Start destructor user section
  36.     # End destructor user section
  37.     $this STInterface::destructor
  38. }
  39.  
  40.  
  41. # Starts Visualworks. Tries to locate the VisualWorks 
  42. # installation directory by scanning the PATH. If that is found
  43. # tries to locate the image by reading VWIMAGEPATH.
  44. # If it is not set the standard image is used.
  45. # File name handling is Unix specific.
  46. #
  47. method VWInterface::startST {this} {
  48.     if [catch { set envPath $env(PATH) }] {
  49.     wmtkerror "environment variable PATH not found"
  50.     return
  51.     }
  52.  
  53.     set visualPath ""
  54.     # visualKey is used to recognize the VW installation in the PATH
  55.     set visualKey "visual"
  56.  
  57.     if $win95 {
  58.     set pathSep "\\"
  59.     set envPathSep ";"
  60.     set visualExecName "vw.exe"
  61.     } else {
  62.     set pathSep "/"
  63.     set envPathSep ":"
  64.     set visualExecName "visualworks"
  65.     }
  66.  
  67.     foreach pathSpec [split $envPath $envPathSep] {
  68.     set dirList [split $pathSpec $pathSep]
  69.     set index [lsearch -exact $dirList $visualKey]
  70.     if { $index == -1 } {
  71.         set index [lsearch -exact $dirList [string toupper $visualKey]]
  72.     }
  73.     if { $index != -1 } {
  74.         # found it! find root: directories up to and including key
  75.         set visualPath [join [lrange $dirList 0 $index] $pathSep]
  76.     }
  77.     }    
  78.  
  79.     if { $visualPath == "" } {
  80.     wmtkerror "VisualWorks not found in PATH"
  81.     return
  82.     }
  83.  
  84.     set visualExec [path_name concat [path_name concat $visualPath bin] \
  85.                                  $visualExecName]
  86.  
  87.     if { ![file exists $visualExec] } {
  88.     wmtkerror "VisualWorks executable not found"
  89.     return
  90.     }
  91.  
  92.     if [catch { set imagePath $env(VWIMAGEPATH) }] {
  93.     wmtkwarning "VWIMAGEPATH not set, using standard image"
  94.     set imagePath [path_name concat $visualPath image]
  95.     }
  96.  
  97.     if { ![file exists $imagePath] } {
  98.     wmtkerror "Image path not found"
  99.     return
  100.     }
  101.  
  102.     set imageFile [path_name concat $imagePath visual im]
  103.  
  104.     if { ![file exists $imageFile] } {
  105.     wmtkerror "Image file not found"
  106.     return
  107.     }
  108.  
  109.     # All set, do it
  110.     system "$visualExec $imageFile &" 
  111.  
  112. # Do not delete this line -- regeneration end marker
  113.  
  114. VWInterface new .main.vw
  115.  
  116.