Should be a cleaner way to do this, but it does work, thanks Jeff
just hit cancel if you don't want that particular folder goes to the next one.
handles USB and networks fine
local inst = mc.mcGetInstance();
local myGCodePath = "C:/";
local Path1 = "C:/Mach3/GCode";
local Path2 = "C:/Mach4/Test GCodes";
local Path3 = "F:/";
local Path4 = "//LIGHT-TABLE/GCode";
local i;
for i=1 , 4 do
if ( i==1 ) then
myGCodePath = Path1;
end
if (i==2) then
myGCodePath = Path2;
end
if (i==3) then
myGCodePath = Path3;
end
if (i==4) then
myGCodePath = Path4;
end
local fileDialog = wx.wxFileDialog(wx.NULL, "Open file", myGCodePath,
"", "GCode files (*.txt;*.nc;*.tap)|*.txt;*.nc;*.tap|TXT files (*.txt)|*.txt|NC files (*.nc)|*.nc|TAP files (*.tap)|*.tap", wx.wxFD_DEFAULT_STYLE);
if fileDialog:ShowModal() == wx.wxID_OK then
local fileName = string.reverse(fileDialog:GetFilename());
local pos = string.find(fileName, "%.");
local fileExt = string.reverse(string.sub(fileName, 1, pos-1));
if fileExt == "tap" or fileExt == "nc" or fileExt == "txt" then
local filePath = fileDialog:GetPath();
local result = mc.mcCntlLoadGcodeFile(inst, filePath);
if not result then
wx.wxMessageBox("Sorry, I could not open file.");
end
else
local message = string.format("%s is wrong file type", fileExt);
wx.wxMessageBox(message);
end
end
end