Category:Language

From Macros Wiki
Revision as of 18:59, 29 July 2010 by MikeO (talk | contribs)
Jump to navigationJump to 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 variables








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"

abc

Message "Hello 2"

You will not see the message "Hello 1".

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


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

Pages in category "Language"

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