Log Delete works, but writes back to history.new

His Dad [04-17-15 - 03:14]
Log Delete works, but writes back to history.new
Filename
HistOffline.lua
en.lua
history.lua
diff --git a/HistOffline.lua b/HistOffline.lua
index da66815..82b6f9c 100644
--- a/HistOffline.lua
+++ b/HistOffline.lua
@@ -11,7 +11,7 @@ dofile "en.lua"	 -- default english translations
 require( "iuplua" )
 require( "iupluacontrols" )
 dofile "../../SavedVariables/History.lua"
---dofile "../../SavedVariables/ItemSaver.lua"
+
 --os.execute( "md ..\\..\\SavedVariables\\History_Bak" )  -- fails silently if already exists.

 --os.execute("copy  ..\\..\\SavedVariables\\History.lua ..\\..\\SavedVariables\\History_Bak\\History.lua")
@@ -60,6 +60,11 @@ for i,_ in pairs(History_SV["Default"]) do -- Only one entry
 	myaccount = i
 end

+function write_data()
+  newf = assert(io.open("../../SavedVariables/History.new", "w"))
+  newf:write("History_SV=" .. write_saved(History_SV))
+  newf:close()
+end
 --Dump it back out
 -- newf:write("History_SV=" .. write_saved(History_SV))
 -- newf:close()
@@ -71,7 +76,7 @@ for i,_ in pairs(History_SV["Default"]) do -- Only one entry
 end

 local allchar = History_SV["Default"][myaccount]["$AccountWide"]["data"]
-local log_data = History_SV["Default"][myaccount]["$AccountWide"]["log"]
+--local log_data = History_SV["Default"][myaccount]["$AccountWide"]["log"]
 --get all character names into an array
 local names = {} display = {}

@@ -336,7 +341,7 @@ for _,char in ipairs(names) do

 			--	iup.label{title="char", expand="HORIZONTAL"},
 				iup.label{SEPARATOR="HORIZONTAL"},	-- Bottom Area
-				iup.button{title="Button", FGCOLOR = "#FF0080"},
+				iup.button{title="Button", FGCOLOR = "#FF0000"},
 				}
 	iup.Append(Chartabs,display[char]["vbox"])
 end
@@ -345,14 +350,14 @@ end

 local logtable =iup.matrix{numcol=1, numcol_visible=1,  numlin=0}
 	logtable:setcell(0,1, L.TStamp)
-	iup.SetAttribute(logtable,  "WIDTH0", 100)
-	iup.SetAttribute(logtable,  "WIDTH1", 150)
+	iup.SetAttribute(logtable,  "WIDTH0", 0)
+	iup.SetAttribute(logtable,  "WIDTH1", 200)


 function Load_Log()
 	local Line=0
 	logtable.numlin = Line
-	for i,j in ipairs (log_data) do
+	for i,j in ipairs (History_SV["Default"][myaccount]["$AccountWide"]["log"]) do
 		Line= Line +1
 		logtable.numlin = Line
 		logtable:setcell( Line,1, j)
@@ -362,7 +367,7 @@ end
 -- Load the log first time
 Load_Log()

-btn_eraselog=iup.button{title=L.EraseButton, FGCOLOR = "#FF0080"}
+btn_eraselog=iup.button{title=L.EraseButton, FGCOLOR = "#FF0000"}


 local log_box=iup.vbox {
@@ -372,14 +377,15 @@ local log_box=iup.vbox {
 	iup.label{SEPARATOR="HORIZONTAL"},	-- Bottom Area
 	iup.hbox {
 		btn_eraselog,
-		iup.label{title = L.EraseWarning},
+		iup.label{title = L.EraseWarning, PADDING="10X0"},
 		iup.fill{}
 	},
 	iup.fill{}
 }
 function btn_eraselog:action()
-	log_data = {}
-	Load_Log()
+	History_SV["Default"][myaccount]["$AccountWide"]["log"] = {}
+ 	write_data()	-- write new history
+ 	Load_Log()
 end
 -- Add to end of Characters
 iup.Append(Chartabs, log_box)
diff --git a/en.lua b/en.lua
index a15b774..2695e21 100644
--- a/en.lua
+++ b/en.lua
@@ -38,7 +38,7 @@ Area_names = {
 		TStamp = "Time Stamp" ,
 		title = "History For  ",
 		EraseButton = "Erase Log",
-		EraseWarning = "Do not Erase while a Character is logged in."
+		EraseWarning = "Do not Erase the log while a Character is logged in to ESO. Your changes will be overwritten."
 	}


diff --git a/history.lua b/history.lua
index bd63edf..9679d17 100644
--- a/history.lua
+++ b/history.lua
@@ -153,7 +153,7 @@ end
 function hist.Initialise(_, addOnName)
 	if (hist.name ~= addOnName) then return end

-	-- find comupted time differnce.
+	-- find computed time difference.
 	local now = GetTimeStamp()
 	hist.datestr = GetDateStringFromTimestamp(now)
 	hist.timestr = GetTimeString()