Hello Guest it is April 19, 2024, 04:14:17 AM

Author Topic: Save #VARS  (Read 371 times)

0 Members and 1 Guest are viewing this topic.

Save #VARS
« on: May 15, 2023, 10:47:56 AM »
Is there a way to save the #VARS like you can the tool table and fixture offsets?  mcToolSaveFile  mcFixtureSaveFile
Or even if I could save them in an external document, that would be fine too.  If Mach4 crashes or you drop the computer our of the electrical cabinet...........  it doesn't save the values in my #VARS.

Chad Byrd
Re: Save #VARS
« Reply #1 on: May 16, 2023, 03:35:46 PM »
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
Chad Byrd
Re: Save #VARS
« Reply #2 on: May 16, 2023, 04:53:36 PM »
Hi,
I've always found tattooing on the wife's forehead a convenient location to store important data. Limited re-write potential! ;D

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'