I have probed a single surface and am able to get x,y,z positions stored in a probe file. The next step is to be able to read this one line .csv file and retrieve the x,y,z values. Other ways to handle the information would be writing registers and then saving to the .ini file or obtaining the variable 5071,5072, and 5072. i would like to learn to work with the file operations at this point. Of course the Lua learning curve is still holding me down but I have been able to cut and paste and make a lot of progress. Properly getting the path listed and working with tables is tricky. I though I was understanding how it is done but no joy. The code posted here seems correct to me but it is providing a nil value for the CSVpath to start with. This is about as simple as it gets and I can't get it done...
Thanks for any suggestions.
Keith
--program to retrieve one line of probe data from a prob file
--and display the x,y,z positions in the error line
-- it does not seem to work and I am not sure why
local ProbeYWheel={}
local inst = mc.mcGetInstance()
local CSVPath= wx.wxGetCwd() .. "\\GcodeFiles\\KFCProbeWheelFLAT.csv" --1 line .csv file with x,y,z position from probing one time
--open file and read out the data
io.input(io.open(CSVPath, "r"))
local line;
for line in io.lines(CSVPath) do
tkz=wx.wxStringTokenizer(line,",");
ProbeYWheel["0"]={}--make blank table to hold the data - Should this be "0"??
local token=tkz:GetNextToken();
ProbeYWheel["0"] ["X_Position"]=Token; --i assume the first line is line 0??
ProbeYWheel["0"] ["y_Position"]=tkz:GetNextToken();
ProbeYWheel["0"] ["Z_Position"]=tkz:GetNextToken();
end
io.close()
--read data
local XPos = ProbeYWheel["0"].X_Position --should this be "0" ??
local YPos = ProbeYWheel["0"].Y_Position
local ZPos = ProbeYWheel["0"].Z_Position
mc.mcCntlSetLastError(inst,string.format(" X: %.4f | Y: %.4f | Z: %.4f", XPos, YPos, ZPos))