For your first example, I don't know what you were doing with that table. I assume that you wanted to walk the digits of the #590 var. This is more easily accomplished by converting the #var number to a string. This is done by the "string.sub(SNv, 1, 6);". Then just loop through each character.
function m100()
local inst = mc.mcGetInstance();
local SNv = mc.mcCntlGetPoundVar(inst , 590);
local str = string.sub(SNv, 1, 6);
local idx = 0;
--wx.wxMessageBox(tostring(str));
--local SN = {}
local SN;
for idx = 1, #str do
SN = str:sub(idx, idx);
if SN == "1" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X1.0");
elseif SN == "2" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X2.0");
elseif SN == "3" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X3.0");
elseif SN == "4" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X4.0");
elseif SN == "5" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X5.0");
elseif SN == "6" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X6.0");
elseif SN == "7" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X7.0");
elseif SN == "8" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X8.0");
elseif SN == "9" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X9.0");
elseif SN == "0" then
mc.mcCntlGcodeExecuteWait(inst, "G0 X0.0");
end
end
mc.mcCntlSetPoundVar(inst , 590, tonumber(str) + 1);
end
if (mc.mcInEditor() == 1) then
m100()
end