OOPS, sorry here is the script I am trying to run it as a Mcode.
function m100()
inst=mc.mcGetInstance()
local SNv = mc.mcCntlGetPoundVar(inst , 590)
local str = string.sub(SNv,1,6)
wx.wxMessageBox(tostring(str))
local SN = {}
for i = 1, #str do
SN = str:sub(i, i)
end
for _,v in ipairs(SN) do
if v == "1" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X1.0");
elseif v == "2" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X2.0");
elseif v == "3" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X3.0");
elseif v == "4" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X4.0");
elseif v == "5" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X5.0");
elseif v == "6" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X6.0");
elseif v == "7" then
mc.mcCntlGcodeExecute(inst, "G0 X7.0");
elseif v == "8" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X8.0");
elseif v == "9" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X9.0");
elseif v == "0" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X0.0");
end
end
--SN = (SN +1)
mc.mcCntlSetPoundVar(inst , 590,(str +1))
end
if (mc.mcInEditor() == 1) then
m100()
end