Hello Guest it is June 01, 2023, 05:02:35 AM

Author Topic: Conditional and redirection from Gcode  (Read 2312 times)

0 Members and 1 Guest are viewing this topic.


Conditional and redirection from Gcode
« on: December 14, 2008, 12:21:59 PM »
Here is an interesting tidbit I found while researching EMC2 and
usbcnc codeing with the O word. Conditional and redirection
programing (parametric) can be a great tool. It allows you to
condense 1000's of lines of code down to just a few lines.(;-)

In a round about way you can do this in Mach as well.

Example code:



M9999 (If (Getvar(3) < (6) ) Then Code"M98 P140" Else code"(End M9999)")


In the example the code works down through the code to the Macro
M9999. In the macro is the conditional and redirection code to drive
the sub type loop. After it loops until it meets the condition it
Posts a message then returns to the gcode and finishes out the Gcode

From a macro the M98 does NOT need an M99 to return from so you can
redirect inside the gcode. I have several test programs running and
it does behave so far(;-) BUT it is yet untested in many ways so be
carefull if you play with it.

NOW if we could get ART to make a macro that would read into itself
the statement after the Macro call inside the $ $ then run itself we
would have the cat's meow.

M9999 $ do whatever$

Have fun, (;-)TP