/* Progress-Bar for Directory Opus 5. By Leo Davidson ("Nudel", P0T-NOoDLE/Gods'Gift Utilities) $VER: PBar.dopus5 1.4 (18.8.95) This ARexx script will add a progress bar (like when deleting files) to external commands which are run on all the selected entries in a lister. Call as: ------------------------------------------------------------------------------ ARexx PBar.dopus5 {Qp} "<1>" "<2>" ------------------------------------------------------------------------------ Where <1> is the AmigaDOS command to be run for each file. Insert "!!f!!" (without quotes) where you would like the full path to the selected file (you can insert it more than once, if you require). <2> is the progress window title. If <1> or <2> have any spaces in them, "put quotes around them". The "Do All Files" switch MUST be turned *_OFF_*!!! e.g. ------------------------------------------------------------------------------ ARexx DOpus5:ARexx/PBar.dopus5 {Qp} "C:PackIt !!f!! CRUNCH" "Packing files:" ------------------------------------------------------------------------------ Note: The command you use must be able to handle "filenames with quotes". TO DO: ------ - Convert this to a nice, fast assembler program - once I get to grips with how to send Rexx messages via rexxsyslib.library (HELP!). - Make it rescan all selected entries. (Short of making it rescan the entire dir, which you can do as a switch within DOpus, I don't think there is a way to emulate "Reload each file" via an ARexx script, at least in the current version of DOpus5.) - Perhaps propper support for all the {} type codes, not just {f}. - ONLY DIRS and ONLY FILES options. (If you don't want it to act on files or on dirs, simply don't select them!) - Take a filetype-ID so that only files matching it are acted on. (this would actually be a pain to impliment - I'm not about to). v1.02 -> v1.03 - Now uses stem variables for getting the lister handle. Some minor tidying up. Now checks to make sure the DOPUS.x port exists. v1.03 -> v1.4 - Now uses Show() instead of ShowList(). (Thanks Stoebi) Style Guide compliant version numbering and $VER string. ---- Setup -------------------------------------------------------------------- You should edit the SepBar below to look right with your output-window setup (use the script and you'll see what it does). */ SepBar = "-----------------------------------------------------------------------------------" options results options FAILAT 99 signal on syntax;signal on ioerr /* Error trapping */ /*- Parse the command-line --------------------------------------------------*/ CmdLine = ARG(1) DOpusPort = GetCmdWord() UserCommand = GetCmdWord() UserTitle = GetCmdWord() If DOpusPort="" THEN Do Say "Not correctly called from Directory Opus 5!" Say "Load this ARexx script into an editor for more info." EXIT END If ~Show("P",DOpusPort) Then Do Say DOpusPort "is not a valid port." EXIT End Address value DOpusPort If UserTitle="" Then UserTitle = "Doing all files..." lister query source stem source_handle. IF source_handle.count = 0 | source_handle.count = "SOURCE_HANDLE.COUNT" Then Do dopus request '"You must have a SOURCE lister!" OK' EXIT End lister set source_handle.0 busy 1 lister query source_handle.0 numselentries /* Get info about selected */ Lister_NumSelEnt = RESULT /* entries & path to them */ lister query source_handle.0 path Lister_Path = Strip(RESULT,"B",'"') If Lister_NumSelEnt = "RESULT" | Lister_Path = "RESULT" Then Do lister set source_handle.0 busy 0 EXIT END /*-- The Progress Bar --------------------------------------------------------- A progress bar will display how many of the selected files have been done. This means the max-number argument is Lister_NumSelEnt. For each selected entry, the "Do i..." loop updates the progress bar, builds and executes the user-defined command, and then de-selects. -----------------------------------------------------------------------------*/ lister set source_handle.0 progress Lister_NumSelEnt UserTitle Do i=1 to Lister_NumSelEnt lister query source_handle.0 firstsel Temp_Name = RESULT lister select source_handle.0 Temp_Name 0 Temp_Name = Strip(Temp_Name,"B",'"') lister set source_handle.0 progress name Temp_Name lister set source_handle.0 progress count i lister query source_handle.0 abort IF RESULT=1 THEN BREAK /* If they aborted, break the loop */ Temp_Name = '"'||Lister_Path||Temp_Name||'"' Temp_Exec = Upper(UserCommand) Do While Index(Temp_Exec,"!!F!!") ~= 0 Temp_Pos = Index(Temp_Exec,"!!F!!") Temp_Exec = DelStr(Temp_Exec,Temp_Pos,"5") Temp_Exec = Insert(Temp_Name,Temp_Exec,Temp_Pos-1) END Address Command Temp_Exec Say SepBar END /*-- Restore the Lister for normal use --------------------------------------*/ syntax:;ioerr: /* In case of error, jump here */ lister clear source_handle.0 progress lister refresh source_handle.0 lister set source_handle.0 busy 0 EXIT /*- Function for Command-Line parsing ----------------------------------------- ARexx's "PARSE ARG" is rank. It isn't very good at handling arguments with "quotes" (especially when the quotes are optional), and inserts spaces where you don't want them sometimes. I don't have the docs to RexxDosSupport, so I wrote my own function which extracts the next argument from the string "CmdLine", respecting quotes, and not adding extra spaces at either side. -----------------------------------------------------------------------------*/ GetCmdWord: Temp_CmdWord = Word(CmdLine,1) CmdLine = DelWord(CmdLine,1,1) If Left(Temp_CmdWord,1) = '"' Then Do Forever If Right(Temp_CmdWord,1) = '"' Then Break If Words(CmdLine) = "0" Then Call BadCmd_Quotes Temp_CmdWord = Temp_CmdWord||" "||Word(CmdLine,1) CmdLine = DelWord(CmdLine,1,1) End Return Strip(Temp_CmdWord,"B",'"') BadCmd_Quotes: dopus request '"PBar.dopus5: Bad Command Line.' || X2C(0A) || 'Unclosed quotes in string." OK' EXIT