Two techniques for building macro screens

When you build a macro screen that refers to a session other than the original session that launches the macro, there are at least two techniques that you can use.

The first technique is to make each macro screen refer to one and only one active session. That is, all the descriptors and all the actions within any one macro screen should refer to the same active session. This technique allows you great flexibility and makes it simple to write, debug, and maintain your macro screens.

For example, the first 10 macro screens of your macro could interact with the original session, the next 8 macro screens could interact with a second session, and the final 4 macro screens could interact with the original session again.

The Macro object uses this first technique in storing recorded material when you record a macro that interacts with more than one active session. Whenever you switch from one active session to another, the Macro object completes and stores the current macro screen and then creates a new macro screen to hold the descriptors and actions for the first application screen of the newly selected session (see One recorded macro screen refers to one session window).

Therefore, when you record a macro that refers to more than one session, the Macro object builds the macro using the first technique.

The second technique is to allow a macro screen to refer to more than one active session. Either the descriptors refer to two or more active sessions, or the actions do, or both. If the descriptors refer to two or more active sessions, then the macro runtime evaluates each descriptor with reference to the session window of the specified session. If the actions refer to two or more active sessions, then the macro runtime executes each action against the session window of the specified session.

The second technique requires users to edit the macro, with either the Macro Editor or the Code Editor, to add references to more than one session within one macro screen (see Referring to different sessions in the same macro screen).

This second technique is more flexible than the first technique and in some situations can be necessary. However, this second technique usually makes it somewhat more complicated to write, debug, and maintain your macro screens.