921
Mach4 General Discussion / Re: need a little bit of help
« on: June 02, 2015, 04:55:24 PM »
You are correct!!! It is prudent to check the API functions for error codes. In examples, I don't write that stuff in, as it becomes time consuming. But it is NEEDED for production scripts to ensure that when things go wrong, it gets handled properly. In the API docs, most of the examples are in C. Some of the functions have LUA examples. But the C examples use the error codes and can be used to deduce what they would be in LUA.
Here is a snippet of a manual tool change M6 macro.
Steve
Here is a snippet of a manual tool change M6 macro.
Code: [Select]
-- M6start stuff here....
--Here, we process an EVT_MACRO_HOLD and enter the macro hold state. We can jog there!
mc.mcCntlSetLastError(inst, "Press Cycle Start to finish the tool change.");
wx.wxMilliSleep(100); -- wait a few so that the GUI can retrieve the message before the machine changes state.
-- A sleep is not generally a good idea to use. But in this case, it is harmless as the wait is minimal.
local rc = mc.mcCntlToolChangeManual(inst);
-- execution resumes from here when the user presses Cycle Start or Cycle Stop or some sort of E-stop or disabling of the machine.
-- but in the mean time the user can Jog, toogle switches, stand on your head, or do anything else he likes!
-- We check the rc of mc.mcCntlToolChangeManual() because the user might have aborted
-- the tool change by pressing Cycle Stop.
if (rc == mc.MERROR_NOERROR) then
-- the user has not aborted, finish the tool change. M6end stuff.
...
end
Steve