Fanuc Macro Programming Training Series [ Part 3 – Local and Common Variables ]

Part #3 in our Fanuc Macro Programming Series is dealing a little bit more in-depth with the definition and use of Local Variables and Common Variables


Local Variables are so named because they are used “locally” in a macro program. This means that the value of the local variable is retained only in the program for which it was assigned. Values of local variables are not retained when branching out to other sub programs.

Local variables are primarily used for data transfer or for intermediate calculations within a macro. The table below represents the local variable available LETTER ADDRESS and corresponding NUMERICAL ADDRESS contained in the macro program. Local variables are assigned either through the use of the G65 command or by direct data input. All local variables are “vacant” unless assigned, and can be freely used by the user.

Program Example using Local Variables :

Assignment by Macro Call :

Macro Call : 
G65 P1234 A2.00 B5.00 ;

Result :  
G65 call assigns the value of 2.00 to local variable #1 ( A )
G65 call assigns the value of 5.00 to local variable #2 ( B )

Program Command :
G01 X#1 F#2

Actual Command :
G01 X2.00 F5.00

Direct Assignment by Program Command :

Macro Statement : 
#1 = #2

Result :
Direct assignment of variable #1 set to the value of variable #2

Intermediate Calculation within a Macro :
Macro Statement : 
#1 = #2 + #3

Result :
Variable #1 is equal to the sum of variables #2 and #3



Common Variables are different from local variables in that once a value is assigned, that value is shared by all other macros and the values are not cleared at M30 or RESET. This means that #100 used in one program is the same value of #100 used in another program. In addition, if the value of a common variable is calculated in one macro, that value is retained when called in another macro.

The main important feature of common variables lies in the fcat that they can be used between macros and that their values are not cleared at M30 or RESET. Users should be careful when performing calculations with common variables because when the program is re-started, the value of common variables is retained from any previous calculations and may produce unexpected results. Common variables can be freely used by the user.

#100 thru #149
These variables are cleared at power off

#500 thru #549
These variables retain their value even after power off.


Stay Tuned for more … 

Kenney Skonieczny – President
Kentech Inc.

Kipware® software is one of the fastest growing brands in machine shops around the world because it solves REAL WORLD problems.




CAD/CAM is ONLY ONE option for CNC programming.



Stop Guesstimating and Start Estimating.



Let ALL your CNC’s operate seamlessly.