home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vopnfdr3.zip / vopnfdr.cmd < prev   
OS/2 REXX Batch file  |  1993-10-14  |  5KB  |  128 lines

  1. /* ================================================================ */
  2. /* VOPNFDR.CMD v1.3 by M. Woo, Champaign-Urbana OS/2 Users Group    */
  3. /* -- choose a folder to open from a PM listbox.                    */
  4. /* Requires OS/2 (R) REXX and the IBM EWS package, VREXX (by        */
  5. /* Richard B. Lam)                                                  */
  6. /*                                                                  */
  7. /* NOTE: if your desktop doesn't reside on the C: drive, or you are */
  8. /* using OS/2 v2.0, you will have to modify this script where       */
  9. /* indicated to reflect your actual desktop's subdirectory.         */
  10. /*                                                                  */
  11. /* The user assumes responsibility for any damage caused by this    */
  12. /* program.  There is no warranty, and the program is guaranteed    */
  13. /* only to waste space on your hard drive.                          */
  14. /* ================================================================ */
  15.  
  16. /* Load the external REXXUtil functions and VREXX */
  17. /* Include VREXX error-checking                   */
  18. call RxFuncAdd "SysLoadFuncs", "REXXutil", "SysLoadFuncs"
  19. call RxFuncAdd 'VInit', 'VREXX', 'VINIT' 
  20. call SysLoadFuncs
  21.  
  22. signal on failure name CLEANUP 
  23. signal on halt name CLEANUP
  24. signal on error name CLEANUP
  25. signal on syntax name CLEANUP
  26.  
  27. if RxFuncQuery(VInit)<>1 then
  28.    if VInit()=="ERROR" then signal CLEANUP 
  29.  
  30. /* ============================================== */
  31. /* Create subdirectory array.  If your desktop's  */
  32. /* directory doesn't reside on the C: drive,      */
  33. /* and/or you are using OS/2 2.0, you will need   */
  34. /* to modify the script here.                     */
  35. /* Note: the desktop under OS/2 2.0 is of the     */
  36. /* format: <drive>:\OS!2 2.0 DESKTOP\             */
  37. /* FAT drives: <drive>:\OS!2 2.0 D\               */
  38. /* ============================================== */
  39. call SysFileTree "c:\desktop\*", "dirs.", "DSO" 
  40.  
  41. /* ============================================== */
  42. /* Get folder names by reading subdir array and   */
  43. /* truncating after the last backslash, then call */
  44. /* Jack S. Tan's add and sort routines.           */
  45. /* ============================================== */
  46. do i=1 to dirs.0 
  47.     lastslash=lastpos("\", dirs.i) 
  48.     dirname.i=delstr(dirs.i, 1, lastslash)
  49.     call add list, dirname.i 
  50. end /* folder name loop */
  51.  
  52. call sort list 
  53.  
  54. /* ============================================== */
  55. /* Draw dialog listbox and keep it onscreen until */
  56. /* the user hits "cancel."                        */
  57. /*                                                */
  58. /* Search the folder name array until the user's  */
  59. /* choice matches, then open the corresponding    */
  60. /* folder.                                        */
  61. /* ============================================== */
  62.  
  63. call VDialogPos 0,90 
  64.  
  65. do forever 
  66.     result= VListBox('Choose a folder to open', list, 22, 4, 3) 
  67.     if result = 'CANCEL'
  68.         then signal CLEANUP 
  69.         else
  70.         selection_string=list.vstring 
  71.  
  72.     do k=1 to dirs.0 until (selection_string=dirname.k) = 1
  73.         thedir=dirs.k
  74.     end /* do k loop */
  75.  
  76.     call SysSetObjectData thedir, "OPEN=DEFAULT"; 
  77.     call SysSetObjectData thedir, "OPEN=DEFAULT"; 
  78.  
  79. end /* do forever loop */
  80.  
  81. CLEANUP:
  82.     call Vexit
  83. exit
  84.  
  85. /* ============================================== */
  86. /* Jack S. Tan's add routine to add objects to an */
  87. /* array more conveniently. The syntax is:        */
  88. /* "call add <stem>, <item>"                      */
  89. /* ============================================== */
  90. add:
  91.    exposeList = arg(1)||"."
  92.    call internalAdd arg(1) arg(2)
  93. return
  94.  
  95. internalAdd: procedure expose (exposeList)
  96.    parse arg stem newVal
  97.    n = value(value(stem).0)
  98.    if DATATYPE(n)<>"NUM" then
  99.       n = 0
  100.     n = n + 1
  101.    interpret value(stem)".0 = " n
  102.    interpret value(stem)"."n "= '"newVal"'"
  103. return
  104.  
  105. /* ============================================== */
  106. /* Jack S. Tan's sort routine.  The syntax is     */ 
  107. /* "call sort <stem>"                             */
  108. /* Uses output of the above "add" routine         */
  109. /* ============================================== */
  110. sort:
  111.    exposeList = arg(1)||"."
  112.    call internalSort arg(1)
  113. return
  114.  
  115. internalSort: procedure expose (exposeList)
  116.    parse arg stem
  117.    n = value(value(stem).0)
  118.    do j=2 to n
  119.       key = value(value(stem).j)
  120.       i = j-1
  121.       do while (i>0) & (value(value(stem).i)>key)
  122.          interpret value(stem)"."i+1 "= '"value(value(stem).i)"'"
  123.          i = i-1
  124.       end /* do */
  125.       interpret value(stem)"."i+1 "= '"key"'"
  126.    end /* do */
  127. return
  128.