For as close a comparison to Fanuc subs and macros, I'd try changing the fanuc post to output for EMC2 like the following
normal Fanuc main program output:
Code:
O100 (main program code)
...
M98 P1001 (sub program call without parameters)
(aka. just repeated code)
...
G65 P1002 A1.0 B3.5 (macro call with parameters)
(aka. Code that changes with parameters)
...
M02
Modified Fanuc main program output to work with EMC2:
Code:
O100 (main program code)
...
O1001 CALL (sub program call without parameters)
(aka. just repeated code)
...
O1002 CALL [1.0] [3.5] (macro call with parameters)
(aka. Code that changes with parameters)
...
M02
EMC2 calls do not label the variables when done this way, they are just ordered in the call line as #1 #2 #3 ect. that is why I chose A B... for the fanuc sample.
normal Fanuc sub program output:
Code:
O1001 (sub program call without parameters)
G91 ( incremental )
...
(normal G-code)
...
G90 ( absolute )
M99
modified Fanuc sub program output to work with EMC2:
Code:
O1001 SUB (sub program call without parameters)
G91 ( incremental )
...
(normal G-code)
...
G90 ( absolute )
O1001 SUBEND
modified Fanuc macro program output to work with EMC2:
Code:
O1001 SUB (sub program call without parameters)
G91 ( incremental )
...
(G-code with #1 and #2 variables used)
...
G90 ( absolute )
O1001 SUBEND
For EMC2, save the subs to separate named files like ArcEye's example.
This is just one way to do this, but probably the closest to a Fanuc like way of doing so.
Personally I like that way piasdom's example is done when using just sub type code, or a macro that is only used with one set of values. If using a macro with different values each time it is called, I prefer the above setup of setting the values on the sub call line.