home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR13 / OPENFDR3.ZIP / OPENFDR.CMD next >
OS/2 REXX Batch file  |  1993-10-11  |  5KB  |  112 lines

  1. /* ================================================================ */
  2. /* OPENFDR.CMD v.1.3 - 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. /* Unfortunately, I don't know of a way to make the folder open in  */
  14. /* front of the 4OS/2 command window, without adding another set of */
  15. /* external REXX functions.  Suggestions would be greatly           */
  16. /* appreciated!                                                     */
  17. /*                                                                  */
  18. /* The user assumes responsibility for any damage caused by this    */
  19. /* program.  There is no warranty, and the program is guaranteed    */
  20. /* only to waste space on your hard drive.                          */
  21. /* ================================================================ */
  22.  
  23. /* Loads the external REXXUtil functions.         */
  24.  
  25. call RxFuncAdd "SysLoadFuncs", "REXXutil", "SysLoadFuncs"
  26. call SysLoadFuncs
  27. '@echo off'
  28.  
  29. /* ============================================== */
  30. /* This section reads the names of the folders    */
  31. /* on your system, and writes them to a file that */
  32. /* 4OS/2's %@select[] command will read.          */
  33. /*                                                */
  34. /* If your desktop is somewhere OTHER than        */
  35. /* c:\desktop\, you'll have to make changes to    */
  36. /* the script to point to your desktop.           */
  37. /* Note: the desktop name under OS/2 2.0 is of    */
  38. /* the format <drive>:\OS!2 2.0 DESKTOP\          */
  39. /* ============================================== */
  40.  
  41. /* Creates an array of all the subdirectories     */
  42. /* below "desktop" (recursively).                 */
  43.  
  44. call SysFileTree "c:\desktop\*", "dirs.", "DSO" 
  45.  
  46. /* Creates an array of folder names by reading    */
  47. /* the subdirectory array and truncating them     */
  48. /* after the final backslash.                     */
  49.  
  50. do i=1 to dirs.0 
  51.     lastslash=lastpos("\", dirs.i) 
  52.     dirname.i=delstr(dirs.i, 1, lastslash)
  53.     name=dirname.i
  54.     lineout(folder,name) '>& nul'
  55. end /* folder name loop */
  56.  
  57. /* ============================================== */
  58. /* This section closes the newly-created text     */
  59. /* file, sorts it alphabetically, then runs the   */
  60. /* 4OS/2 variable function %@select on the text   */
  61. /* file to create the popup menu.                 */
  62. /* ============================================== */
  63.  
  64. /* Closes the text file called "folder," then     */
  65. /* sorts the output into a new file called        */
  66. /* "folder.txt"                                   */
  67.  
  68.     lineout(folder) '>& nul'
  69.     'sort < folder > folder.txt' 
  70.  
  71. /* Directs the user's selection into a file named */
  72. /* "choice," and pipes any error messages to nul. */
  73.  
  74.     'echos %@select[folder.txt,1,1,15,30,Folder] 1>choice 2>nul' 
  75.  
  76. /* Assigns the text in "choice" to the variable   */
  77. /* "answer" and closes "choice."                  */
  78.  
  79.     answer=linein(choice)
  80.     lineout(choice) '>&nul'
  81.  
  82. /* In case the user presses Esc to cancel the     */
  83. /* popup menu, this if-then-do loop will catch    */
  84. /* it and exit the script, after cleaning up.     */
  85.  
  86.     if answer='' then 
  87.         do
  88.         'del folder.txt folder choice /q /f' 
  89.         exit
  90.         end /* of answer loop */
  91.  
  92. /* ============================================== */
  93. /* This section reads the array of your           */
  94. /* folder names.  When the user's choice is the   */
  95. /* same as the folder name, the correct folder    */
  96. /* will be opened.                                */
  97. /* ============================================== */
  98.  
  99.     do k=1 to dirs.0 until (answer=dirname.k)
  100.         thedir=dirs.k
  101.     end /* do k loop */
  102.  
  103. /* open correct folder, specified by "thedir"     */ 
  104.  
  105.     call SysSetObjectData thedir, "OPEN=DEFAULT"; 
  106.  
  107. /* The cleanup of those messy little files that   */
  108. /* were created by this program.                  */
  109.  
  110.     'del folder.txt folder choice /q /f' 
  111. exit
  112.