Machsupport Forum
G-Code, CAD, and CAM => G-Code, CAD, and CAM discussions => Topic started by: lew on March 01, 2007, 08:42:45 AM
-
Hi:
I recently got Mach3 running. Finding that I need to tweak old programs from AhHa system.
Have a question on variable programming. In the AhHa system I could use a variable name to represent numbers.
i.e. %down=-2.312
I would then call this variable in several places in the Gcode file.
i.e. G01 Z%down
It made it easy to change the Z value without having to find it in the lines of Gcode.
I usually place the variable at the top of the program.
Now, the question. Can I use a variable to represent a decimal number in Mach3?
I know about the pound character (#) but it can only represent an integer. Not a decimal.
Thanks
Lew
-
Hi Lew,
you can do it like this :-
O0001
#1=-9.95 (z depth)
#2= -10.95 (width)
G21 G40 G00 G90 G17
G00 X0 Y0 Z25.
S1000 M3
Z1.
G01 Z#1 F50.
G01 X#2
Y#2
X0
Y0
G00 Z1.
Z1.
G01 Z#2
ETC.....
M30
You can do in line calculations too.
X[[#2*2]+#1]
Graham.
-
Graham, are there rules about the order of in line calculations or whether a variable can be used more than once in a line?
-
Mach3 uses standard maths rules anything in [] is evaluated first as is *, only thing is the whole function must be enclosed in [] brackets. #100=-1 is not allowed so you have to do #100=[1*-1], dont ask why it just one of those things.