Hi,
I wrote an m40 and an m41 specifically to work with Autoleveller, a software utility that probes a nominally flat surface to determine
small deviations from flat and thereafter manipulate the Gcode to follow the contour. I use this for making circuit boards.
The full story about how and why I came to write the macros is here:
http://www.cncsoftwaretools.com/forum/viewtopic.php?f=4&t=336You will note that the file dialog I used as the basis for my macros is included in Mach4Hobby release:
C:\Mach4Hobby\LuaExamples\ProbeToFile\m401.
The m401 macro is to open a probe file while m400 closes it. I copy m401 here, but you have it on your PC already:
function m401()
inst = mc.mcGetInstance();
    -- create the wxFrame window
    mainframe = wx.wxFrame( wx.NULL,          -- no parent
                        wx.wxID_ANY,          -- whatever for wxWindow ID
                        "DummyFrame", -- frame caption
                        wx.wxDefaultPosition, -- place the frame in default position
                        wx.wxDefaultSize,     -- default frame size
                        wx.wxDEFAULT_FRAME_STYLE ) -- use default frame styles
    -- create a panel in the frame
    panel = wx.wxPanel(mainframe, wx.wxID_ANY)--We are not going to show it but we need to have this to use the File dialog
local file = wx.wxFileDialog(panel, "Select Probe File", "", "", "Text files (*.txt)|*.txt|Tap files (*.tap)|*.tap", 
                             wx.wxFD_SAVE,wx.wxDefaultPosition,wx.wxDefaultSize, "File Dialog" );
        if(file:ShowModal() == wx.wxID_OK)then
            local path = file:GetPath()   
			--wx.wxMessageBox(tostring(path))
			--[[
			Set the output of the probe points with the format String
			Example:
			X%.3AXIS_X
			will output X<xprobevalue> 
			]]--
			mc.mcCntlProbeFileOpen(inst, path, "X%.3AXIS_X Y%.3AXIS_Y Z%.3AXIS_Z A%.3AXIS_A\r\n", true);
        end 
end
if (mc.mcInEditor() == 1) then
    m401()
endThis file dialog will need to be edited for yor purpose. A g31 automatically writes to this file in append mode, but you wish to write values you will
have to write to the file using the formal Lua procedures, and you'll find examples in my m40/m41 macros.
Craig