machine fanuc15m
 word order = ( OP G3 G2 G4 G5 G6 G1 G7 )
 word order = (+ X Y Z B C I J K D H )
 word order = (+ S M1 M2 MS msg EM )
 word order = (+ Q Q1 Z2 R2 ID F)

block start = 1

 block increment = 1
 maximum block number = 100000

 define word ID
     address letter = "O"
 end define

 define format all
     tape position = 1
 end define

 define codes
     coolant on mist = M2 8
     coolant off = M2 9
 end define

 define format ( G3 G5 G6 G2 G4 G7 )
      field width   = 2
      not modal
     end define
     
 define format ( G1 M1 M2)
      field width   = 2
      trailing zeros = true
      leading zeros = true
      modal
     end define

 define format ( N )
     permanent
 end define

define word TN 
  address letter = "(ToolPathName="
  address width = 15
end define


define word JOB
  address letter = "(Name="
  address width = 6
end define


  define word TD
     address letter = "(D="
     address width  = 3
     scale factor   = 2
  end define

  define word TR
     address letter = " R="
     address width  = 3
  end define

  define format ( TN TD TR )
     not modal
     field width    = 2
     metric formats
     decimal point  = true
     decimal places = 1
     trailing zeros = false
   end define

define format (F)
     decimal point = true
 end define

word order = ( + TN TD TR )
    define format (I J K)
    scale factor = -1
 end define

 message output = false

  block order = true

define block tape start
  "%"
  ID PartID 
  G3 17 ;  G2 40 ;  G4 80 
  G5 91 ; G6 28 ; Z 0 
end define
    
define block tool change first  
  change tool ; T ToolNum 
  JOB JobName  ; ")"   
  G6 49
  "G05.1 Q1"
  TD ToolRadius[ToolNum] ;  TR TipRadius[ToolNum] ; ")"
  G5 90 ; G3 54 ; G1 0 ; X FromX ; Y FromY ; X =C ; Y =C
  G6 43 ; H Toolnum ; Z FromZ
  S ToolSpeed ; M1 3
  OP ; coolant on
end define
 
define block tool change
  G5 90 ; G1 0 ; Z FromZ ; G1 =C ; Z =C
  "G05.1 Q0" 
  M2 9
  M2 5
  G2 40 ; G4 80 ; G3 17 
  G5 91 ; G6 28 ; Z 0   
  change tool ; T ToolNum
  G6 49
  "G05.1 Q1"
  TD ToolRadius[ToolNum] ; TR TipRadius[ToolNum] ; ")"
  G2 90 ; G6 43 ; H Toolnum ; Z FromZ
  S ToolSpeed ; M1 3
  OP ; coolant on 
 end define
 
 define block move rapid   
   G1 ; X ; Y ; G1 =C ;
   Z 
 end define

 define block move circle
   G1 ; G2 ; G3 ; X ; Y ; Z ; I ; J ; K ; F
 end define

 define block tape end
    "G00 Z200"
    M1 5    
    "G05.1 Q0"   
    G5 91 ; G6 28 ; Z 0  
    G5 91 ; G6 28 ; Y 0  
    M1 30
  "%"
end define
end
