home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / TE2HOST.ZIP / VIEWZIP.SCR < prev    next >
Text File  |  1990-12-27  |  3KB  |  96 lines

  1. ;; --------------------------------------------------------------------------
  2. ;;
  3. ;; ViewZIP.scr -- Host mode script suite for TE/2
  4. ;;                Copyright 1990, Oberon Software, All rights reserved
  5. ;;
  6. ;; --------------------------------------------------------------------------
  7.  
  8. global string  CmdStack
  9. global string  FileSpec
  10. global string  DfltSpec
  11. global integer WatchUser
  12.  
  13.   ;; ---------------------------------------------------
  14.   ;; Archivers, modify these to match your system setup:
  15.  
  16. string  PkUnZip      = "pkunzip"
  17. string  SeaArc       = "arc2"
  18. string  LhArc        = "lharc2"
  19. string  Zoo          = "zoo"
  20.  
  21. string  buffer
  22. integer retcode
  23.  
  24.   ;; ------------------------------------------------------------------------
  25.   ;; Perform a verbose listing os the contents of a ZIP, ARC, LZH, or ZOO
  26.   ;;  archive.  If you don't have all of these archive programs, you'll
  27.   ;;  probably want to comment out part of this routine.  Note that the
  28.   ;;  names of the archivers are stored in variables, if they are named
  29.   ;;  something different on your system, or need to be pathed to, they
  30.   ;;  can easily be changed.
  31.  
  32. subroutine ViewArchive
  33.  
  34.   if strlen(CmdStack) == 0
  35.     transmit("^M^JView ZIP or ARC File:")
  36.     DfltSpec = ""
  37.     run("getfspec.scr")
  38.   else
  39.     FileSpec = CmdStack
  40.     CmdStack = ""
  41.   endif
  42.  
  43.   if strlen(FileSpec)
  44.  
  45.     ;; If the FileSpec is shorter than 5 characters it CAN'T have and
  46.     ;; extension, add ".zip"
  47.     if strlen(FileSpec) < 5
  48.       FileSpec = FileSpec + ".ZIP"
  49.     endif
  50.  
  51.     ;; Extract the extension into buffer
  52.     buffer = strright(FileSpec, 4)
  53.     buffer = toupper(buffer)
  54.  
  55.     ;; Now, make sure that it IS an extension, if not, add ".zip"
  56.     if asciival(buffer) != asciival(".")
  57.       FileSpec = FileSpec + ".ZIP"
  58.       buffer = ".ZIP"
  59.     endif
  60.  
  61.     transmit("^M^J")
  62.     message("^M^JUser is viewing archive [%s]", FileSpec)
  63.  
  64.     ;; Execute the proper archiver based on extension
  65.     if strcmp(buffer, ".ZIP") == 0
  66.       buffer = sprintf("-v %s", FileSpec)
  67.       retcode = rshell(PkUnZip, buffer, 1)
  68.     elseif strcmp(buffer, ".ARC") == 0
  69.       buffer = sprintf("v %s", FileSpec)
  70.       retcode = rshell(SeaArc, buffer, 1)
  71.     elseif strcmp(buffer, ".LZH") == 0
  72.       buffer = sprintf("-v %s", FileSpec)
  73.       retcode = rshell(LhArc, buffer, 1)
  74.     elseif strcmp(buffer, ".ZOO") == 0
  75.       buffer = sprintf("v %s", FileSpec)
  76.       retcode = rshell(Zoo, buffer, 1)
  77.     else
  78.       transmit("^M^JSorry, don't know how to view ""%s"".", FileSpec)
  79.       retcode = 0
  80.     endif
  81.  
  82.     if retcode != 0
  83.       transmit("^M^JError executing archive program")
  84.     endif
  85.     transmit("^M^JPress any key to continue...")
  86.     rgetc(30, 1)
  87.   endif
  88.  
  89. endsub
  90.  
  91.  
  92. program
  93.   gosub ViewArchive
  94.   end
  95.  
  96.