Hi steelroot,
I have real problems with LUA and less so with VB.
In a Gcode program you cant use instructions like getOEMDRO(802) as such an instruction
is VB and needs to be compiled before it will run but you can use pound variables like #99802.
I used these as an example but they relate to your question.
OEMDRO(802) is the current Z axis DRO and #99802 is exactly the same.
So if you wish to subtract from the Z DRO in Gcode:
#99802=[#99802-1.234]
Section 10 of Mach3Mill_1.84.pdf from the Artsoft website tells how pound variables work
and names a few of them...there are 10,000 of them!
Unfortunately you can't use conditionals in Gcode. Pound variables are useful but wont
in themselves solve your problem.
If I understand your question correctly you want to calculate the difference in the current
Z DRO with the next programmed Z axis move. Mach hasn't read that line yet so unless it
reads ahead until it finds a new Z instruction how can it do as you want?
If you wait until Mach reads the line with the next Z move the move is committed to the buffer before
the next line, your conditional, is read and executed. I dearsay it is possible to intervene between the
interpreter and the motion control but that is internal to Mach and I have no idea how to go about it.
The only alternative as I see it is to have a macro that reads your Gcode line by line until it finds your next
anticipated Z move. There are some useful string functions in VB which should make it possible. I have a macro
for instance that does a correction on the X axis of a large Gcode file. It achieves it by reading a line, indentifying
the next X coord if there is one, extract the string value of X move, apply an arithmetic correction, reassemble
the line as a string and outputting that line to a new or 'Corrected' file.
For this idea to work would depend on the regularity of you Gcode. If for instance you can safely assume that
a Z coord is on every line then you only need to read one line ahead. If not, and a lot of my Gcode files are this
way, many intervening lines of XY moves before the next Z move then you have a lot more reading ahead to do.
Also you would have to decide whether G0 moves or in fact any other Gcode Z moves like helical interpolation should
be included in your conditional.
If the idea sound workable to you let me know and I can write some code fragments that might help.
Craig