doing a little code to zero work z. program works fine when i single step through it but when i run it from a button, not so good. here is the 
here is the code.
feed = getdro(18)
if suchsignal(22) then
code "g31 z-7 f35"     'seek the sensor fast
while ismoving()
wend
sensor = getoemdro(85)  'get machine z position
pull back = sensor +.1     'add .1 to machine z
code "g53 g01 z" & pullback   'move z upto clear sensor
while ismoving()
wend
nextmove = getoemdro(85)  ' get new machine z position
move = nextmove - .11       ' set up for next machine move
code "f1"
code "g31 z" & move   ' slow sensor seek
while ismoving()
wend
ofst = getoemdro(1001)   ' get sensor height
call setdro(2, ofst)           ' set work z dro to sensor height
code "f" & feed              ' reset feed rate
end if
end
ok here is the problem i  have.  when i step through the script using the editor i works great, just like i wanted it to.  
this line "call setdro(2, ofst)  sets the work dro to sensor height ,then from the mdi line i can type in g01 z0 and it will move the tool down to top of part.
when i run it from the auto zero button it won't set dro 2 to the right offset.
any ideas
thanks rob