home *** CD-ROM | disk | FTP | other *** search
/ TopWare Tools / TOOLS.iso / tools / top1629 / viewfile.btm < prev   
Encoding:
Text File  |  1993-10-01  |  5.7 KB  |  193 lines

  1. @ECHO OFF
  2. REM
  3. REM VIEWFILE.BTM Copyright 1993 by Bernd Schemmer   Version 2.00
  4. REM
  5. REM Function: View file/archivs
  6. REM
  7. REM Usage: ViewFile {file|dir}
  8. REM
  9. REM VIEWFILE.BTM is freeware. So use and share it freely!
  10. REM Send any comments and problem reports to
  11. REM
  12. REM     Bernd Schemmer
  13. REM     Bäckerweg 48
  14. REM     60316 Frankfurt
  15. REM     Germany
  16. REM     Phone: +49 (069) 4 97 84 04 (only in the evening of MEZ)
  17. REM
  18. REM Last Update: 01.10.93
  19. REM
  20. REM Note: Set the variable "ArcPath" if your packers are in a directory
  21. REM       which is not in the path.
  22. REM
  23. REM       ViewFile supports the archivs .ARJ, .ZIP, .LHA, .LZH,
  24. REM       .ICE, .SQZ, .ARC, .PAK and .ZOO.
  25. REM
  26. REM History: V1.00 - first release
  27. REM          V1.10 - minor changes
  28. REM          V1.20 - ViewFile is now compound char independent
  29. REM                  ViewFile now returns the following errorlevels:
  30. REM                  0 = okay
  31. REM                  1 = error
  32. REM                  2 = user pressed ALT-X
  33. REM          V1.30 - added support for .ARC- and .PAK-archivs
  34. REM          V2.00 - changes for 4OS2
  35. REM                  NOTE: You must use % as parameter char to use this
  36. REM                        BTM with 4OS2
  37. REM
  38. SETLOCAL
  39.  
  40.                                             REM directory with the pack programr(s)
  41. IFF "%_DOS%" == "DOS" THEN
  42.     *SET arcPath=C:\DOS\TOOLS\ARCHIV
  43. ELSE
  44.     *SET arcPath=C:\OS_2\TOOLS\ARCHIV
  45. ENDIFF
  46.  
  47.                                             REM Check OS and 4DOS version
  48. IFF "%_DOS" != "OS2" THEN
  49.     IFF "%_4VER" LE "4.00" .OR. "%_DOSVER" LE "3.30" THEN
  50.         ECHO. Sorry, ViewFile needs DOS 3.3+ and 4DOS 4+!
  51.         ECHO. (currently you have DOS %_DOSVER and 4DOS %_4VER)
  52.         QUIT 1
  53.     ENDIFF
  54. ENDIFF
  55.                                             REM Check free env and alias space
  56. IFF "%_DOS" == "DOS" .AND. 0%_ENV% LE 300 THEN
  57.    ECHO. Sorry, ViewFile needs at least 300 byte free environment.
  58.    ECHO. (currently you have %_ENV free bytes in the environment)
  59.    QUIT 1
  60. ENDIFF
  61.                                             REM get path for the temp files
  62. *SET TMPFIL=%@UNIQUE[%TMP%]
  63. IF NOT EXIST %TMP%CON *SET TMP=%TMP%\
  64. IF NOT EXIST %TMP%CON *SET TMP=C:\
  65.  
  66. :FileLoop
  67. IF "%file%" =="" *SET file=*.*
  68.  
  69. IFF "%1%" != "" THEN
  70.     *SET file=%1
  71.     SHIFT
  72. ENDIFF
  73.  
  74. :DirLoop
  75. IFF IsDir %file% THEN
  76.     IFF "%file%" =="." THEN
  77.         CLS
  78.         SCRPUT %@eval[%_rows-2] 0 %_fg on %_bg Current Directory is %_cwd
  79.         SCREEN %@eval[%_rows-1] 0
  80.         INPUT Enter the new directory: %%f
  81.         IFF "%f%" != "" THEN
  82.             IFF isDir %f% THEN
  83.                 SET file=%f%
  84.             ELSE
  85.                 CLS
  86.                 SCRPUT %@eval[%_rows-2] 0 %_fg on %_bg [FileView] Error: %f% is NOT a directory
  87.                 SCRPUT %@eval[%_rows-1] 0 %_fg on %_bg Press any key to continue ...
  88.                 INKEY %%f
  89.                 IFF "%f%" =="@45" THEN
  90.                     CLS
  91.                     QUIT 2
  92.                 ENDIFF
  93.             ENDIFF
  94.         ENDIFF
  95.     ENDIFF
  96.     cdd %file%
  97.     *SET file=%_cwds%*.*
  98.     UNSET /Q f
  99. ENDIFF
  100.  
  101. :ShowLoop
  102. IFF %@index[%file%,*] != -1 .OR. %@index[%file%,?] != -1 THEN
  103.    *SET mask=%file%
  104.    UNSET /Q file
  105.    select /A-H-S /OGEN SET file=[%mask%]
  106.    *SET file=%@word[0,%file%]
  107.    IFF "%file%" =="" THEN
  108.        IFF "%1%" != "" THEN
  109.            GOTO FileLoop
  110.        ELSE
  111.            QUIT 0
  112.        ENDIFF
  113.    ENDIFF
  114.    IF IsDir %file% GOTO DirLoop
  115. ENDIFF
  116.  
  117. CLS
  118. *SET t=%@upper[%@ext[%file%]]
  119.  
  120. *SET f=%@unique[%tmp%]
  121.  
  122. IFF "%t%" == "" THEN
  123.     list %file%
  124.  
  125. ELSEIFF "%t%" == "ARJ" THEN
  126.     
  127.     %arcPath%arj l %file% >&!%f%
  128. :ShowArj
  129.     *SET n=%@WORD[0,%@SELECT[%f%,2,0,%@eval[%_rows-1],%@eval[%_COLUMNS-1], Select a file to view or ESC to abort ]]
  130.     IF "%n%" =="" GOTO EndView
  131.     %arcPath%arj p %file %n% |& list /s
  132.     GOTO /I ShowArj
  133.         
  134. ELSEIFF "%t%" == "LZH" .OR. "%t%" == "LHA" .OR. "%t%" == "ICE"  THEN
  135.     %arcPath%lha l %file% >&!%f%
  136. :ShowLZH    
  137.     *SET n=%@WORD[0,%@SELECT[%f%,2,0,%@eval[%_rows-1],%@eval[%_COLUMNS-1], Select a file to view or ESC to abort ]]
  138.     IF "%n%" =="" GOTO EndView
  139.     %arcPath%lha p %file %n% |& list /s
  140.     GOTO /I ShowLZH
  141.     
  142. ELSEIFF "%t%" == "SQZ" THEN
  143.     %arcPath%sqz l %file% >&!%f%
  144. :ShowSQZ    
  145.     *SET n=%@WORD[0,%@SELECT[%f%,2,0,%@eval[%_rows-1],%@eval[%_COLUMNS-1], Select a file to view or ESC to abort ]]
  146.     IF "%n%" =="" GOTO EndView
  147.     %arcPath%sqz p %file %n% |& list /s
  148.     GOTO /I ShowSQZ
  149.  
  150. ELSEIFF "%t%" == "ZIP" THEN
  151.     %arcPath%pkunzip -v %file% >&!%f%
  152. :ShowZIP
  153.     *SET n=%@WORD[8,%@SELECT[%f%,2,0,%@eval[%_rows-1],%@eval[%_COLUMNS-1], Select a file to view or ESC to abort ]]
  154.     IF "%n%" =="" GOTO EndView
  155.     %arcPath%pkunzip -c %file% %n% |& list /s
  156.     GOTO /I ShowZIP
  157.  
  158. ELSEIFF "%t%" == "ZOO" THEN
  159.     %arcPath%zoo l %file% >&!%f%
  160. :ShowZOO
  161.     *SET n=%@WORD[7,%@SELECT[%f%,2,0,%@eval[%_rows-1],%@eval[%_COLUMNS-1], Select a file to view or ESC to abort ]]
  162.     IF "%n%" =="" GOTO EndView
  163.     %arcPath%zoo -p %file %n% |& list /s
  164.     GOTO /I ShowZOO
  165.  
  166. ELSEIFF "%t%" == "PAK" THEN
  167.     %arcPath%pak l %file% >&!%f%
  168. :ShowPAK
  169.     UNSET /Q n
  170.     *SET n=%@SELECT[%f%,2,0,%@eval[%_rows-1],%@eval[%_COLUMNS-1], Select a file to view or ESC to abort ]
  171.     IF "%n%" =="" GOTO EndView
  172.     *SET n=%@WORD[0,%n%].%@WORD[1,%n%]
  173.     %arcPath%pak p %file %n% |& list /s
  174.     GOTO /I ShowPAK
  175.  
  176. ELSEIFF "%t%" == "ARC" THEN
  177.     %arcPath%pkunpak -v %file% >&!%f%
  178. :ShowARC
  179.     *SET n=%@WORD[0,%@SELECT[%f%,2,0,%@eval[%_rows-1],%@eval[%_COLUMNS-1], Select a file to view or ESC to abort ]]
  180.     IF "%n%" =="" GOTO EndView
  181.     %arcPath%pkunpak -c %file %n% |& list /s
  182.     GOTO /I ShowARC
  183.  
  184. ELSE
  185.     list %file%
  186. ENDIFF
  187.  
  188. :EndView
  189. IF EXIST %f% DEL /Q %f%
  190. *SET file=%_cwds%*.*
  191. GOTO ShowLoop
  192.  
  193.