I can't manage to get a string of the current line, I've got mc.mcCntlGetGcodeLineNbr() working, but I can't get mc.mcCntlGetGcodeLine() to work. It's being executed in a module, I've make test functions in the module work when I click a screen button in Mach, so I know the button is accessing the module file correctly.
I've tried copying the documentation exactly with:
char gline[128]
gline[0] = '0'
mc.mcCntlGetGcodeLine(inst, counter, gline, 128)
But when I use a char, the script in the Mach screen button that tries to link to the module file crashes as it tries to link to it, when I switch gline back to a string everything links up fine.
Here's the screen button script:
local inst = mc.mcGetInstance()
-- get access to module functions
package.path = wx.wxGetCwd().."\\Modules\\?.mcs;"
if (package.loaded.dialogTest == nil) then
module = require "dialogTest"
end
local gcodeProgram = getGcode()
mc.mcCntlSetLastError(inst, gcodeProgram[5])
test() -- just to make sure the module file is being accessed
And here's my module code:
function getGcode()
local inst = mc.mcGetInstance()
local lineNumber = mc.mcCntlGetGcodeLineNbr(inst) + 1 -- not being used
local lineCount = mc.mcCntlGetGcodeLineCount(inst)
local gcodeProgram = {}
local count = 1
loca curLine = ""
while counter <= lineCount do
mc.mcCntlGetGcodeLine(inst, counter, curLine)
table.insert(gcodeProgram, curLine)
counter = counter + 1
end
return gcodeProgram
end
function test()
local inst = mc.mcGetInstance()
mc.mcCntlSetLastError(inst, "It worked.")
end
Thanks guys.