Hi,
I understand that, in theory, it's possible to remotely debug Mach4 Macros. I have no problem setting up the debugging server for the UI - instructions at the end of the Mach4 Screen Editor manual, worked for me. However, I'd like to be able to do the same with Macros. Is this feasible? If it is, then what do I need to do?
I know that LUA does not have an intrinsic Error Handler, as it relies on the host API/OS to provide that service. However, unless I'm missing a detail in a manual somewhere, Mach4 doesn't provide it either, so any error will typically result in the code halting, and usually without any helpful explanations or hints - which makes it hard to debug. If the Macro is a relatively straightforward, and self contained in a single file, there doesn't seem to be a problem with error handling/reporting. However it appears that, once you start requiring external modules from within the Macro - it stops giving tracebacks. I've overcome that by writing a very basic handler that wraps a function in a pcall (which does native Lua error capture, and doesn't ripple through to the main routine).
In case you're interested here's the code:
errorHandler = function(func)
local wrapper = function(...)
args ={...}
errorState, msg = pcall(func, args)
if not errorState then
mc.mcCntlLog(inst, "Error: "..msg, "", -1)
-- add more handling code here
end
end
return wrapper
end
So if you have a Macro, say m900, this code snippet is used like this:
in file "m900.mcs"
function m900()
-- function body stuff goes here
end
-- add this at the end:
errorHandler = function.... --as above
m900 = errorHandler(m900)
Peter