A nested macro instruction definition is a macro instruction definition you can specify as a set of model statements in the body of an enclosing macro definition. This lets you create a macro definition by expanding the outer macro that contains the nested definition.
Note that all nested inner macro definitions are effectively "black boxes": there is no visibility to the outermost macro definition of any variable symbol or sequence symbol within any of the nested macro definitions. This means that you cannot use an enclosing macro definition to tailor or parameterize the contents of a nested inner macro definition.
This lack of parameterization can be overcome in some cases by using the AINSERT statement. This lets you generate a macro definition from within another macro generation. A simple example is shown at Where to define a macro in a source module. In Figure 33, macro ainsert_test_macro generates the macro mac1 using a combination of AINSERT and AREAD instructions. The mac1 macro is then called with a list of seven parameters.
1 macro
2 &name ainsert_test_macro
3 ainsert ' Macro',back
4 ainsert ' mac1',back
5 ainsert 'Blah blah blah',front
6 &aread aread
7 &aread setc '&aread'(1,10)
8 ainsert '&&n seta n''&&syslist ',back
9 ainsert ' dc a(&&n)',back
10 ainsert ' dc c''&aread'' ',back
11 ainsert ' mend',back
12 mend
13 *
14 testains csect 0
15 *
16 ainsert_test_macro
17+ ainsert ' Macro',back
18+ ainsert ' mac1',back
19+ ainsert 'Blah blah blah',front
20-Blah blah blah
21+ ainsert '&&n seta n''&&syslist ',back
22+ ainsert ' dc a(&&n)',back
23+ ainsert ' dc c''Blah blah '' ',back
24+ ainsert ' mend',back
25> Macro
26> mac1
27>&n seta n'&syslist
28> dc a(&n)
29> dc c'Blah blah '
30> mend
31 *
32 mac1 a,b,c,d,e,f,g
33+ dc a(7)
34+ dc c'Blah blah '
35 *
36 end[ Top of Page | Previous Page | Next Page | Contents | Index ]