Understanding Macros

CC3 has a simple macro language that enables you to automate repetitive tasks. It can loop, store variables and control some dialog box settings. The macros cannot drive dialog boxes. CC3’s macros are stored in a plain text file called fcw32.mac. This contains many essential macros that CC3 uses to perform mapping tasks, so don’t change these.

To start creating macros, open fcw32.mac in a plain text editor such as notepad.

  1. Type MACRO then a unique string. This mustn’t be a CC3 command, modifier or macro. To test this, type it at the command prompt. If you get a "CC3 cannot perform this task" then you have a uniqe name.

  2. Type your macro

  3. Type ENDM.

To try out your macro

  1. Save fcw32.mac.

  2. Click Tools >> Macros >> Load Macros and select fcw32.mac.

  3. Type the name of the macro at the prompt, press ENTER.

How do macros work?
Whenever you select a command by typing at the Command prompt, from a script, from a button, or from a menu, CC3 checks the list of macros to see if that term has been defined as a macro name. If it has, CC3 replaces the macro name with the macro text.

The macro text can be:

·   A single value (for example, 2 stored in the name RED);

·   A renamed command (for example, FSTYLE stored in the name FS);

·   A command with one or more parameters (for example, the name SQUARE could contain RPOLY 4 to let you start a 4-sided regular polygon by typing SQUARE);

·   A series of commands making up a macro program.

You can use the text-equivalent of CC3’s menu commands in a macro program. You can also use the special macro programming commands explained in the Macro Command Reference. These special commands let you write programs that:

·   Ask the user (yourself or another, less experienced user) to enter points, values, text, and other data (prompting for user input);

·   Store the data in variables (storing data in variables);

·   Use the stored data in drawing and editing operations;

·   Make calculations based on stored data (calculating with variables);

·   Compare values in variables and make decisions based on the results (controlling program flow);

·   Jump to a label within the macro or repeat a series of commands (controlling program flow);

·   Call other macros as subroutines, for up to 16 levels of nesting.

You do not have to write programs to use the special macro commands. For example, if you want to draw several lines radiating from a common point, you could use GP (Get Point) to store the point in a function key, then press the key to enter the first point of each line. Using macro commands from the keyboard can help you learn how they work. If you intend to write complex macros (using branching, looping, and so on), this discussion assumes that you are already familiar with basic programming concepts.

Related Topics:

image\btn_mini.gif Macro Tips

image\btn_mini.gif Macro Command Reference

image\btn_mini.gif Alphabetical List of Macro Commands