home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / blkos207.zip / D.CMD < prev    next >
OS/2 REXX Batch file  |  1993-05-19  |  5KB  |  160 lines

  1. /*D.CMD*/
  2. /*QUICK DIRECTORY CHANGE/LIST COMMAND from ***BLKOS2****/
  3. /*(c) C.BLACK,B.STONE, KUTEK 1992,1993*/
  4. /*KUTEK PO BOX 261 FORKED RIVER, NJ 08731*/
  5. /* you do not type full paths with this command- it finds them for you!!!*/
  6. /* in the following dir is the dir you want to go to or list subdirs of*/
  7. /*USAGE: D <x:dir OR a number> </>  ( no space  for the /)*/
  8. /*EXAMPLE:you are at g:\ and want to go to C:\what\when\where\how\cost\scream*/
  9. /* type      D c:scream           to go directly to scream*/
  10. /* if more than one dir scream exists on the target you choose from a list*/
  11. /*EXAMPLE: you are at c:\tired\being\ ripped\ off  */
  12. /*and want to go to b:\blkos2\excellent\functional\cheapware\capable*/
  13. /* type D b:capable  and you are there.*/
  14. /*EXAMPLE: D x:dir/    gives you a list of all subdir of X:dir*/
  15. /* where x is  a drive letter  and dir is a directory name on that drive*/
  16. /*choose a number from the list to go directly to that sub*/
  17. /*EXAMPLE: to see the sub dirs of b:\blkos2\excellent\functional  */
  18. /* type D b:functional/  */
  19. /*EXAMPLE: type D alone to get  a list of all subs of the current dir*/
  20. /*choose a number from the list to go directly to that sub*/
  21. /*EXAMPLE: D 5  to go 'up'  the dir tree from scream to what*/
  22. /* the number eliminates that many terms from the prompt*/
  23. /*EXAMPLE: D g:/ gives a list of all subdirs on drive g  */
  24. /*wildcards are allowed*/
  25. /*EXAMPLE: to go from g:\ to c:\\\scream you can type D c:sc??am  */
  26. /* case is irrelevant*/
  27. /*no quotation marks necessary for long dir names on HPFS drives*/
  28. /*EXAMPLE HPFS: to go to_ g:\how easy can you get _on hpfs drive g  */
  29. /*type D G:how easy can you get        add / for sub dir list   */
  30. /* all REXX programs must start with a comment  at the first col of the first line*/
  31. /*remove all BUT ONE of these comments from your working copy*/
  32. /* to get max speed*/
  33. /* turn ansi ON*/
  34. /* make sure long lines with ansi terms are one line in your working copy*/
  35. /*D.CMD*/
  36. /*QUICK DIRECTORY CHANGE/LIST COMMAND from ***BLKOS2****/
  37. /*(c) C.BLACK,B.STONE, KUTEK 1992,1993*/
  38. /*all rights reserved, use at your own risk*/
  39. /* may not be sold or bundled*/
  40.  
  41. '@echo off'
  42. s=rxfuncquery(sysloadfuncs)
  43. if s=1 then do
  44. call rxfuncadd sysloadfuncs,rexxutil,sysloadfuncs
  45. call sysloadfuncs;end
  46. ret=directory()
  47. curd=substr(ret,1,3)
  48. dodir=0
  49. tt=0;nju=''
  50. fleeb=0
  51. if value(noff,,'OS2ENVIRONMENT')\=''  then fleeb=1
  52. if fleeb =0 then parse upper arg xx
  53. else do
  54. xx=value(noff,,'OS2ENVIRONMENT')
  55. end  /* Do */
  56.  
  57. if right(xx,1)='/' then do
  58. dodir=1
  59. xx=strip(xx,'T','/')
  60. end
  61. if length(xx)=2&(pos(':',xx)=2)&(dodir\=1) then do
  62. wq=directory(xx'\')
  63. exit
  64. end
  65.  
  66.  if (xx\='')&(datatype(xx,W)=1)&(xx<9) then do i=1 to xx
  67. 'cd..'
  68. if i=xx  then exit
  69.    end  /* Do */
  70.     if (length(xx)=2) &(substr(xx,2,1)=':')  then do
  71.  l=xx'\'
  72. tt=1
  73. end
  74.  if (xx='')&(right(ret,1)\='\') then l=(ret)('\')
  75.    If (xx\='')&(pos(':',xx)=0) then l=(curd)(xx)('\')
  76. else if(length(xx)>2)&(pos(':',xx)=2) then do
  77. parse var xx aaa':'bbb
  78. l=aaa':\'bbb'\'
  79.    end  /* Do */
  80. if (dodir\=1)&(tt\=1)then l=strip(l,'T','\')
  81. if (xx='')&(ret\=curd) then do
  82.  l=ret'\*'
  83. dodir=1
  84. end
  85. if (xx='')&(ret=curd) then l='*'
  86. lu=sysfiletree(l,by,dst)
  87. if (dodir\=1)&(by.0=0) then do
  88. if fleeb=1 then do
  89. rtnn='xxx*'
  90. call gone
  91. end
  92. else
  93. say ''L 'DOES NOT EXIST ON THE DRIVE'
  94. sfd=directory(ret)
  95. exit
  96. end
  97. else if(dodir\=1)&( by.0=1) then do
  98. parse var by.1 v1 v2 v3 v4
  99. xx=strip(v4,b)
  100. if fleeb=1 then call gone
  101. else
  102. call directory xx
  103. exit
  104. end
  105.  
  106. listit:
  107. parse value systextscreensize() with rr y
  108. lp=0
  109.  if (BY.0=0) then do
  110. say 'THERE ARE NO SUBDIRECTORIES '
  111. sfr=directory(ret)
  112. exit
  113. end
  114. else do k=1 to BY.0
  115. lp=lp+1
  116. parse var by.k v1 v2 v3 v4 
  117. say  '('k')' v4''
  118. if lp=rr-2 then do
  119. call ki
  120. lp=0
  121. end
  122. end
  123. ki:
  124. if k<(BY.0-1) then say 'SELECT DIRECTORY OR HIT ENTER FOR MORE'
  125. else say 'SELECT DIRECTORY OR HIT ENTER TO EXIT TO PROMPT'
  126.  
  127. do forever                              
  128. nj=sysgetkey()                          
  129. if nj=x2c(0d) then leave                
  130. nju=nju||nj                             
  131. end                                     
  132.                       
  133. if (nju\='') then do
  134. parse var by.nju b1 b2 b3 b4 
  135. xx=strip(b4,b)
  136. if fleeb=1 then do
  137.    call gone
  138. end  /* Do */
  139. else
  140. call directory xx
  141. end
  142. if (nju='')&(k\>by.0-1) then return
  143. else do
  144. if nju='' then fry=directory(ret)
  145.  exit
  146. end
  147. end
  148. end
  149. exit
  150.  
  151. gone:
  152. www=value(noff,xx,'OS2ENVIRONMENT')
  153. return 
  154.  
  155.  
  156.  
  157.  
  158.                                           /*     REXX RULES!!    */
  159.  
  160.