Hi,
As I get more proficient with MS, I am beginning to see opportunities to combine or consolidate multiple smaller macros into one big macro.
But before I undertook a task like that wanted to ask, in general, is it generally considered better to have smaller macros that call upon another one when it's finished, or is it better to have one or a few macros handling as much as possible?
(I'm asking from a process/system usage and macro integrity standpoint.)
Thanks,
rjw
Simple Question about Macro Design...
Moderators: JRL, Dorian (MJT support)
Re: Simple Question about Macro Design...
Its likely a matter of preference. My opinion is keep your macros "manageable". I have hundreds of macros that do simple things and I use them like functions. Occasionally I use include> to bring them into a script, more likely I'll copy and paste them into the script, usually as a subroutine, then make alterations to suit the needs of the parent script.
Writing large scripts without planning and without the generous use of subroutines will make your head swim. I have one old functioning script in use company wide that I wrote before I understood using subroutines to make a script manageable. The script is a little over 6000 lines and I'll cry myself to sleep the night before I have to go into it to make any kind of change. I get anxious just talking about it.
One caveat to creating scripts by simply using the Include> or Macro> functions is that the Included scripts need to be written generically enough so they can be included in different scripts. Imagine you have a script that has a dialog that you want to Include> into many other scripts. You had better make the name of the dialog in the included script something unique. A name like "Dialog1" is likely to cause interference problems with other scripts. The same interference issues can occur with variable names, subroutine names, label names, etc. Another caveat is that once a script is in use in multiple other scripts you need to use extreme care if you need to alter the script at a later time. Altering it even slightly to make it work with one script could cause it to fail in other scripts.
From the standpoint of system usage, I don't think it matters whether the scripts are called or embedded.
Writing large scripts without planning and without the generous use of subroutines will make your head swim. I have one old functioning script in use company wide that I wrote before I understood using subroutines to make a script manageable. The script is a little over 6000 lines and I'll cry myself to sleep the night before I have to go into it to make any kind of change. I get anxious just talking about it.
One caveat to creating scripts by simply using the Include> or Macro> functions is that the Included scripts need to be written generically enough so they can be included in different scripts. Imagine you have a script that has a dialog that you want to Include> into many other scripts. You had better make the name of the dialog in the included script something unique. A name like "Dialog1" is likely to cause interference problems with other scripts. The same interference issues can occur with variable names, subroutine names, label names, etc. Another caveat is that once a script is in use in multiple other scripts you need to use extreme care if you need to alter the script at a later time. Altering it even slightly to make it work with one script could cause it to fail in other scripts.
From the standpoint of system usage, I don't think it matters whether the scripts are called or embedded.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Simple Question about Macro Design...
It's really up to you / the needs of the project. What makes most sense is to keep often-used functions in Include files, so that you are not duplicating code and having to modify multiple scripts just for a change to one replicated piece of code. See:
http://help.mjtnet.com/article/16-inclu ... rary-files
http://help.mjtnet.com/article/16-inclu ... rary-files
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Simple Question about Macro Design...
Honestly, I don't know what I would do without you two. I feel like a part of my paycheck should be going to you guys every month.
well...almost, lol.
well...almost, lol.