From Macros Wiki
Jump to: navigation, search


The GibbsCAM Macro language uses a set of logic commands to control the order in which the contents of a macro file is processed.

When a macro is run, the first line in the macro file is processed. This will be followed by the second line, the third and so on, until the end of the file is reached. At this point the macro processing will be complete.

Most macro commands require additional data in order to set a value, or to give you a value. In a macro, values take two forms, numeric or text.

You can specify a numeric value as a number (for example 3.42), as an expression (for example 3+9/2), as a variable (for example MyToolDia), or as an expression that includes variables (for example 42.3 + MyToolDia/2). There are also a set of functions included in the macro language (cos, sin, sqrt etc) that may be used in expressions.

Text values can be specified by enclosing it in double quotes (for example "My text"), as a string variable (for example MyToolComment$), or as a text expression (for example LEFT$(MyComment$, 3)).


Numeric variable names can be from 1 to 32 characters long. They can contain characters (A to Z), numbers (0 to 9) and the underscore character "_". They may not contain spaces. Variable names must start with a character. They are not case dependant. A numeric variable is used to hold a single (floating point) value. You can also create single dimension array variables that can store a set of values.

Arrays must be defined before they are used (to specify the number of elements in the array). The first element in an array variable is 1. Other numeric variables (not arrays) do not need to be defined before use. Any variable that is not defined, is treated as a GLOBAL variable.

String variables follow the same naming convention as numeric variables, except they must end with the dollar sign "$". A string variable can hold a text string up to 1000 characters long. You can also define string arrays.


You can apply conditions to whether a line of the macro is processed or not by using the IF command. This enables you to compare two values and to choose to process the remainder of that line of the macro, depending on the comparison.

For example:

IF a>3 THEN Message "Hello" When the value of the variable "a" is greater than 3, you will see the message "Hello". When it is less than or equal to 3, the macro commands following THEN (on this line) will not be processed and the macro will move on to the next line in the file.

You can change the next line that is to be processed by using the GOTO command. You simply follow GOTO with the name of a label in the macro file and processing will move to the line that starts with a colon ":", followed by the name of the label

For example:

GOTO abc Message "Hello 1"


Message "Hello 2"

You will not see the message "Hello 1".

To repeat a section of code, you should use a FOR/NEXT loop.

List of Macro Language Commands

IF <value> <condition> <value> THEN
FOR <variable> = <start> TO <end> [STEP <value>]
NEXT <variable>
GOTO <label>
CALL <macro name> [<arg 1>, <arg2>, <arg3> (max 10 arguments)]
ON_ERROR <label>
#INCLUDE <filename>

Pages in category "Language"

The following 8 pages are in this category, out of 8 total.