Ok, I think I finally figured out what is going on. The following code is what I wrote for a Z axis zeroing routine. Thanks to everyone for your help with this. If any previous post implied that I have not gotten support here, it was just poor wording (I was complaining about my previous hardware/software vendor , not Mach3 or CandCNC), everyone here has been nothing but helpful. I've gotten several suggestions that got this program to work in the first place and, hopefully, a few more will let me make this a usable macro.
If GetOEMLed(800)<>0 Then (Check to see if the reset led is on or off, if on send reset)
DoOEMButton(1021)
End If
While GetOEMLed(824)=0 (If the Z Home led is not on)
DoOEMButton(312)Wend (Activate Z- jog button)
Wend
q=0 (I could never get the 'Sleep' function to work. I got a syntax error every time I tried to use it.)
While q < 1000 (These 4 lines are just a time delay)
q=q+1
Wend
While GetOEMLed(800)<>0 (Since the touchplate acts as a limit, this sends a reset code)
DoOEMButton(1021)
Wend
q=0 (Another time delay.)
While q < 1000
q=q+1
Wend
Code "G91 G0 Z0.252" (my touchplate is .498 thick so it raises the Z axis .252" to get it to .750)
q=0 (Another time delay. If it parses the 'While IsMoving() line before the axis starts moving it gets stuck in an unrecoverable loop)
While q < 1000
q=q+1
Wend
While ismoving() (Wait for the Z axis to stop moving before setting the Z axis DRO)
Wend
SetDro(2,.750) (Reset the Z axis DRO to .750 (my .498 plate + .252 travel)
End
This code runs perfectly in the VBScript editor window, but it chokes if I enter M1001 (the name of the macro) in in the MDI window, or try to call it as a button routine. It runs until the tool hits the touchplate, then aborts. I think that what is happening is that in the VB window, it is running under the control of VB. While it does trip a limit, the program continues and is allowed to pass a reset code to Mach3, and the program completes. When I attach it to a button in Mach3, when it hits the limit, Mach3 aborts the program so it never gets to the 'Reset' command.
It appears that what I want to do isn't possible from inside the program because any home or limit activation aborts all program code, and won't allow you to do anything else until clicking on the reset button. I have 'Auto Limit Override' turned on, but it makes no difference. What I've been able to find in documentation indicates that this setting should allow one move in the opposite direction after a 'Reset' flag is set, but so far I haven't found a way to make it work.
Does anyone have any idea if it is possible to override the 'Reset'?