Menu

Feature request - apply macro to all tabs.

Vadi
2007-12-17
2012-11-13
  • Vadi

    Vadi - 2007-12-17

    Hello,

    Would it be possible to have such a feature where you can run a macro once, until the end of file, or n times for *all* opened tabs?

    Right now, I need to do each feature for every opened tab, which is a bit tedious.

    Thank you!

     
    • Nobody/Anonymous

      Perhaps this can be done by or added to the Simple Script Plug-In?

      You're welcome!!

       
      • fidvo

        fidvo - 2007-12-18

        (I am the author of Simple Script)

        I was actually thinking the same thing.  I could add menu options "Run script on all open tabs" and "Repeat script on all open tabs."  Right now there's no way to do it in Simple Script, but it's on the wish list.  If I can figure out how to switch between tabs, I'll probably add it to version 1.2 or 1.3.  I don't anticipate there will be any great difficulty; I just need to research it a bit.

         
        • fidvo

          fidvo - 2007-12-18

          Switching tabs through a script is probably beyond the scope of the plugin.  SimpleScript is meant for text processing, not program control.

          As far as errors go, I've done my best to anticipate errors and catch them in the validation process, so most errors will be caught before any updating of the data takes place.  However, it's possible that some will sneak through.  In this case, the error will bring everything to a halt, and the updated data will not be copied back into the document.  I figured this was the best solution; not only is it easy to code, but if anything goes wrong, the document is left in its original state.

          When dealing with running a script on multiple documents (i.e. tabs), the errors can be divided into 3 categories, listed here in order of decreasing probability:

          1) Syntax errors.  It will be caught during the validation process and the script won't run at all.  Just fix it and run it again.

          2) Logical bugs or other runtime errors.  It will most likely manifest itself in the first document it tries to update, and therefore none of the documents will be updated.  Again, just fix it and run it again.

          3) Errors that depend upon the content of the document.  It will update some of the tabs fine, but others will be left un-updated.  You might need to "Undo" some of the documents to get them back to the original state so you can make the fixes and run the script again.

          Since the third type of error should be extremely rare and doesn't result in an unrecoverable state, I don't think I'll worry about it too much when I write the code to run a script on all opened tabs.

           
          • fidvo

            fidvo - 2007-12-19

            Building an "Undo" into the SimpleScript plugin might be a little difficult, because I would have to keep track of which tabs were updated, a tricky problem when there are errors involved.  Right now, the built-in Undo seems to work just fine to undo the entire script, so I didn't worry about it when only one tab is involved.

            I'll keep it in mind, though.

             
          • Nobody/Anonymous

            OK, thanks for your clear answers.

            Perhaps it would be a good thing to build an Undo (last action) feature into the Simple Script Plug-In as well, undoing all the changed documents in case a macro was applied (possibly not successfully) to all of them.

             
        • Nobody/Anonymous

          I don't know how easily this can be done, but it would be nice if the script language would allow switching tabs, too. But if it's in the menu, I guess it would already be of great help. (But what if a script goes wrong and ends in an error, or is that impossible?)