361
Mach4 General Discussion / Re: New to jogging/ non g-code moves
« on: February 02, 2020, 01:52:30 PM »
You can't jog a coordinated axis from an M code. Period. Because the machine is in automatic mode when running G code. Jogging coordinated axes is only possible in manual mode. Determining what the return code is would tell you this. We know it is not MERROR_NOERROR. But what is the return code exactly? If you had looked at it, you would have seen that it is -18 (MERROR_NOT_NOW). Meaning you cannot jog now.
To RT's point, the return codes are numbers like -18. As such, it is hard to know what they mean unless you have memorized them. This is why mc.mcCntlGetErrorString() exists.
Notice the comment about wxMessageBox(). You can paint yourself into a corner really quickly using wxMessageBox() in macro scripts. It is best not to use them. You should use mcCntlSetLastError() or mcCntlLog() (requires the log window to be up) instead.
Steve
To RT's point, the return codes are numbers like -18. As such, it is hard to know what they mean unless you have memorized them. This is why mc.mcCntlGetErrorString() exists.
Code: [Select]
function m91002()
local inst = mc.mcGetInstance()
rc = mc.mcJogIncStart(inst, 0, -.2)
if rc ~= mc.MERROR_NOERROR then
local rcText = mcCntlGetErrorString(inst, rc)
-- wx.wxMessageBox("failure") -- you have to be careful with message boxes in scripts!!!!
-- Better to use mc.mcCntlSetLastError().
mc.mcCntlSetLastError(inst, "m91002(): " .. rcText)
end
end
Notice the comment about wxMessageBox(). You can paint yourself into a corner really quickly using wxMessageBox() in macro scripts. It is best not to use them. You should use mcCntlSetLastError() or mcCntlLog() (requires the log window to be up) instead.
Steve