Start work on Char Archiveing. Create data file if missing

His Dad [04-17-15 - 04:14]
Start work on Char Archiveing. Create data file if missing
Filename
HistOffline.lua
diff --git a/HistOffline.lua b/HistOffline.lua
index e36a6b9..11a547e 100644
--- a/HistOffline.lua
+++ b/HistOffline.lua
@@ -16,6 +16,16 @@ dofile "../../SavedVariables/History.lua"

 --os.execute("copy  ..\\..\\SavedVariables\\History.lua ..\\..\\SavedVariables\\History_Bak\\History.lua")

+-- ============== Setup storage for old characters.
+archivef = io.open("../../SavedVariables/History.Archive", "r")
+if archivef ==nil then	--create empty file
+	archivef = io.open("../../SavedVariables/History.Archive", "w")
+	archivef:write("Archive = {} \n")
+end
+archivef:close()
+dofile "../../SavedVariables/History.Archive"
+-- ==============
+
 function dump(o)
    if type(o) == 'table' then
       local s = '{ '
@@ -76,7 +86,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"]
+
 --get all character names into an array
 local names = {} display = {}

@@ -87,6 +97,12 @@ local names = {} display = {}

 -- print (dump(names))
 --print (dump(display))
+function print_old()
+	for i,j in pairs (History_SV["Default"][myaccount]["$AccountWide"]["old"]) do
+		print (i .. " .. " .. j)
+	end
+
+end
 function getlevel(char) -- as numbers
 	local level = 0
 	for i,_ in pairs(allchar[char].levels) do
@@ -106,6 +122,8 @@ function getlevel_as_text(char) -- as text and Vlevels
 	end
 end

+lbl_Status_bar = iup.label{title=L.Welcome, expand = "HORIZONTAL"}
+btn_archive = iup.button{title="Archive", FGCOLOR = "#FF0000"}
 logtabs  =iup.tabs{}  -- Examine Log Data
 Chartabs =iup.tabs{}  -- Character Info in Here

@@ -293,9 +311,6 @@ for _,char in ipairs(names) do
 		iup.SetAttribute(Vet_box[char], "BGCOLOR0:5", Colour_Heading_Complete)
 	end

-
-lbl_Status_bar = iup.label{title=L.Welcome, expand = "HORIZONTAL"}
-
 	Vet_box[char].Redraw= "ALL"
  -- ====================================

@@ -336,13 +351,9 @@ lbl_Status_bar = iup.label{title=L.Welcome, expand = "HORIZONTAL"}
 											leveling_box[char],
 											iup.fill{}
 										},
-							},
-				},
-
-			--	iup.label{title="char", expand="HORIZONTAL"},
-				iup.label{SEPARATOR="HORIZONTAL"},	-- Bottom Area
-				iup.button{title="Button", FGCOLOR = "#FF0000"},
-				}
+							},	-- end of tabs for dungeons
+						},
+				}  -- end of tabs for characters vbox
 	iup.Append(Chartabs,display[char]["vbox"])
 end
 -- Now create the Log panel
@@ -366,6 +377,7 @@ end

 -- Load the log first time
 Load_Log()
+print_old()

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

@@ -393,7 +405,7 @@ iup.Append(Chartabs, log_box)

 local panelsize = (#names*80+100) .. "x250"

--- Creates dialog
+-- Create dialog
 dlg = iup.dialog{iup.vbox{Chartabs,
 						iup.hbox{lbl_Status_bar,	-- Bottom Status bar.
 								iup.fill{},