|
- Written and documented by David Deley
Introduction to CMac Chapter 2: Hello World II
I'll explain a few things here about invoking Multi-Edit macros, and how Multi-Edit finds your macro to
execute it. To learn by example, let's create a file with two macros in it. Type the following code into a new
window and save it as "test2.s"
| Code: |
macro_file mycmac;
void testhello()
{
TEXT("Hello World");
}
void testgoodbye()
{
TEXT("Goodbye Y'all");
}
|
The first line
tells the compiler to name the output .mac file "mycmac.mac" Without this line the compiler would default
to naming the output file after the first macro in the file. In the above example, if the "macro_file mycmac;"
line were not present, the output file would be named "testhello.mac", after the first macro encountered in
the file, "testhello".
Compile this code as explained in the previous lesson. (Examine the
three lines in the output window. The last one will tell you where your
compiled output file "mycmac.mac" ended up.)
To run the testhello macro, enter the following in the Run Macro window:
This tells Multi-Edit to look for file "mycmac.mac", and in that file find and run macro "testhello".
Similarly, to run the testgoodbye macro, enter in the Run Macro window:
This tells Multi-Edit to look for file "mycmac.mac", and in that file find and run macro "testgoodbye".
This will always work, even if you exit and restart Multi-Edit, as long as file "mycmac.mac" exists.
However, once a macro is loaded into Multi-Edit, it is no longer
necessary to enter the filename. Simply entering "testhello" or
"testgoodbye" in the Run Macro box will be sufficient to run the macro.
Multi-Edit first looks to see if it has a macro of the name you
specify already loaded. If so, it runs that macro. If not, it then
looks to see if you also entered a filename where it should look to
find the macro.
A macro remains loaded after running. Also, compiling a macro loads
the macro. That's why you can always compile a macro and then run it
without specifying the filename.
|