home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / REXMENU2.ZIP / CDMENU.CMD < prev    next >
OS/2 REXX Batch file  |  1992-10-27  |  3KB  |  87 lines

  1. /* CDMenu.cmd: Use RexxMenu to move to interactively move to different
  2.  * different directories and drives.
  3.  */
  4.  
  5. /* ADD RexxMenu function support from the RexxMenu.dll */
  6. if 1 = RxFuncQuery('RexxMenu') then
  7.    CALL RxFuncAdd 'RexxMenu', 'RexxMenu', 'RexxMenu'
  8. /* Also uses SysFileTree to read directory */
  9. CALL RxFuncAdd 'SysFileTree', 'rexxutil', 'SysFileTree'
  10. CALL RxFuncAdd 'SysDriveMap', 'rexxutil', 'SysDriveMap'
  11.  
  12. do until 0 = COMPARE(DirChoice,'')
  13.  
  14.    CurDirSpec = DIRECTORY()
  15.    if \(LENGTH(CurDirSpec) = 3) then CurDirSpec = INSERT(CurDirSpec,'\')
  16.  
  17.    /* prepare new temporary file to save to */
  18.    TempFile = INSERT(CurDirSpec,'CDMnLst.tmp')
  19.    '@if exist' TempFile 'del' TempFile
  20.  
  21.    /* If this is not the root directory then prepare a double-dot entry */
  22.    if \(LENGTH(CurDirSpec) = 3) then do
  23.       '@echo' INSERT(CurDirSpec,'..') '>>' TempFile
  24.       curdir = DIRECTORY()
  25.       '@echo Full Name =' DIRECTORY('..') '>>' TempFile
  26.       call DIRECTORY curdir
  27.    end  /* Do */
  28.  
  29.    /* Add the current directory, just because I feel like it */
  30.    '@echo' INSERT(CurDirSpec,'.') '>>' TempFile
  31.    '@echo Full Name =' DIRECTORY() '>>' TempFile
  32.  
  33.    call SysFileTree "*", 'FileList' , 'OD'
  34.    if \(FileList.0 = 0) then do
  35.  
  36.       /* Build temporary file to hold list of subdirectories */
  37.       i = 0
  38.       do while i < FileList.0
  39.          i = i + 1
  40.          '@echo' FileList.i '>>' TempFile
  41.          '@echo Full Name =' FileList.i '>>' TempFile
  42.       end /* do */
  43.  
  44.    end  /* Do */
  45.    DROP FileList.
  46.  
  47.    /* Add options for all the drives */
  48.    curdir = DIRECTORY()
  49.    DriveMap = SysDriveMap()
  50.    i = 1
  51.    do until DriveLetter = '.'
  52.       DriveLetter = SUBSTR(DriveMap,i,1,'.')
  53.       if \(DriveLetter = '.') then do
  54.          '@echo' INSERT(CurDirSpec,INSERT(DriveLetter,':')) '>>' TempFile
  55.          '@echo Full Name =' DIRECTORY(INSERT(DriveLetter,':')) '>>' TempFile
  56.       end  /* Do */
  57.       i = i + 3
  58.    end /* do */
  59.    call DIRECTORY curdir
  60.  
  61.    /* Let user choose Directory to move to */
  62.    DirChoice = RexxMenu(TempFile,'/Com','Full Name = ',,
  63.                         '/Pre',CurDirSpec,,
  64.                         '/Prompt','CD' CurDirSpec,,
  65.                         '/Esc')
  66.  
  67.    /* Do not need the temporary file anymore */
  68.    '@del' TempFile
  69.  
  70.    if \ 0 = COMPARE(DirChoice,'') then do
  71.       if LENGTH(DirChoice) = 2 & SUBSTR(DirChoice,2,1) = ':' then do
  72.          /* change to the selected drive letter */
  73.          call DIRECTORY DirChoice
  74.       end  /* Do */
  75.       else do
  76.          /* May need quotes around directory in case there are spaces */
  77.          QuoteDirChoice = INSERT(INSERT('"',DirChoice),'"')
  78.          call DIRECTORY DirChoice
  79.       end  /* Do */
  80.    end  /* Do */
  81.  
  82. end /* do */
  83.  
  84. '@cls'
  85.  
  86. EXIT
  87.