Fundamentals: Running A Macro

Instructions on how to select and launch a macro file are covered in your SmartCAM application's help file and in the Automation/Customization - Record and Playback Overview topics. A very brief explanation of the entire process is described below:

  1. Create your macro as an ASCII text file, one expression per line.
  2. Save the macro.
  3. Start your SmartCAM application.
  4. Select Macro - Execute.
  5. Use File Select or type in the path and name of your macro.
  6. Use Accept to run it.

How It Works

SmartCAM's macro system is what is technically termed a two-pass compiler. When you run a macro, SmartCAM first reads through the macro converting the macro commands into a set of machine instructions. During this compilation pass, the syntax of your macro is evaluated. If there are errors, they are written to the SmartCAM Diagnostics window. If there were no errors, the list of machine instructions are executed by a "virtual machine."

SmartCAM does not have an entry procedure, instead it starts reading the macro from top to bottom and starts running commands as soon as it reads one that can be run. If the very first line at the top of the ASCII file is a valid macro command, that is where SmartCAM will begin to run.

It will continue to run each line of macro commands, in succession, until:

Comments

When parsing a macro file, SmartCAM will ignore anything that follows the comment characters. Comment characters are two forward-slashes "//". Anything following the comment characters, until the end of the current line is reached, is ignored. Example:

//	This entire line is ignored
#A=10  // #A is set to 10, but everything after that is ignored
//  #A=11 - #A is NOT set to 11, since it comes after the comment characters

When writing a macro, use a lot of comments and thoroughly document what your macro is meant to do and what each line or block of lines is for. Using comments to document your macro will make it easier to extend the macro or debug the macro. Also the person that wrote the macro may no longer be associated with your organization when it is time to make changes. So, accurate and complete documentation will aid the new programmer understand what the macro code is attempting to accomplish.

Whitespace

Whitespace characters are characters that don't display on your monitor, such as blank lines, space characters, and tabs. They effect the formatting of text but have no specific character themselves.

SmartCAM skips over blank lines in your macro file. Using blank lines to group together related functionality, along with comments, is a good idea.

SmartCAM also skips over other whitespace characters, such as spaces and tabs. As long as the spaces and tabs do not cause macro key words to be broken. Examples:

#S = #S + 1	// this is valid
#S=#S+1 // this is also valid and is the same as above
# S = #S + 1 // this is not valid, because the variable designator is separated from the variable name

The same whitespace requirements exist for macro commands as well.

ON_LAYER[LY=1,
WP = "XY_PLANE", LV=-1,
PT=1.0]

The above is the same as:

ON_LAYER[LY=1, WP="XY_PLANE", LV=-1, PT=1.0]

While you can split up macro commands into multiple lines, this is not recommended. It makes debugging and understanding the macro logic more difficult.

Related Topics

Functions and Commands

Expressions

Macro Development Fundamentals Overview

SmartCAM Automation Overview