home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / openfdr4.zip / openfdr.cmd next >
OS/2 REXX Batch file  |  1993-10-13  |  4KB  |  104 lines

  1. /* ================================================================ */
  2. /* OPENFDR.CMD v.1.4 - by M. Woo, Champaign-Urbana OS/2 Users Group */
  3. /* -- choose a folder to open from a popup list under 4OS2.         */
  4. /* Requires OS/2 (R) REXX, J.P. Software Inc.'s 4OS2 (TM).          */
  5. /*                                                                  */
  6. /* My contact addresses through Dec, 1993 (I don't know where I'll  */
  7. /* be after then) are: Internet: m-woo@uiuc.edu, Fidonet: 1:233/4.0 */
  8. /*                                                                  */
  9. /* NOTE: if your desktop doesn't reside on the C: drive, or you are */
  10. /* using OS/2 v2.0, you will have to modify this script where       */
  11. /* indicated to reflect your actual desktop's subdirectory.         */
  12. /*                                                                  */
  13. /* The user assumes responsibility for any damage caused by this    */
  14. /* program.  There is no warranty, and the program is guaranteed    */
  15. /* only to waste space on your hard drive.                          */
  16. /* ================================================================ */
  17.  
  18. /* Loads the external REXXUtil functions.         */
  19.  
  20. call RxFuncAdd "SysLoadFuncs", "REXXutil", "SysLoadFuncs"
  21. call SysLoadFuncs
  22. '@echo off'
  23.  
  24. /* ============================================== */
  25. /* If your desktop is somewhere OTHER than        */
  26. /* c:\desktop\, you'll have to make changes to    */
  27. /* the script to point to your desktop.           */
  28. /* Note: the desktop name under OS/2 2.0 is of    */
  29. /* the format <drive>:\OS!2 2.0 DESKTOP\, and     */
  30. /* a FAT drive will have <drive>:\OS!2 2.0 D\     */
  31. /* ============================================== */
  32.  
  33. /* Creates an array of all the subdirectories     */
  34. /* below "desktop" (recursively).                 */
  35.  
  36. call SysFileTree "c:\desktop\*", "dirs.", "DSO" 
  37.  
  38. /* Creates an array of folder names by reading    */
  39. /* the subdirectory array and truncating them     */
  40. /* after the final backslash.                     */
  41.  
  42. do i=1 to dirs.0 
  43.     lastslash=lastpos("\", dirs.i) 
  44.     dirname.i=delstr(dirs.i, 1, lastslash)
  45.     name=dirname.i
  46.     call lineout folder,name
  47. end /* folder name loop */
  48.  
  49. /* ============================================== */
  50. /* This section closes the newly-created text     */
  51. /* file, sorts it alphabetically, then runs the   */
  52. /* 4OS/2 variable function %@select on the text   */
  53. /* file to create the popup menu.                 */
  54. /* ============================================== */
  55.  
  56. /* Closes the text file called "folder," then     */
  57. /* sorts the output into a new file called        */
  58. /* "folder.txt"                                   */
  59.  
  60.     call lineout folder
  61.     'sort < folder > folder.txt' 
  62.  
  63. /* Directs the user's selection into a file named */
  64. /* "choice," and pipes any error messages to nul. */
  65.  
  66.     'echos %@select[folder.txt,1,1,15,30,Folder] 1>choice 2>nul' 
  67.  
  68. /* Assigns the text in "choice" to the variable   */
  69. /* "answer" and closes "choice."                  */
  70.  
  71.     answer=linein(choice)
  72.     call lineout choice
  73.  
  74. /* In case the user presses Esc to cancel the     */
  75. /* popup menu, this if-then-do loop will catch    */
  76. /* it and exit the script, after cleaning up.     */
  77.  
  78.     if answer='' then 
  79.         do
  80.         'del folder.txt folder choice /q /f' 
  81.         exit
  82.         end /* of answer loop */
  83.  
  84. /* ============================================== */
  85. /* This section reads the array of your           */
  86. /* folder names.  When the user's choice is the   */
  87. /* same as the folder name, the correct folder    */
  88. /* will be opened.                                */
  89. /* ============================================== */
  90.  
  91.     do k=1 to dirs.0 until (answer=dirname.k)
  92.         thedir=dirs.k
  93.     end /* do k loop */
  94.  
  95. /* open correct folder, specified by "thedir"     */ 
  96.  
  97.     call SysSetObjectData thedir, "OPEN=DEFAULT"; 
  98.  
  99. /* The cleanup of those messy little files that   */
  100. /* were created by this program.                  */
  101.  
  102.     'del folder.txt folder choice /q /f' 
  103. exit
  104.