While attempting to figure out a problem with a m6 script I placed a line is the mcs file. This IMMEDIATLY crashed mach4 and consistantly crashed it on startup until I removed the offending line. I was attempting a C/C++ type statement with a boolean variable like the following.
--log = msg..string.format((val == 1) ? "Not ": "" .. "Ignore all tool changes, selected tool was #%0.0f", selectedtool)
On the other hand, this completely fails in a function m6(). yes I know it's mostly commented out. I've been attempting to figure out why this fails.
local hreg, rc = mc.mcRegGetHandle(inst, "iRegs0/2010/IgnoreM6")
--if (rc ~= mc.MERROR_NOERROR) then
-- mc.mcCntlLog(inst, msg.."failure to acquire register handle. rc="..rc, "", -1)
-- ignore = 0
--else
-- ignore = mc.mcRegGetValue(hreg)
-- mc.mcCntlSetLastError(inst," IgnoreM6 set to " .. ignore)
--end
ignore = mc.mcRegGetValue(hreg)
--log = msg..string.format((val == 1) ? "Not ": "" .. "Ignore all tool changes, selected tool was #%0.0f", selectedtool)
-- Skip remaining tool change steps if ignoring tool changes
if (ignore == 1) then
log = msg..string.format("Ignoring all tool changes, selected tool was #%0.0f", selectedtool)
mc.mcCntlLog(inst, log, "", -1)
mc.mcCntlSetLastError(inst, log)
return
end
Some part of this crashes mach4 with NO error msg at all. I haven't dug into this enough to know where though. I suspect it might be the extra ) on the end of the string.format. This should NOT ever happen to a well developed program though. Error msg, yes. Crash NO.
local hreg, rc = mc.mcRegGetHandle(inst, "iRegs0/2010/IgnoreM6")
if (rc ~= mc.MERROR_NOERROR) then
mc.mcCntlLog(inst, msg.."failure to acquire register handle. rc="..rc, "", -1)
else
ignore = mc.mcRegGetValueLong(hreg)
end
-- Skip remaining tool change steps if ignoring tool changes
if (ignore == 1) then
log = msg..string.format("Ignoring all tool changes, selected tool was #%0.0f", selectedtool))
mc.mcCntlSetLastError(inst, log)
return
end
I've also discovered that the random NULL pointer is being written into the screen.xml file which causes mach4 to crash of course. sometimes it will tell you where the error is so you can use a text editor to fix the xml, other times I've had to use XMLnotepad to find and correct the extra character. This has been going on for years now. I remember working on a screenset 5-6 years ago and found the same thing. Randomly inserted null pointer into the screen xml file. Can I reliably replicate the problem? nope. do I know it happens, yes it does. Just wish it'd be fixed. From the lack of activity on the forums though, it's like Mach4 is going by the wayside. No idea what it's being replaced with though.