Macro Variables

There are different variable types that can be used to store data. User defined are variables that the user has given a name, scope, and type of data to store variables. Predefined global and local variables have set names and scope that the user can store whatever data type inside that is required. $P arguments are special local type variables that store information specific to an event. System variables are variables which exist inside the post-processor software and track and hold all types of information such as the current tool number, $T or the feedrate being currently used, $F.

Variable Type Variable Format Example
User Defined A...Z, 0...9 myvar_20
Predefined Global %Gnn %G1, %G05, %G23
Predefined Local %Lnn %L1, %L03, %L23
$P argument $Pnn $P1, $P02, $P23
System $name $XC, $PI, $T

Explicit Variable Declaration

The DECLAR command is used to create a User Defined variable.

DECLAR /  variable_scope,  variable_type,  variable_name(s) [ = initial_value(s) ] 

Parameter Description
variable_scope GLOBAL, OBJECT or LOCAL
variable_name Maximum 32 characters, only alphanumeric characters and underscores, must beign with a letter
variable_assignment (optional) Initial value preceded by an equal sign

Array Variables

Number of array elements specified within parentheses

Cannot be initialized on the declaration line


System Variables

Macro system variables are predefined variables to which GENER assigns values at runtime. All system variable names begin with a ‘$’ character. All system variables have a return value, but on variables that are not read-only can be assigned a value.

The CAM-POST reference manual contains the complete list of macro variables, where all these variables are explained and the return value data type and read/write properties are indicated.

The following table includes a few examples of system variables from different functional categories.

System Variable Category Examples
Constants (read-only) $TRUE, $FALSE, $PI
Machine & CL Coordinates (read-only) $XM, $YM, $ZM, $AM, $CM, $XC, $YC, $ZC, $IC, $JC, $KC, $NXM, $NYM, $NZM,$NAM, $NCM, $NXC, $NYC, $NZC $LXM, $LYM, $LZM, $LAM, $LCM, $LXC, $LYC
Motion-related $LCS, $TCP, $MULTAX, $TLMODE, $RAPID
Coolant, spindle, feedrate, tool compensation $COOLNT, $S, $SDIR, $F, $FMODE, $TCL, $DCOMP, $TCF
Tooling-related $T, $NT, $FT, $TLNAME, $TLSUM
Canned cycle-related $CYTYPE, $CYAPT, $CYCLRP, $CYDPTH, $CYDWEL


The following table summarizes the numeric, string and sequence operators available in the ICAM macro language. Numeric operators cannot be used on strings or sequences, and string concatenation cannot be used on numbers.

Operator Function Examples
+2 Addition %G00+%L21
- Subtraction %G01–2
* Multiplication $P1*10
/ Division %L00/5
** Exponentiation %L00**2
// String concatenation %L12//'.TXT'
: Sub-string / sub-sequence $P2(1:3)
( ) Grouping %L01/(%L02+1)
{ } Sequence {$P1,$P2,$P3}

The following table lists the assignment operators available in the ICAM macro language.

Operator Function Examples
= Assignment %G00=10.5
+= Addition assignment I+=1 (same as I=I+1)
-= Subtraction assignment I-=1 (same as I=I-1)
*= Multiplication assignment %L01=2 (same as %L01=%L012)
/= Division assignment %G01/=2 (same as %G01=%G01/2)

The following table lists the logical operators available in the ICAM macro language. Two styles are available. A logical operator compares two variables or constants, returning a value of “.TRUE.” or “.FALSE.”

Operator Function Examples
.EQ. == Equal %G01.EQ.0 %G01 == 0
.NE. != Not equal %G01.NE.0 %G01 != 0
.GT. Greater than %G01.GT.0 %G01 > 0
.GE. >= Greater than or equal to %G01.GE.0 %G01 >= 0
.LT. Less than %G01.LT.0 %G01 < 0
.LE. <= Less than or equal to %G01.LE.0 %G01 <= 0
.NOT. ! Logical NOT .NOT.$FEOF() !$FEOF()
.AND. && Logical AND I.GT.0.AND.I.LE.3 I > 0 && I <= 3
.OR. || Logical OR J.EQ.1.OR.J.EQ.2 J == 1 || J = = 2

When compiling a macro, Quest ensures that the data type of the expressions left and right of an assignment operator match. If mismatching occurs, Quest issues an error message.


The ICAM macro language provides a wide variety of functions to simplify the task of writing macros. All function names begin with the $F characters and have zero or more arguments specified within parentheses (e.g. $FEOF(), $FCOS(A), $FDIST(x1,y1,z1,x2,y2,z2)). Functions can only be used to retrieve a value, called the return value. Functions cannot be used on the left hand side of an assignment.

The CAM-POST reference manual contains the complete list of macro functions explained in detail, along with the data type of the arguments and the return value data type.

The following table includes a few examples of macro functions from different categories.

Mathematical functions $FSIN, $FCOS, $FSQRT, $FLN
Numeric functions $FABS, $FFRAC, $FINT, $FMOD, $FMAX, $FMIN
Geometric, vector and matrix functions $FGPLPT3, $FVCROSS, $FVDOT, $FMX, $FMXMULT
Conversion functions $FATOF, $FCVINT, $FCVREAL
Character string and sequence functions $FMATCH, $FEDIT, $FLEN, $FTOUPER, $FTOLOWR
File and directory functions $FACCESS, $FDIRNAM, $FBASNAM, $FEOF
CL data parsing functions $FGET, $FCL, $FSIZE, $FGETARG, $FCLASS, $FSUBCL
Miscellaneous functions $FDIALOG, $FINFO, $FLOOK, $FDIST, $FDK, $FIK