{"id":1172,"date":"2010-05-07T15:26:17","date_gmt":"2010-05-07T15:26:17","guid":{"rendered":"http:\/\/www.mjtnet.com\/blog\/?p=1172"},"modified":"2010-05-07T15:26:17","modified_gmt":"2010-05-07T15:26:17","slug":"run-all-macros-in-a-foldergroup","status":"publish","type":"post","link":"https:\/\/www.mjtnet.com\/blog\/2010\/05\/07\/run-all-macros-in-a-foldergroup\/","title":{"rendered":"Run All Macros in a Folder\/Group"},"content":{"rendered":"<p>Someone asked me today how to run all macros found in a folder.  This simple script will run all macros it finds in its own folder in turn:<\/p>\n<pre name=\"code\" class=\"macroscript\">GetFileList>%SCRIPT_DIR%\\*.scp,MacroFiles\r\nSeparate>MacroFiles,;,Macros\r\nIf>Macros_count>0\r\n  Let>k=0\r\n  Repeat>k\r\n    Let>k=k+1\r\n    Let>this_macro=Macros_%k%\r\n    If>this_macro<>SCRIPT_FILE\r\n      Macro>this_macro\r\n    Endif\r\n  Until>k=Macros_count\r\nEndif<\/pre>\n<p>Note the check to make sure it doesn&#8217;t run itself!  <\/p>\n<p>This could be useful where you want a quick way to schedule a series of macros.  Schedule this script and then all you need to do to add another to the schedule is to drop it into the same folder (or macro group).<\/p>\n<p>For a bit more control consider naming each macro with a numeric prefix and then sort the array to determine the order in which they are run.  Version 12 (currently in beta) has a built in ArraySort function.  Or use <a href=\"http:\/\/www.mjtnet.com\/blog\/2009\/10\/29\/quick-sort-routine\/\">this QuickSort algorithm<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Someone asked me today how to run all macros found in a folder. This simple script will run all macros it finds in its own folder in turn: GetFileList>%SCRIPT_DIR%\\*.scp,MacroFiles Separate>MacroFiles,;,Macros If>Macros_count>0 Let>k=0 Repeat>k Let>k=k+1 Let>this_macro=Macros_%k% If>this_macroSCRIPT_FILE Macro>this_macro Endif Until>k=Macros_count Endif Note the check to make sure it doesn&#8217;t run itself! This could be useful where [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,6],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/1172"}],"collection":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/comments?post=1172"}],"version-history":[{"count":2,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/1172\/revisions"}],"predecessor-version":[{"id":1174,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/1172\/revisions\/1174"}],"wp:attachment":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/media?parent=1172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/categories?post=1172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/tags?post=1172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}