home *** CD-ROM | disk | FTP | other *** search
/ TopWare Tools / TOOLS.iso / tools / top1628 / desc.btm < prev    next >
Encoding:
Text File  |  1993-12-13  |  31.8 KB  |  1,067 lines

  1. @ECHO OFF
  2. REM ----------------------------------------
  3. REM
  4. REM DESC.BTM Copyright 1993 by Bernd Schemmer   Version 2.11
  5. REM
  6. REM Last Update: 13.12.93 /bs
  7. REM
  8. REM Description:
  9. REM     Create/Edit descriptions for 4DOS/4OS2
  10. REM     DESC can also view text files and files in archivs.
  11. REM     DESC supports the archivs .LZH, .LHA, .ICE, .ARJ, .ARC
  12. REM     .PAK, .ZOO, .SQZ and .ZIP. So you may use DESC as a
  13. REM     replacement for the internal list command of 4DOS.
  14. REM
  15. REM Requirements:
  16. REM     MS-DOS 3+ and 4DOS 4+ *OR* OS/2 1.3+ and 4OS2
  17. REM     Additional needed programs to view the contents of an archiv:
  18. REM     ARJ.EXE, LHA.EXE, PAK.EXE, ZOO.EXE, SQZ.EXE and PKUNZIP.EXE
  19. REM
  20. REM Usage:
  21. REM    DESC {file|directory} {...}
  22. REM or (only to show one or more files or archivs)
  23. REM    DESC **view** {file|directory} {...}
  24. REM You should use an alias like
  25. REM    ALIAS list desc **view** %&
  26. REM for the second usage.
  27. REM
  28. REM Used internal 4DOS/4OS2-Variables:
  29. REM      %_dos%, %_dosver%, %_fg, %_bg, %_rows, %_columns, %_cwd, %_4ver,
  30. REM      %_disk, %_date, %_time, %_? %_lastdisk
  31. REM
  32. REM Additional used internal 4DOS-Vars if started under 4DOS:
  33. REM      %_env%, %_alias%
  34. REM
  35. REM Input-Variables (if set):
  36. REM        %ipath% - path for the file data files and init file of DESC
  37. REM                  (default: path where DESC.BTM is located)
  38. REM          %tmp% - path for temporay files
  39. REM                  (default: C:\)
  40. REM       %DOSarc% - path with the pack programs for DOS-Version
  41. REM       %OS2arc% - path with the pack programs for OS/2-Version
  42. REM
  43. REM Used internal 4DOS/4OS2 commands (DESC ingores ALIASse for this commands):
  44. REM     SET, UNSET, LIST
  45. REM
  46. REM Additional files created in the directory "iPath" from DESC.BTM:
  47. REM     DESCINIT.BTM - general init file for DESC.BTM
  48. REM     DESCDRVM     - Drive Map
  49. REM     DESCTREE.x   - Directory of drive x where x is the drive char
  50. REM                    ( 'A' <= x <= 'Z')
  51. REM
  52. REM Warranty disclaimer:
  53. REM     Bernd Schemmer makes no warranty of any kind, expressed or implied,
  54. REM     including without limitation any warranties of merchantability and/or
  55. REM     fitness for a particular purpose.
  56. REM
  57. REM DESC.BTM is freeware. So use and share it freely!
  58. REM Send any comments and bug reports to
  59. REM
  60. REM     Bernd Schemmer
  61. REM     Bäckerweg 48
  62. REM     60316 Frankfurt/M.
  63. REM     Germany
  64. REM     Phone: +49 (069) 4 97 04 84 (only in the evening of MEZ)
  65. REM
  66. REM Note: You may delete the comments at the beginning of this file to speed
  67. REM       up the execution. You may NOT distribute this file without the
  68. REM       comments, generally speaking: YOU ARE ONLY ALLOWED TO DISTRIBUTE
  69. REM       THIS FILE IN THE ORIGINAL FORM!
  70. REM
  71. REM Hints:
  72. REM       Change the variables "DOSArc" and "OS2Arc" if your packers are in
  73. REM       another directory.
  74. REM       If the file DESCINIT.BTM exists, you must also change this variables
  75. REM       in this file - or delete DESCINIT.BTM
  76. REM
  77. REM       Set the variable "iPath" if you want DESC to save it's initfile in
  78. REM       a special directory.
  79. REM       The Search-Algorithm for "iPath" is:
  80. REM
  81. REM       IFF EXIST DESCINIT.BTM
  82. REM           REM use local DESCINIT.BTM in the current directory
  83. REM           SET ipath=%_cwds
  84. REM       ELSEIFF "%ipath%" != "" .AND. isDir %ipath% THEN
  85. REM           REM use predefined "ipath"
  86. REM       ELSE
  87. REM           SET ipath=directory with DESC.BTM
  88. REM       ENDIFF
  89. REM
  90. REM       To work propper, KSTACK should be loaded (DOS-Version).
  91. REM
  92. REM       If you're getting a error message after moving DESC.BTM from one
  93. REM       drive/directory to another -- delete the file DESCINIT.BTM.
  94. REM
  95. REM       You may add or delete magics for the filename mask (stored
  96. REM       in the environment variable MAGICS) in the OS-Shell while DESC
  97. REM       is running - DESC saves the contents of the variable MAGICS and
  98. REM       the contents of all magics automaticly at program end.
  99. REM
  100. REM       Example: To add the magic TEXT issue the following commands in
  101. REM                the OS-Shell from DESC:
  102. REM                    SET TEXT=*.TXT;*.DOC;*.LST
  103. REM                    SET MAGICS=%MAGICS% TEXT
  104. REM                That's all! If you'll leave DESC and call it again
  105. REM                the new magic TEXT is always there.
  106. REM
  107. REM       DESC make the following assumptions about the format of
  108. REM       the file listings generated by the packers (see also
  109. REM       the function 'ViewFile' in this source):
  110. REM
  111. REM       Archiv-Typ      Word, containing the filename (1..n)
  112. REM       ----------------------------------------------------
  113. REM       ARJ             1 Word
  114. REM       LHA, ICE, LZH   1 Word
  115. REM       SQZ             1 Word
  116. REM       ZIP             9 Word
  117. REM       ZOO             7 Word
  118. REM       PAK, ARC        1 Word
  119. REM
  120. REM History: V1.00 - first release
  121. REM          V1.10 - DESC is now compound char independent
  122. REM                  DESC now returns the following errorlevels:
  123. REM                   0 = okay
  124. REM                   1 = error
  125. REM                   2 = user pressed ALT-X
  126. REM                  DESC can now edit the descriptions of hidden
  127. REM                  and system files in single edit mode (not in
  128. REM                  'edit some descriptions')
  129. REM          V1.11 - minor changes
  130. REM          V2.00 - changes for 4OS2 (only FAT partitions, because
  131. REM                  4OS2 won't show descriptions for HPFS partitions)
  132. REM                  Caution: DESC therefore shows HPFS partitions in
  133. REM                           FAT-Format
  134. REM                  Note that you must use the char % as parameter char
  135. REM                  to use DESC under 4OS2. Note also that this file DON'T
  136. REM                  uses the compound char of 4DOS/4OS2.
  137. REM                  add support for .PAK-archivs
  138. REM          V2.10 - add support for SFX archivs
  139. REM                  add support for .ARC-archivs
  140. REM                  add parameter **view**
  141. REM                  add support for jokers in the parameters
  142. REM                  DESC now supports local init files
  143. REM                  DESC now supports separat pathes for the pack programs
  144. REM                  in the DOS-Version and in the OS/2-Version
  145. REM                  But note that all pack programs MUST generate the same
  146. REM                  archiv listing in the DOS- and the OS/2-Version!
  147. REM          V2.11 - minor bug fixes
  148. REM
  149. REM --------
  150.  
  151. SETLOCAL
  152. ECHO.
  153.  
  154. *SET xParm=**view**
  155.                                             REM desc init file
  156. *SET initFile=DESCINIT.BTM
  157.  
  158. IFF "%1%" == "%xParm%" THEN
  159.     UNSET /q descActiv
  160.     IFF "%2%" == "" THEN
  161.        ECHO. [DESC] Missing parameters!
  162.        QUIT 1
  163.     ENDIFF
  164. ENDIFF
  165.  
  166.                                             REM don't fake me!
  167. *UNSET /Q _dos _dosVer _4ver _env _alias
  168.                                             REM Check OS and 4DOS version
  169. IFF "%_dos%" == "OS2" THEN
  170.                                             REM Running under 4OS2
  171.     *SET _dosVer=OS/2
  172. ELSEIFF "%_dos%" == "DOS" THEN
  173.                                             REM Running under 4DOS
  174.     IFF %@name[%_dosver%]0 GT 100 THEN
  175.        *SET _dosVer=OS/2 %@substr[%_dosver,0,1].%@substr[%_dosver%,3,2] DOS-BOX
  176.     ELSEIFF %@name[%_4VER%]0 LT 40 .OR. %@name[%_DOSVER]0 LT 30 THEN
  177.        ECHO. Sorry, DESC needs DOS 3+ and 4DOS 4+!
  178.        ECHO. (currently you have DOS %_DOSVER and 4DOS %_4VER)
  179.        QUIT 1
  180.     ENDIFF
  181.  
  182.                                             REM Check free env and alias space
  183.     IFF "%_ENV%" != "" .AND. 0%_ENV% LE 500 THEN
  184.        ECHO. Sorry, DESC needs at least 500 byte free environment.
  185.        ECHO. (currently you have %_ENV free bytes in the environment)
  186.        QUIT 1
  187.     ENDIFF
  188.  
  189.     IFF "%_ALIAS%" != "" .AND.  0%_ALIAS% LE 075 THEN
  190.        ECHO. Sorry, DESC needs at least 100 byte free alias space!
  191.        ECHO. (currently you have %_ALIAS free space for new aliasse)
  192.        QUIT 1
  193.     ENDIFF
  194.  
  195. ELSE
  196.                                             REM I don't like Windows NT
  197.    ECHO. Sorry, DESC do not know the operating system %_dos% %_dosVer%!
  198.    QUIT 1
  199. ENDIFF
  200.  
  201. IFF "%DescActiv%" != "" THEN
  202.    ECHO. DESC is already activ. Use 'EXIT' to return to DESC.
  203.    QUIT 1
  204. ENDIFF
  205.  
  206.                                             REM please don't change this!
  207. alias cc scrput 0 15 whi on blue DESC %DESCVersion% Copyright (c) by Bernd Schemmer 1993
  208.  
  209.                                             REM get the path for data files
  210. IFF exist %initFile% THEN
  211.     *SET iPath=%_cwds%
  212. ELSEIFF "%iPath%" != "" THEN
  213.     IFF IsDir %IPath% THEN
  214.         IF NOT EXIST %iPath%CON *SET iPath=%iPath%\
  215.     ELSE
  216.         ECHO. [DESC] Error: %iPath% (variable "iPath" is NOT a directory!
  217.         QUIT 1
  218.     ENDIFF
  219. ELSE
  220.   *SET iPath=%@path[%@search[%0%]]
  221.   IF "%iPath%" == "" *SET iPath=%@path[%0%]
  222.   IF "%iPath%" == "" *SET iPath=%@path[%@search[%@name[%0%].%@ext[%0%]]]
  223.   IF "%iPath%" == "" *SET iPath=%_cwds
  224. ENDIFF
  225.  
  226.                                             REM get path for the temp files
  227. IF NOT EXIST %TMP%CON *SET TMP=%TMP%\
  228. IF NOT EXIST %TMP%CON *SET TMP=C:\
  229. *SET TMPFIL=%@UNIQUE[%TMP%]
  230.  
  231.                                             REM get foreground and background color
  232. CLS
  233. *SET clrF=%_fg
  234. *SET clrB=%_bg
  235.  
  236. *UNSET /Q KStack
  237. IFF "%_DOS" == "DOS" THEN
  238.                                             REM check if KSTACK is loaded
  239.     keystack #00 >&NUL
  240.                                             REM set KStack to Y if so
  241.     IF %_? == 0 *SET KStack=Y
  242. ENDIFF
  243.                                             REM SET default var values
  244. *SET mline1=%@eval[%_rows-6]
  245. *SET mline2=%@eval[%_rows-5]
  246. *SET mline3=%@eval[%_rows-1]
  247.                                             REM DESC Version
  248. *SET DESCVersion=V2.11
  249.                                             REM Describe or change dirs
  250. *SET DescDirs=OFF
  251.                                             REM Describe or view files
  252. *SET ViewFiles=OFF
  253.                                             REM filemask
  254. *SET mask=*.*
  255.  
  256.                                             REM dirs with the pack program(s)
  257. IF "%DOSArc%" == "" *SET DOSarc=D:\UTILS\ARCHIV
  258. IF "%OS2Arc%" == "" *SET OS2arc=C:\OS_2\TOOLS\ARCHIV
  259.  
  260.                                             REM magic for the filemask
  261. *SET archivs=*.ARJ;*.ZIP;*.LZH;*.ZOO;*.SQZ;*.LHA;*.PAK;*.ICE;*.ARC
  262.  
  263.                                             REM magic for the filemask
  264. IFF "%_DOS" == "DOS" THEN
  265.     *SET exes=*.EXE;*.COM;*.BAT;*.BTM
  266. ELSE
  267.     *SET exes=*.EXE;*.CMD;*.BTM
  268. ENDIFF
  269.  
  270.                                             REM magic for the filemask
  271. *SET all=*.*
  272.                                             REM variable with the magics
  273. *SET magics=EXES ARCHIVS ALL
  274.                                             REM filename for the drivemap
  275. *SET DriveMap=%iPath%DESCDRVM
  276.  
  277.                                             REM load configuration if possible
  278. IFF "%initFile%" != "" THEN
  279.     IFF EXIST %ipath%%initFile% THEN
  280.         *SET msg=Executing configuration file "%ipath%%initfile%" ....
  281.         GOSUB ShowMsg
  282.         call %iPath%%initFile%
  283.     ENDIFF
  284. ENDIFF
  285. GOSUB ClearMsg
  286.  
  287. IFF "%_DOS%" == "DOS" THEN
  288.     *SET arcPath=%DOSArc%
  289. ELSE
  290.     *SET arcPath=%OS2Arc%
  291. ENDIFF
  292.  
  293.                                             REM errorlevel of internal cmds
  294. *SET iErr=0
  295.                                             REM semaphor for reReading dirs
  296. *SET ReadDir=Y
  297.  
  298. IF "%1%" == "" GOTO LOOP
  299.                                             REM proceed parameter
  300.     IFF "%1%" != "%xParm%" THEN
  301.                                             REM let describe do the work
  302.         *describe %1&
  303.         QUIT %_?
  304.     ENDIFF
  305.  
  306.     pushd
  307.  
  308.     FOR %%t IN (%2&) DO GOSUB ProceedParm
  309.     QUIT %_?
  310.  
  311. REM ------------------------------------
  312.  
  313. :LOOP
  314.  
  315.                                             REM interactive mode
  316. IFF "%ReadDir%" == "Y" THEN
  317.     IF EXIST %TMPFIL% DEL /Q %TMPFIL%
  318.  
  319.     *SET msg=Checking directory %_cwd. Please wait ...
  320.     GOSUB ShowMsg
  321.  
  322.                                             REM create file list of current Dir
  323.     IFF "%_DOS" != "DOS" THEN
  324.         ECHO.■Current workdirectory is %_CWD>>!%TMPFIL%
  325.     ELSE
  326.         IFF %_CWD == %@truename[%_CWD] THEN
  327.             ECHO.■Current workdirectory is %_CWD>>!%TMPFIL%
  328.         ELSE
  329.             ECHO.■Current workdirectory is %_CWD (= %@truename[%_CWD] )>>!%TMPFIL%
  330.         ENDIFF
  331.     ENDIFF
  332.  
  333.     ECHO.■Change file mask (current mask is %mask%)>>!%TMPFIL%
  334.     ECHO.■Toggle Describe Dirs-Switch (ON: Describe Dirs - OFF: Change Dir)>>%TMPFIL%    
  335.     ECHO.■Toggle View Files-Switch (ON: view files - OFF: edit file desc.)>>%TMPFIL%
  336.  
  337. IFF "%_DOS" == "DOS" THEN
  338.     ECHO.■4DOS V%_4VER Shell (%_DOS %_DOSVER)>>%TMPFIL%
  339. ELSE
  340.     ECHO.■4OS2 V%_4VER Shell (%_DOS %_DOSVER)>>%TMPFIL%
  341. ENDIFF
  342.  
  343.     ECHO.■Delete file(s)>>%TMPFIL%
  344.     ECHO.■Delete a Directory-Tree>>%TMPFIL%
  345.     ECHO.■Clear all descriptions>>%TMPFIL%
  346.     ECHO.■Erase some descriptions>>%TMPFIL%
  347.     ECHO.■Edit some descriptions>>%TMPFIL%
  348.     ECHO.■Directory-Tree>>%TMPFIL%
  349.     ECHO.■Available Drives>>%TMPFIL%
  350.     ECHO.■Root-Directory>>%TMPFIL%
  351.     ECHO.------------------------------------------------------------------------------->>%TMPFIL%
  352.  
  353. IFF "%_DOS" == "DOS" THEN
  354.                                             REM MS-DOS or PC-DOS
  355.     DIR /KM /AD  *.* /oGEN >>!%TMPFIL% >&>NUL
  356.     ECHO.------------------------------------------------------------------------------->>%TMPFIL%
  357.     DIR /KM /A-D /oGEN  %mask%  >>!%TMPFIL% >&>NUL
  358. ELSE
  359.                                             REM OS/2
  360.     DIR /Z /KM /AD /oGEN *.*  >>!%TMPFIL% >&>NUL
  361.     ECHO.------------------------------------------------------------------------------->>%TMPFIL%
  362.     DIR /Z /KM /A-D /oGEN %mask%  >>!%TMPFIL% >&>NUL
  363. ENDIFF
  364.  
  365. ENDIFF
  366.  
  367. CLS
  368. GOSUB ClearMsg
  369. *SET ReadDir=Y
  370. cc
  371.  
  372. *UNSET /Q n1
  373. IF %@len[%_cwds] GT 3 *SET n1=2
  374. *SET n1=%@eval[%@lines[%tmpfil%]-14- %n1]
  375.  
  376. *SET cmd1=%@WORD[0,"%@SELECT[%TMPFIL%,2,0,%@eval[%_rows-1],%@eval[%_columns-1], Edit descriptions for %n1% files/dirs / Describe Dirs = %DescDirs% ViewFiles = %ViewFiles% ]"]
  377. IF %cmd1% == "" GOTO End
  378.  
  379. REM *** only for HPFS formated output
  380. REM *SET FILE=%@WORD[-0,%@substr[%cmd1%,1,%@eval[%@len[%cmd1%]-2]]]
  381.  
  382. *SET  cmd1=%@SUBSTR[%cmd1%,1,12]
  383. *SET  file=%cmd1%
  384.  
  385.                                             REM proceed user choice (=%cmd1%)
  386. IFF %@INDEX[%cmd1%,■Delete f] != -1 THEN
  387.     IFF NOT EXIST %mask% THEN
  388.         *SET msg=There are no files in the directory %_cwd
  389.         *SET msg1=for the current file mask. The current file mask is "%mask%".
  390.         GOSUB ShowAsk
  391.         *SET ReadDir=N
  392.     ELSE
  393.         GOSUB chkdrive
  394.         *SET ReadDir=N
  395.         IFF %Ierr% == 0 THEN
  396.             *UNSET /Q Files_To_Delete
  397.             select /A /OGEN *SET Files_To_Delete=[%mask%]
  398.             IFF "%Files_To_Delete%" != "" THEN
  399.                 del /Q /y %Files_To_Delete%
  400.                 *SET readDir=Y
  401.             ENDIFF
  402.             *UNSET /Q Files_To_Delete
  403.         ENDIFF
  404.     ENDIFF
  405.     cls
  406.  
  407. ELSEIFF %@index[%cmd1%,■Directory] != -1 THEN
  408.     GOSUB getDirTree
  409.     *SET ReadDir=N
  410.     IFF "%dirl%" != "" THEN
  411.         cdd %dirl%
  412.         *SET ReadDir=Y
  413.     ENDIFF
  414.  
  415. ELSEIFF %@INDEX[%cmd1%,■Delete] != -1 THEN
  416.     *UNSET /Q Directory_to_delete
  417.     select /AD *SET Directory_to_Delete=[*.*]
  418.     *SET ReadDir=N
  419.     IFF "%Directory_To_Delete%" != "" .AND. "%Directory_To_Delete%" != "." .AND. "%Directory_To_Delete%" != ".." THEN
  420.         *SET msg=Delete the directory "%Directory_To_Delete%" and ALL sub directorys.
  421.         GOSUB ShowMsg
  422.         inkey /K"ynYN" Really delete this directory tree (y/n)? %%c
  423.         IFF "%@upper[%c%]" == "Y" THEN
  424.             *SET msg=Deleting the directory tree "%Directory_To_Delete%" ...
  425.             GOSUB ShowMSG
  426.             del /s/y/x %Directory_To_Delete% >&NUL
  427.             *SET ReadDir=Y
  428.         ENDIFF
  429.         *UNSET /Q Directory_To_Delete
  430.         GOSUB ClearMsg
  431.     ENDIFF
  432.  
  433. ELSEIFF %@INDEX[%cmd1%,■Erase] != -1 THEN
  434.     IFF NOT EXIST %mask% THEN
  435.         *SET msg=There are no files in the directory "%_cwd%"!
  436.         *SET msg1=(Current file mask is "%mask%")
  437.         GOSUB ShowAsk
  438.         *SET ReadDir=N
  439.     ELSE
  440.         GOSUB chkdrive
  441.         *SET ReadDir=N
  442.         IFF %Ierr% == 0 THEN
  443.            *UNSET /Q Files_To_Delete_Description
  444.            select /OGEN *SET Files_To_Delete_Description=[%mask%]
  445.            IFF "%Files_To_Delete_Description%" != "" THEN
  446.                FOR %%f IN (%Files_To_Delete_Description%) DO describe %f ""
  447.                *SET readDir=Y
  448.            ENDIFF
  449.            *UNSET /Q Files_To_Delete_Description f
  450.         ENDIFF
  451.     ENDIFF
  452.     cls
  453.  
  454. ELSEIFF %@INDEX[%cmd1%,■Edit] != -1 THEN
  455.     IFF NOT EXIST %mask% THEN
  456.         *SET msg=There are no files in the directory "%_cwd%"!
  457.         *SET msg1=(Current file mask is "%mask%")
  458.         GOSUB ShowAsk
  459.         *SET ReadDir=N
  460.     ELSE
  461.         GOSUB chkdrive
  462.         *SET ReadDir=N
  463.         IFF %Ierr% == 0 THEN
  464.            *UNSET /Q Files_To_Describe
  465.            select /OGEN *SET Files_To_Describe=[%mask%]
  466.            IFF "%Files_To_Describe%" != "" THEN
  467.                describe %Files_To_Describe% ""
  468.                *SET readDir=Y
  469.            ENDIFF
  470.            *UNSET /Q Files_To_Describe
  471.         ENDIFF
  472.     ENDIFF
  473.     cls
  474.  
  475. ELSEIFF %@INDEX[%cmd1%,■Toggle D] != -1 THEN
  476.     IFF "%DescDirs%" == "ON" THEN
  477.         *SET DescDirs=OFF
  478.     ELSE
  479.         *SET DescDirs=ON
  480.     ENDIFF
  481.     *SET ReadDir=N
  482.  
  483. ELSEIFF %@INDEX[%cmd1%,■Toggle V] != -1 THEN
  484.     IFF "%ViewFiles%" == "ON" THEN
  485.         *SET ViewFiles=OFF
  486.     ELSE
  487.         *SET ViewFiles=ON
  488.     ENDIFF
  489.     *SET ReadDir=N
  490.  
  491. ELSEIFF %@INDEX[%cmd1%,■4DOS] != -1 .OR. %@INDEX[%cmd1%,■4OS2] != -1 THEN
  492.     SCREEN 1 0 
  493.     *SET DESCactiv=Y
  494.  
  495. :DosShellLoop
  496.     ECHO.
  497.     ECHO.--- Type EXIT to return to DESC ... ---
  498.     INPUT [%_cwds%] Enter command(s) to execute: %%l
  499.     IFF "%@upper[%l%]" != "EXIT" THEN
  500.         IF "%l" != "" call %l
  501.         GOTO DosShellLoop
  502.     ENDIFF
  503.     *UNSET /Q DescActiv
  504.     GOTO Loop
  505.  
  506. ELSEIFF %@INDEX[%cmd1%,■Clear] != -1 THEN
  507.     *SET ReadDir=N
  508.     IFF EXIST descript.ion THEN
  509.         GOSUB chkdrive
  510.         IFF %Ierr == 0 THEN
  511.             del /Z /Q descript.ion
  512.             *SET readDir=Y
  513.         ENDIFF
  514.     ENDIFF
  515.  
  516. ELSEIFF %@INDEX[%cmd1%,-----] != -1 THEN
  517.     *SET ReadDir=N
  518.  
  519. ELSEIFF %@INDEX[%cmd1%,■Current] != -1 THEN
  520.     *SET msg=Current work directory is "%_cwd%".
  521.     GOSUB ShowMsg
  522.     INPUT Enter new work directory (RETURN = no change): %%t
  523.     *SET ReadDir=N
  524.     IFF "%t%" != "" THEN
  525.         IF NOT EXIST %t%CON .AND. %t% != - *SET t=%t%\
  526.         IFF NOT EXIST %t%CON .AND. %t% != - THEN
  527.             *SET msg=Error: "%t%" is NOT a directory!
  528.             GOSUB ShowAsk 
  529.         ELSE    
  530.             cdd %t%
  531.             *SET ReadDir=Y
  532.         ENDIFF             
  533.     ENDIFF
  534.     GOSUB ClearMsg
  535.  
  536. ELSEIFF %@INDEX[%cmd1%,■Change] != -1 THEN
  537.     *SET msg=Current filemask is "%mask%".
  538.     *SET msg1=Magics are "%magics%"
  539.     GOSUB ShowMsg
  540.     *SET ReadDir=N
  541.  
  542.     INPUT Enter new filemask (RETURN = no change): %%t
  543.     IFF "%t%" != "" THEN
  544.         *SET mask=%t%
  545.         *SET ReadDir=Y
  546.     ENDIFF
  547.     GOSUB ClearMsg
  548.  
  549. ELSEIFF %@INDEX[%cmd1%,■Root] != -1 THEN
  550.     CD \
  551.  
  552. ELSEIFF %@INDEX[%cmd1%,■Available] != -1 THEN
  553.     GOSUB GetDrives
  554.  
  555. ELSEIFF "%@SUBSTR[%file%,0,2]" == ".." THEN
  556.     IFF "%DescDirs%" == "OFF" THEN
  557.         CD ..
  558.     ELSE
  559.         *SET ReadDir=N
  560.     ENDIFF
  561.             
  562. ELSEIFF IsDir %file% .AND. "%DescDirs%" == "OFF" THEN
  563.     CD %file%
  564.  
  565. ELSE
  566.     IFF %ViewFiles% == OFF THEN
  567.         GOSUB chkdrive
  568.     ELSE
  569.         *SET IErr=0
  570.     ENDIFF
  571.     *SET ReadDir=N
  572.  
  573.     IFF %Ierr% == 0 THEN
  574.         *UNSET /Q attr
  575.  
  576.         IF %@attrib[%file%,H] == 1 *SET attr=%attr%H
  577.         IF %@attrib[%file%,S] == 1 *SET attr=%attr%S
  578.         IF "%attr%" != "" attrib /D -hs %file% >&NUL
  579.  
  580.         IFF %ViewFiles% == OFF .OR. IsDir %file% THEN
  581.             GOSUB DES
  582.             *SET ReadDir=Y
  583.         ELSE
  584.             GOSUB ViewFile
  585.         ENDIFF
  586.  
  587.         IF "%attr%" != "" attrib /D +%attr% %file% >&NUL
  588.         *UNSET /Q attr
  589.     ENDIFF
  590. ENDIFF
  591.  
  592. GOTO LOOP
  593.  
  594. :End
  595. IF EXIST %TMPFIL%  DEL /Q %TMPFIL%
  596.  
  597. IFF "%initFile%" != "" THEN
  598.    *SET msg=Saving configuration in "%iPath%%initFile%" ....
  599.    GOSUB ShowMsg
  600.    GOSUB SaveDescVars
  601. ENDIFF
  602. cls
  603. ECHO. Have a nice day ...
  604. QUIT 0
  605.  
  606. REM ----------------------------------------
  607.  
  608.  
  609. REM ----- getDirTree
  610. REM       choose a directory out of a directory tree
  611. REM       input:  %iPath% = directory for the treemap file
  612. REM       output: %dirl% = choosen dir (or empty)
  613. REM
  614. :getDirTree
  615.  
  616. *UNSET /Q dirL
  617.  
  618. *SET TreeDrive=%@lower[%_Disk%]
  619. *SET TreeMap=%iPath%DESCTree.%TreeDrive%
  620. *SET ReadTree=old
  621. *SET vStr=■Directory-Tree for %TreeDrive%: created by DirTree %DescVersion%
  622.  
  623. IF %@FileSize[%TreeMap%,B] LE 0 GOTO getTree
  624. IF %@index[%@line[%TreeMap%,0],%vStr%] == 0 GOTO ShowDirTree
  625.  
  626. :GetTree
  627.  
  628. IFF %@ready[%TreeDrive%:] != 1 THEN
  629.     *SET msg=Error: Drive "%TreeDrive%:" is not ready!
  630.     GOSUB ShowMsg
  631.     GOTO GetTreeEnd
  632. ENDIFF
  633.  
  634. *SET msg=Checking directory structure of "%TreeDrive%:". Please wait ...
  635. GOSUB ShowMsg
  636.  
  637. *SET ReadTree=new
  638.  
  639. ECHO.%vstr% at %_DATE %_TIME>!%TreeMap%
  640. ECHO.■ReRead Directory Structure>>!%TreeMap%
  641. ECHO.------------------------------------------------------------------------------->>%TreeMap%
  642.  
  643. *SET f=%@unique[%tmp%]
  644. dir %TreeDrive%:\ /1/AD/B/S/F/Ou >>!%f%
  645. sort <%f% >>%TreeMap%
  646. del %f%>NUL
  647.  
  648. :ShowDirTree
  649. *UNSET /Q vstr
  650. CLS
  651. *SET dirN=%@eval[ %@lines[%TreeMap%] - 2]
  652. *SET dirL=%@SELECT[%TreeMap%,2,0,%@eval[%_rows-1],%@eval[%_columns-1], (%readTree%) Choose one of the %dirN% Directorys ]
  653.  
  654. IF "%dirL%" == ""  GOTO GetTreeEnd
  655. IF %@index["%dirL%",-----] == 1 GOTO ShowDirTree
  656.  
  657. IFF %@INDEX[%dirL%,■ReRead] != -1 THEN
  658.     DEL /Q %TreeMap% >&NUL
  659.     GOTO GetDirTree
  660. ENDIFF
  661. IF %@INDEX[%dirL%,■Directory-Tree] != -1 GOTO ShowDirTree
  662.  
  663. :GetTreeEnd
  664. *UNSET /Q f vstr readTree dirMap TreeDrive
  665. RETURN
  666.  
  667. REM ----- viewFile
  668. REM       Show the contents of the file or archiv
  669. REM       input: %file% = file to view
  670. REM
  671. :ViewFile
  672. CLS
  673. *SET t=%@upper[%@ext[%file%]]
  674.  
  675. *SET f=%@unique[%tmp%]
  676. cc
  677.  
  678. *SET msg=Reading file "%file%" ...
  679. GOSUB ShowMsg
  680.  
  681. IFF "%t%" == "EXE" .OR. "%t%" == "COM" THEN
  682.     *SET msg=Known Archiv Types: ARJ, LHA, LZH, ICE, ZIP, ZOO, PAK, ARC, SQZ
  683.     GOSUB ShowMsg
  684.     *UNSET /Q t
  685.     INPUT Enter the type of the Archiv "%file%": %%t
  686.     GOSUB ClearMSG
  687. ENDIFF
  688.  
  689. IFF "%t%" == "" THEN
  690.     *list %file%
  691.  
  692. ELSEIFF "%t%" == "ARJ" THEN
  693.     
  694.     %arcPath%\ARJ.EXE l %file% >&!%f%
  695. :ShowArj
  696.     *SET msg=Viewing archiv "%file%" ...
  697.     GOSUB ShowMsg
  698.     *SET na=%@WORD[0,%@SELECT[%f%,2,0,%@eval[%_rows-1],%@eval[%_columns-1], Select a file to view or ESC to abort ]]
  699.     IF "%na%" == "" GOTO EndView
  700.     *SET msg=Extracting file "%na%" ...
  701.     GOSUB ShowMsg
  702.  
  703.     %arcPath%\ARJ.EXE p %file% %na% |& *list /s
  704.     GOSUB ClearMsg
  705.     GOTO /I ShowArj
  706.         
  707. ELSEIFF "%t%" == "LZH" .OR. "%t%" == "LHA" .OR. "%t%" == "ICE" THEN
  708.     %arcPath%\LHA.EXE l %file% >&!%f%
  709. :ShowLZH    
  710.     *SET msg=Viewing archiv "%file%" ...
  711.     GOSUB ShowMsg
  712.     *SET na=%@WORD[0,%@SELECT[%f%,2,0,%@eval[%_rows-1],%@eval[%_columns-1], Select a file to view or ESC to abort ]]
  713.     IF "%na%" == "" GOTO EndView
  714.  
  715.     *SET msg=Extracting file "%na%" ...
  716.     GOSUB ShowMsg
  717.     %arcPath%\LHA.EXE p %file% %na% |& *list /s
  718.     GOSUB ClearMsg
  719.     GOTO /I ShowLZH
  720.  
  721. ELSEIFF "%t%" == "SQZ" THEN
  722.     %arcPath%\SQZ.EXE l %file% >&!%f%
  723. :ShowSQZ    
  724.     *SET msg=Viewing archiv "%file%" ...
  725.     GOSUB ShowMsg
  726.     *SET na=%@WORD[0,%@SELECT[%f%,2,0,%@eval[%_rows-1],%@eval[%_columns-1], Select a file to view or ESC to abort ]]
  727.     IF "%na%" == "" GOTO EndView
  728.  
  729.     *SET msg=Extracting file "%na%" ...
  730.     GOSUB ShowMsg
  731.     %arcPath%\SQZ.EXE p %file% %na% |& *list /s
  732.     GOSUB ClearMsg
  733.     GOTO /I ShowSQZ
  734.  
  735. ELSEIFF "%t%" == "ZIP" THEN
  736.     %arcPath%\PKUNZIP.EXE -v %file% >&!%f%
  737. :ShowZIP
  738.     *SET msg=Viewing archiv "%file%" ...
  739.     GOSUB ShowMsg
  740.     *SET na=%@WORD[8,%@SELECT[%f%,2,0,%@eval[%_rows-1],%@eval[%_columns-1], Select a file to view or ESC to abort ]]
  741.     IF "%na%" == "" GOTO EndView
  742.  
  743.     *SET msg=Extracting file "%na%" ...
  744.     GOSUB ShowMsg
  745.     %arcPath%\PKUNZIP.EXE -c %file% %na% |& *list /s
  746.     GOSUB ClearMsg
  747.     GOTO /I ShowZIP
  748.    
  749. ELSEIFF "%t%" == "ZOO" THEN
  750.     %arcPath%\ZOO.EXE l %file% >&!%f%
  751. :ShowZOO
  752.     *SET msg=Viewing archiv "%file%" ...
  753.     GOSUB ShowMsg
  754.     *SET na=%@WORD[7,%@SELECT[%f%,2,0,%@eval[%_rows-1],%@eval[%_columns-1], Select a file to view or ESC to abort ]]
  755.     IF "%na%" == "" GOTO EndView
  756.  
  757.     *SET msg=Extracting file "%na%" ...
  758.     GOSUB ShowMsg
  759.     %arcPath%\ZOO -p %file% %na% |& *list /s
  760.     GOSUB ClearMsg
  761.     GOTO /I ShowZOO
  762.  
  763. ELSEIFF "%t%" == "PAK" .OR. "%t%" == "ARC" THEN
  764.     %arcPath%\PAK.EXE v %file% >&!%f%
  765. :ShowPAK
  766.     *SET msg=Viewing archiv "%file%" ...
  767.     GOSUB ShowMsg
  768.     *SET na=%@SUBSTR[%@SELECT[%f%,2,0,%@eval[%_rows-1],%@eval[%_columns-1], Select a file to view or ESC to abort ],0,12]
  769.     IF "%na%" == "" GOTO EndView
  770.     *SET na=%@WORD[0,%na%].%@WORD[1,%na%]
  771.  
  772.     *SET msg=Extracting file "%na%" ...
  773.  
  774.     GOSUB ShowMsg
  775.  
  776.     %arcPath%\PAK.EXE p %file% %na% |& *list /s
  777.     GOSUB ClearMsg
  778.     GOTO /I ShowPAK
  779. ELSE
  780.     *list %file%
  781. ENDIFF
  782.  
  783. :EndView
  784. IF EXIST %f% DEL /Q %f%
  785. *UNSET /Q na
  786. RETURN
  787.  
  788. REM ----- chkdrive
  789. REM       Test if the current drive is ready to write
  790. REM       output: iErr == 0 - okay, iErr != 0 - error
  791. REM
  792. REM       note: Only works, if KSTACK is loaded (DOS-Version)
  793. REM
  794. :chkdrive
  795. *SET iErr=0
  796.  
  797. IFF "%KSTACK%" == "" THEN
  798.                                             REM KSTACK NOT loaded
  799.     IF %@ready[%_cwd%] != 1 *SET iErr=1
  800.     RETURN
  801. ENDIFF
  802.  
  803. CLS
  804. *SET msg=Testing directory "%_cwd%" ...
  805. GOSUB ShowMsg
  806. SCREEN %mline2 1
  807. keystack CTRL-Z ENTER 0 "I"
  808. copy con $$TEMP$$
  809. *SET iErr=%_?
  810. keystack 0
  811. CLS
  812. SCREEN %mline2 1
  813. IFF %iErr == 0 THEN
  814.     DEL $$TEMP$$
  815.     GOSUB ClearMsg
  816.     RETURN
  817. ENDIFF
  818. *SET msg=Error: Can't write to the directory "%_CWD" (4DOS error %iErr%)!
  819. GOSUB ShowAsk
  820. RETURN
  821.  
  822. REM ----- Des - Edit the description of the choosen file
  823. REM       Input: %file% = filename
  824. :DES
  825.     CLS
  826.     GOSUB ClearMSG
  827.     DRAWHLINE %mline1 0 %@eval[%_columns -1] 1 BRI WHI ON CYAN
  828.     DRAWHLINE %mline3 0 %@eval[%_columns -1] 1 BRI WHI ON CYAN
  829.     SCREEN %mline2 1
  830.     DESCRIBE %file%
  831.     CLS
  832. RETURN
  833.  
  834. REM ---- GetDrives - Choose a drive out of a drive list
  835. REM
  836. :GetDrives
  837. *SET Read=old
  838.  
  839. *SET vStr=■Drive-Map created by DriveMap %DescVersion%
  840.  
  841. IF %@FileSize[%DriveMap%,B] LE 0 GOTO GetDriveMap
  842. IF %@index[%@line[%DriveMap%,0],%vStr%] == 0 GOTO GLoopEnd
  843.  
  844. :GetDriveMap
  845. *SET msg=Checking drives. Please wait ...
  846. GOSUB ShowMsg
  847. *SET Read=new
  848.  
  849. *SET n=65
  850. *SET n1=1
  851. *SET n2=0
  852.  
  853. ECHO.%vstr% at %_DATE %_TIME>!%DriveMap%
  854. ECHO.■ReRead Drive Map>>!%DriveMap%
  855. ECHO.------------------------------------------------------------------------------->>%DriveMap%
  856. ECHO.Drive  --- Description ----    Total Space     Free Space   Volume >>!%DriveMap%
  857.  
  858. *SET c=%@CHAR[%n%]
  859.  
  860. :GLoop
  861. *SET c=%c%:
  862. *SET t=  %c%
  863.  
  864. IF "%KSTACK%" != "" keystack 0 enter
  865. *SET r=%@ready[%c%]
  866. IF "%KSTACK%" != "" keystack 0
  867. IFF %_row != %@eval[%_rows -4] THEN
  868.     *SET msg=Checking drives. Please wait ...
  869.     GOSUB ShowMsg
  870. ENDIFF
  871.  
  872. IF %r% == 1 *SET n2=%@eval[%n2 +1]
  873.  
  874. IFF %@REMOVABLE[%c%] == 1 THEN
  875.    *SET t=%t%  [removable]
  876. ELSE
  877.    *SET t=%t%  [fixed    ]
  878. ENDIFF
  879.    
  880. IFF %r% == 1 THEN
  881.     IFF %@REMOTE[%c%] == 1 THEN
  882.         *SET t= %t% [remote]
  883.     ELSE
  884.         *SET t= %t% [local ]
  885.     ENDIFF
  886. ELSE    
  887.    *SET t= %t% [n/a   ]
  888.    
  889. ENDIFF
  890.  
  891. IFF %r% == 1 THEN
  892.     *SET t1=%@DiskTotal[%c%,K] kb
  893.     *SET t=%t% %@substr[`                   `,1,%@eval[12-%@len[%t1%]]]  %t1%
  894.  
  895.     *SET t1=%@DiskFree[%c%,K] kb
  896.     *SET t=%t% %@substr[`                   `,1,%@eval[12-%@len[%t1%]]]  %t1%
  897.  
  898.     *SET t1=%@label[%c%]
  899.  
  900.     IFF "%t1%" == "" THEN
  901.         *SET t=%t%   [n/a]
  902.     ELSE
  903.         *SET t=%t%   %@label[%c%]
  904.     ENDIFF
  905.  
  906. ENDIFF
  907.  
  908. ECHO.%t%>>!%DriveMap%
  909. *SET n=%@eval[%n +1]
  910.  
  911. *SET c=%@CHAR[%n%]
  912. IF %c% GT %@upper[%_LASTDISK] GOTO GLoopEnd
  913.  
  914. *SET n1=%@eval[%n1 +1]
  915. GOTO GLoop
  916.  
  917. :GLoopEnd
  918. *UNSET /Q vstr
  919. CLS
  920. CC
  921. IFF "%read%" == "old" THEN
  922.     *SET n2=???
  923.     *SET n1=%@eval[ %@lines[%driveMap%]-3]
  924. ENDIFF
  925. *SET c=%@SELECT[%DriveMap%,2,0,%@eval[%_rows-1],%@eval[%_columns-1], (%read%) %n1% Drives [%n2% available, current drive is %_disk:] ]
  926.  
  927. IFF "%c%" == "" THEN
  928.     *SET ReadDir=N
  929.     RETURN
  930. ENDIFF
  931. IF %@index["%c%",Drive] == 1 GOTO GLoopEnd
  932. IF %@index["%c%",-----] == 1 GOTO GLoopEnd
  933.  
  934. IFF %@INDEX[%c%,■ReRead] != -1 THEN
  935.     DEL %DriveMap% >&NUL
  936.     GOTO GetDrives
  937. ENDIFF
  938. IF %@INDEX[%c%,■Drive-Map] != -1 GOTO GLoopEnd
  939. *SET c=%@SUBSTR["%c%",4,2]
  940.  
  941. IFF %@READY[%c%] != 1 THEN
  942.     *SET msg=Error: Drive "%c%" is NOT ready!
  943.     GOSUB ShowAsk
  944.         
  945.     GOTO GLoopEnd
  946. ENDIFF
  947. %c%
  948. RETURN
  949.  
  950. REM ----- ShowAsk - Show a msg and wait for a key
  951. REM       Input:    %msg% = Message
  952. REM
  953. :ShowAsk
  954. *SET wait=Y
  955. GOSUB ShowMsg
  956.  
  957. :ClearMsg
  958. *UNSET /Q msg
  959.  
  960. :ShowMsg
  961. REM ----- ShowMsg - Show a msg
  962. REM       Input: %msg% = Message
  963. REM              %wait% = Y ->> wait for a key and delete message
  964. REM                    else ->> return without deleting the message!
  965. REM
  966.  
  967. CLS
  968. cc
  969.                               REM clear the message box
  970. DRAWHLINE %mline1 0 %@eval[%_columns%] 1 BRI RED ON CYAN
  971. *SET n=%@eval[%mline1 +1]
  972. SCRPUT %n% 0 %clrF ON %clrB `                                                                                `
  973. *SET n=%@eval[%n +1]
  974. SCRPUT %n% 0 %clrF ON %clrB `                                                                                `
  975. *SET n=%@eval[%n +1]
  976. SCRPUT %n% 0 %clrF ON %clrB `                                                                                `
  977. *SET n=%@eval[%n +1]
  978. SCRPUT %n% 0 %clrF ON %clrB `                                                                                `
  979.  
  980. DRAWHLINE %mline3 0 %@eval[%_columns%] 1 BRI RED ON CYAN
  981. IF "%msg%" == "" RETURN
  982.  
  983. *SET n=%mline2%
  984.  
  985. SCRPUT %n% 1 %clrF ON %clrB [DESC] %msg%
  986.  
  987. IFF "%msg1%" != "" THEN
  988.     *SET n=%@eval[%n +1]
  989.     SCRPUT %n% 1 %clrF ON %clrB `       `%msg1%
  990. ENDIFF
  991. SCREEN %@eval[%n +1] 1
  992. *UNSET /Q msg msg1 n
  993. IF "%wait%" != "Y" RETURN
  994.  
  995. *UNSET /Q wait
  996. SCREEN  %@eval[%_rows-2] %@eval[(%_columns/2) - 10]
  997. INKEY --- Press any key --- %%wait
  998. CLS
  999. IF "%wait%" == "@45" QUIT 2
  1000. *UNSET /Q wait
  1001. RETURN
  1002.  
  1003. REM ----- Save DESC vars
  1004. REM
  1005. REM
  1006. :SaveDescVars
  1007. IF EXIST %ipath%%initFile% DEL /Q %ipath%%initFile%
  1008. ECHO.@ECHO OFF >!%iPath%%InitFile%
  1009. ECHO.REM ----- Values for the environment variables of DESC.BTM %DESCversion% >>%iPath%%InitFile%
  1010. ECHO.REM>>%iPath%%InitFile%
  1011. ECHO.*SET DescDirs=%DescDirs%>>%iPath%%InitFile%
  1012. ECHO.*SET ViewFiles=%ViewFiles%>>%iPath%%InitFile%
  1013. ECHO.*SET mask=%@upper[%mask%]>>%iPath%%InitFile%
  1014. ECHO.*SET DOSArc=%@upper[%DOSarc%]>>%iPath%%InitFile%
  1015. ECHO.*SET OS2Arc=%@upper[%OS2arc%]>>%iPath%%InitFile%
  1016.  
  1017. *SET l=0
  1018. :MagicLoop
  1019. *SET t=%@upper[%@word[%l%,%magics%]]
  1020. IF "%t%" == "" GOTO MagicLoopEnd
  1021. *SET l=%@eval[%l +1]
  1022. ECHO.*SET %t%=%[%t%]>>%iPath%%InitFile%
  1023. GOTO MagicLoop
  1024. :MagicLoopEnd
  1025. *UNSET /Q l t
  1026.  
  1027. ECHO.*SET magics=%@upper[%magics%]>>%iPath%%InitFile%
  1028.  
  1029. ECHO.*SET driveMap=%DriveMap%>>%iPath%%InitFile%
  1030. ECHO.>>%iPath%%InitFile%
  1031. ECHO.*SET lastDir=%_CWDS>>%initFile%
  1032. RETURN
  1033.  
  1034. REM ------------------------------------
  1035. REM ProceedParm
  1036. REM
  1037. REM Function: Proceed a parameter
  1038. REM
  1039. REM input:    %t% = current parameter
  1040. REM
  1041. REM Note:     only called if the first parameter is %xParm%
  1042. REM
  1043. :ProceedParm
  1044.     *SET file=%t%
  1045.  
  1046.     IFF "%@ready[%file%]" != "1"  THEN
  1047.         *SET msg=Warning: Can NOT access "%file%"!
  1048.         GOSUB ShowAsk
  1049.     ELSEIFF isDir %file% THEN
  1050.         cdd %file%
  1051.  
  1052.     ELSEIFF NOT EXIST %file% THEN
  1053.         *SET msg=Warning: Can NOT find the file "%file%"!
  1054.         GOSUB ShowAsk
  1055.  
  1056.     ELSE
  1057.         pushd
  1058.         IF "%@PATH[%file%]" != "" cdd %@PATH[%file%]
  1059.         *SET file=%@NAME[%file%].%@EXT[%file%]
  1060.         GOSUB ViewFile
  1061.         popd
  1062.     ENDIFF
  1063. RETURN
  1064.  
  1065. REM ----------------------------------------
  1066.  
  1067.