I found some examples and made a macro to do this.
This will write to a txt document that we can compare to if Mach4 crashes.
I will just run this at the end of a program to update the file.
--Update #VARS into VARS LOG File
function m101()
local inst = mc.mcGetInstance()
local Vars550 = mc.mcCntlGetPoundVar(inst, 550)
local Vars551 = mc.mcCntlGetPoundVar(inst, 551)
local Vars552 = mc.mcCntlGetPoundVar(inst, 552)
local Vars553 = mc.mcCntlGetPoundVar(inst, 553)
local Vars554 = mc.mcCntlGetPoundVar(inst, 554)
local VARSLog = string.format("#VARS 550 = ".. Vars550 .."\n")
VARSLog = VARSLog .. "#VARS 551 = " .. Vars551 .."\n"
VARSLog = VARSLog .. "#VARS 552 = " .. Vars552 .."\n"
VARSLog = VARSLog .. "#VARS 553 = " .. Vars553 .."\n"
VARSLog = VARSLog .. "#VARS 554 = " .. Vars554 .."\n"
--Write to the File Log
local MyFile = wx.wxGetCwd() .. "\\VARS Log\\VARS LOG.txt" --Mach4Hobby - VARS Log - VARS LOG.txt
file = io.open(MyFile, "w+") --Open the file in update mode, all previous data is erased
file:write (VARSLog) --Write the Gcode file
file:flush (MyFile) --Save written data
file:close (MyFile) --Close file
end--m101
if (mc.mcInEditor() == 1) then
m101()
end