home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / FileMover / Dopus5 / scx-do51.lha / arexx / PBar.dopus5 < prev    next >
Encoding:
Text File  |  1995-05-05  |  3.0 KB  |  80 lines

  1. /* Progress-Bar v1.00 [04-May-1995] for Directory Opus 5.
  2.    By Leo Davidson (P0T-NOoDLE/Gods'Gift Utilities)
  3.    This ARexx script will add a progress bar (like when deleting files)
  4.    to external commands which are run on all the selected files in a
  5.    lister.
  6.  
  7. Call as:
  8. ------------------------------------------------------------------------------
  9. ARexx    PBar.dopus5 {p} <AmigaDOS command to do for each selected file>
  10. ------------------------------------------------------------------------------
  11. The "Do All Files" switch MUST be turned OFF!!!
  12. Insert "!!f!!" where you would like the full path to the selected file.
  13.  
  14. e.g.
  15. ------------------------------------------------------------------------------
  16. ARexx    DOpus5:ARexx/PBar.dopus5 {p} C:PackIt !!f!! CRUNCH
  17. ------------------------------------------------------------------------------
  18.  
  19. TO DO:
  20. ------
  21.  
  22. - The user should also be able to specify the "Doing all files..." message.
  23. - ONLY DIRS and ONLY FILES options.
  24. - Perhaps propper support for all the {} type codes, not just {f}.
  25. */
  26.  
  27. /*-- Setup ------------------------------------------------------------------*/
  28. options results                    /* Start talking to DOpus */
  29. signal on syntax;signal on error;signal on ioerr
  30. PARSE ARG DOpusPort UserCommand
  31. If DOpusPort~="" THEN Address value DOpusPort
  32.  
  33. lister query source                /* Get lister and set busy */
  34. Lister_Handle = RESULT
  35. If Lister_Handle = "RESULT" THEN EXIT
  36. lister set Lister_Handle busy 1
  37.  
  38. lister query Lister_Handle numselentries    /* Get info about selected */
  39. Lister_NumSelEnt = RESULT            /* entries & path to them */
  40. lister query Lister_Handle path
  41. Lister_Path = Strip(RESULT,"B",'"')
  42.  
  43. If Lister_NumSelEnt = "RESULT" | Lister_Path = "RESULT" Then Do
  44.     lister set Lister_Handle busy 0
  45.     EXIT
  46.     END
  47.  
  48. /*-- The Progress Bar ---------------------------------------------------------
  49. A progress bar will display how many of the selected files have been done.
  50. This means the max-number argument is Lister_NumSelEnt.
  51. For each selected entry, the "Do i..." loop updates the progress bar,
  52. builds and executes the user-defined command, and then de-selects.
  53. -----------------------------------------------------------------------------*/
  54. lister set Lister_Handle progress Lister_NumSelEnt "Doing all files..."
  55.  
  56. Do i=1 to Lister_NumSelEnt
  57.     lister query Lister_Handle firstsel
  58.     Temp_Name = Strip(RESULT,"B",'"')
  59.     lister set Lister_Handle progress name Temp_Name
  60.     lister select Lister_Handle Temp_Name 0
  61.     lister set Lister_Handle progress count i
  62.     lister query Lister_Handle abort
  63.     IF 1=RESULT THEN BREAK        /* If they aborted, break the loop */
  64.  
  65.     Temp_Exec = Upper(UserCommand)
  66.     Do While Index(Temp_Exec,"!!F!!") ~= 0
  67.         Temp_Pos = Index(Temp_Exec,"!!F!!")
  68.         Temp_Exec = Left(Temp_Exec,Temp_Pos-1)||'"'||Lister_Path||Temp_Name||'"'||Right(Temp_Exec,Length(Temp_Exec)-(Temp_Pos+4))
  69.         END
  70.     Address Command Temp_Exec
  71.     END
  72.  
  73. /*-- Restore the Lister for normal use --------------------------------------*/
  74. syntax:;error:;ioerr:            /* In case of error, jump here */
  75. lister clear Lister_Handle progress
  76. lister refresh Lister_Handle
  77. lister set Lister_Handle busy 0
  78.  
  79. EXIT
  80.