From: John L. <jr...@us...> - 2006-05-30 22:56:34
|
Update of /cvsroot/wxlua/wxLua/samples In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv15712/wxLua/samples Modified Files: wxluasudoku.wx.lua Log Message: move check stack to debug lib and remove duplicate code Index: wxluasudoku.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/wxluasudoku.wx.lua,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** wxluasudoku.wx.lua 30 May 2006 05:57:12 -0000 1.48 --- wxluasudoku.wx.lua 30 May 2006 22:56:29 -0000 1.49 *************** *** 165,169 **** sudoku.ELIMINATE_NAKED_QUADS = 5 -- for sudoku.CalcAllPossible(sudokuTable) sudoku.ELIMINATE_HIDDEN_QUADS = 6 -- set to true to have it run ! sudoku.FILENAME = 7 -- store the filename from Open/Save functions sudoku.ELIMINATE_FLAG_MIN = 1 -- for iterating the ELIMINATE flags --- 165,169 ---- sudoku.ELIMINATE_NAKED_QUADS = 5 -- for sudoku.CalcAllPossible(sudokuTable) sudoku.ELIMINATE_HIDDEN_QUADS = 6 -- set to true to have it run ! sudoku.FILENAME = 7 -- store the fileName from Open/Save functions sudoku.ELIMINATE_FLAG_MIN = 1 -- for iterating the ELIMINATE flags *************** *** 222,231 **** -- returns a sudoku.CreateTable() with the values set and "" on success -- or nil, error_message on failure ! function sudoku.Open(filename) local values = {} local value_count = 0 -- number of cols in line local row_count = 0 -- number of rows read local line_n = 0 -- actual line number in file ! for line in io.lines(filename) do line_n = line_n + 1 local col_count = 0 --- 222,231 ---- -- returns a sudoku.CreateTable() with the values set and "" on success -- or nil, error_message on failure ! function sudoku.Open(fileName) local values = {} local value_count = 0 -- number of cols in line local row_count = 0 -- number of rows read local line_n = 0 -- actual line number in file ! for line in io.lines(fileName) do line_n = line_n + 1 local col_count = 0 *************** *** 237,241 **** value_count = value_count + 1 else ! return nil, string.format("Error loading sudoku file : '%s' invalid number '%d' on line %d.", filename, k, line_n) end end --- 237,241 ---- value_count = value_count + 1 else ! return nil, string.format("Error loading sudoku file : '%s' invalid number '%d' on line %d.", fileName, k, line_n) end end *************** *** 244,261 **** row_count = row_count + 1 elseif (col_count ~= 0) and (col_count ~= 9) then ! return nil, string.format("Error loading sudoku file : '%s' on line %d.\nExpecting 9 columns, found %d.", filename, line_n, col_count) end end if line_n == 0 then ! return nil, string.format("Error opening sudoku file : '%s'.", filename) elseif row_count ~= 9 then ! return nil, string.format("Error loading sudoku file : '%s', expected 9 rows, found %d.", filename, row_count) elseif value_count ~= 81 then ! return nil, string.format("Error loading sudoku file : '%s', expected 81 numbers, found %d.", filename, value_count) end local s = sudoku.CreateTable() ! s.flags[sudoku.FILENAME] = filename s = sudoku.SetValues(values, s) --- 244,261 ---- row_count = row_count + 1 elseif (col_count ~= 0) and (col_count ~= 9) then ! return nil, string.format("Error loading sudoku file : '%s' on line %d.\nExpecting 9 columns, found %d.", fileName, line_n, col_count) end end if line_n == 0 then ! return nil, string.format("Error opening sudoku file : '%s'.", fileName) elseif row_count ~= 9 then ! return nil, string.format("Error loading sudoku file : '%s', expected 9 rows, found %d.", fileName, row_count) elseif value_count ~= 81 then ! return nil, string.format("Error loading sudoku file : '%s', expected 81 numbers, found %d.", fileName, value_count) end local s = sudoku.CreateTable() ! s.flags[sudoku.FILENAME] = fileName s = sudoku.SetValues(values, s) *************** *** 264,269 **** -- Save a sudoku grid as a 9x9 comma separated table to a file, returns success ! function sudoku.Save(filename, sudokuTable) ! local f = io.open(filename, "w+") if not f then return false end --- 264,269 ---- -- Save a sudoku grid as a 9x9 comma separated table to a file, returns success ! function sudoku.Save(fileName, sudokuTable) ! local f = io.open(fileName, "w+") if not f then return false end *************** *** 272,276 **** io.close(f) ! sudokuTable.flags[sudoku.FILENAME] = filename return true --- 272,276 ---- io.close(f) ! sudokuTable.flags[sudoku.FILENAME] = fileName return true *************** *** 1242,1263 **** if backwards == true then k = 10 - n end if possible[k] then ! -- try a number and remove it as a possibility ! s = sudoku.RemoveCellPossible(cell, k, s) ! -- start a new table and test out this guess w/ new table ! local s1 = sudoku.RemovePossibleAll(row, col, k, TableCopy(s)) ! local g ! -- don't use SetValue since we only care about possible ! s1.values[cell] = k --sudoku.SetValue(row, col, k, s1) ! guesses[cell] = guesses[cell] + 1 ! guesses.current = guesses.current + 1 ! s1, g = sudoku.DoSolveBruteForce(sudokuTable, backwards, s1, guesses, cell+1) ! -- if s1 then success! we're all done ! if s1 then ! local s2 = TableCopy(sudokuTable) ! s2 = sudoku.SetValues(s1.values, s2) ! return s2, g ! end end end --- 1242,1263 ---- if backwards == true then k = 10 - n end if possible[k] then ! -- try a number and remove it as a possibility ! s = sudoku.RemoveCellPossible(cell, k, s) ! -- start a new table and test out this guess w/ new table ! local s1 = sudoku.RemovePossibleAll(row, col, k, TableCopy(s)) ! local g ! -- don't use SetValue since we only care about possible ! s1.values[cell] = k --sudoku.SetValue(row, col, k, s1) ! guesses[cell] = guesses[cell] + 1 ! guesses.current = guesses.current + 1 ! s1, g = sudoku.DoSolveBruteForce(sudokuTable, backwards, s1, guesses, cell+1) ! -- if s1 then success! we're all done ! if s1 then ! local s2 = TableCopy(sudokuTable) ! s2 = sudoku.SetValues(s1.values, s2) ! return s2, g ! end end end *************** *** 1274,1290 **** end function sudoku.IsUniquePuzzle(sudokuTable) local s1, g1 = sudoku.SolveBruteForce(sudokuTable, false) ! local s2, g2 = sudoku.SolveBruteForce(sudokuTable, true) ! if (not s1) or (not s2) then return nil, g1 end ! if not sudoku.IsSamePuzzle(s1, s2) then ! return nil, g1 ! end return s1, g1 end function sudoku.IsSamePuzzle(s1, s2) for cell = 1, 81 do --- 1274,1295 ---- end + -- Does this puzzle have a unique solution. It works by trying the brute force + -- solution method iterating from low to high numbers and then from high to low. + -- This should always find if there are at least two solutions. + -- returns nil if no solution or [soln table, # guesses] for forward iteration function sudoku.IsUniquePuzzle(sudokuTable) + local s1, g1 = sudoku.SolveBruteForce(sudokuTable, false) ! if not s1 then return nil end ! local s2, g2 = sudoku.SolveBruteForce(sudokuTable, true) ! if not s2 then return nil end ! if not sudoku.IsSamePuzzle(s1, s2) then return nil end return s1, g1 end + -- Do these two puzzles have the same cell values? Returns true/false. function sudoku.IsSamePuzzle(s1, s2) for cell = 1, 81 do *************** *** 1373,1377 **** local i = 0 local count = 0 - local last_cell local soln = TableCopy(sudokuTable) local bad_cells = {} --- 1378,1381 ---- *************** *** 1393,1411 **** end ! if (not bad_cells[cell]) and (last_cell ~= cell) and sudoku.HasCellValue(cell, sudokuTable) then -- test if soln going forward is same as soln backwards and original local s = TableCopy(sudokuTable) s = sudoku.SetCellValue(cell, 0, s) local soln1 = sudoku.SolveBruteForce(s, false) if not sudoku.IsSamePuzzle(soln, soln1) then - -- don't try same cell twice in a row - last_cell = cell bad_cells[cell] = true bad_cells_count = bad_cells_count + 1 else local soln2 = sudoku.SolveBruteForce(s, true) if not sudoku.IsSamePuzzle(soln, soln2) then - last_cell = cell bad_cells[cell] = true bad_cells_count = bad_cells_count + 1 --- 1397,1415 ---- end ! if (not bad_cells[cell]) and sudoku.HasCellValue(cell, sudokuTable) then -- test if soln going forward is same as soln backwards and original local s = TableCopy(sudokuTable) s = sudoku.SetCellValue(cell, 0, s) local soln1 = sudoku.SolveBruteForce(s, false) + if not soln1 then return nil, count end if not sudoku.IsSamePuzzle(soln, soln1) then bad_cells[cell] = true bad_cells_count = bad_cells_count + 1 else local soln2 = sudoku.SolveBruteForce(s, true) + if not soln2 then return nil, count end + if not sudoku.IsSamePuzzle(soln, soln2) then bad_cells[cell] = true bad_cells_count = bad_cells_count + 1 *************** *** 1813,1817 **** ]] ! -- Simply way to generate unique window or menu ids function NewID() if not sudokuGUI_ID_New then sudokuGUI_ID_New = wx.wxID_HIGHEST end --- 1817,1821 ---- ]] ! -- Simply way to generate unique window or menu ids and ensure they're in order function NewID() if not sudokuGUI_ID_New then sudokuGUI_ID_New = wx.wxID_HIGHEST end *************** *** 1831,1841 **** block_refresh = false, ! filepath = "", -- last opened filepath ! filename = "", -- last opened filename printData = wx.wxPrintData(), pageSetupData = wx.wxPageSetupDialogData(), ! Colours = {}, -- table of colours to use, indexes below VALUE_COLOUR = 1, INIT_VALUE_COLOUR = 2, --- 1835,1845 ---- block_refresh = false, ! filePath = "", -- last opened filePath ! fileName = "", -- last opened fileName printData = wx.wxPrintData(), pageSetupData = wx.wxPageSetupDialogData(), ! Colours = {}, -- table of wxColours to use, indexes below VALUE_COLOUR = 1, INIT_VALUE_COLOUR = 2, *************** *** 2508,2512 **** event:Skip() -- we don't care who actually got this event, just use the "focused cell" ! if (sudokuGUI.focused_cell_id < 1) or (sudokuGUI.focused_cell_id > 81) then return end local key = event:GetKeyCode() --- 2512,2516 ---- event:Skip() -- we don't care who actually got this event, just use the "focused cell" ! if (sudokuGUI.focused_cell_id < 1) then return end local key = event:GetKeyCode() *************** *** 2524,2528 **** event:Skip() -- we don't care who actually got this event, just use the "focused cell" ! if (sudokuGUI.focused_cell_id < 1) or (sudokuGUI.focused_cell_id > 81) then return end local key = event:GetKeyCode() --- 2528,2532 ---- event:Skip() -- we don't care who actually got this event, just use the "focused cell" ! if (sudokuGUI.focused_cell_id < 1) then return end local key = event:GetKeyCode() *************** *** 2743,2747 **** end ! -- value is still bad, just exit if not ((value == 0) or sudoku.IsValidValueN(value)) then return end --- 2747,2751 ---- end ! -- if value is still bad, just exit if not ((value == 0) or sudoku.IsValidValueN(value)) then return end *************** *** 2788,2792 **** -- clear calculated values to save memory for n = 2, sudokuGUI.sudokuTables_pos do - sudokuGUI.sudokuTables[n].possible = {} sudokuGUI.sudokuTables[n].row_values = {} sudokuGUI.sudokuTables[n].col_values = {} --- 2792,2795 ---- *************** *** 2827,2832 **** -- Create a new empty puzzle function sudokuGUI.NewPuzzle() ! local ret = wx.wxMessageBox("Clear the current puzzle and start anew?", ! "wxLuaSudoku - new puzzle?", wx.wxOK + wx.wxCANCEL + wx.wxICON_INFORMATION, sudokuGUI.frame ) --- 2830,2836 ---- -- Create a new empty puzzle function sudokuGUI.NewPuzzle() ! local ret = wx.wxMessageBox("Clear the current puzzle and start anew?\n".. ! "Use 'Create' to enter the initial values.", ! "wxLuaSudoku - New puzzle?", wx.wxOK + wx.wxCANCEL + wx.wxICON_INFORMATION, sudokuGUI.frame ) *************** *** 2865,2871 **** if init then local ret = wx.wxMessageBox( ! "Enter values in cells to initialize the puzzle with.\n".. "Previous cell values will be overwritten.\n".. ! "Don't forget to uncheck the \"Create\" menu item or tool before playing.", "wxLuaSudoku - Initialize puzzle?", wx.wxOK + wx.wxCANCEL + wx.wxICON_INFORMATION, --- 2869,2875 ---- if init then local ret = wx.wxMessageBox( ! "Enter values in the cells to initialize the puzzle with.\n".. "Previous cell values will be overwritten.\n".. ! "Don't forget to uncheck 'Create' before playing.", "wxLuaSudoku - Initialize puzzle?", wx.wxOK + wx.wxCANCEL + wx.wxICON_INFORMATION, *************** *** 2885,2889 **** "Press Ok to correct them before continuing.\n".. "If you press cancel then don't blame me if things don't work out for you.", ! "wxLuaSudoku - Invalid initial puzzle", wx.wxOK + wx.wxCANCEL + wx.wxICON_ERROR, sudokuGUI.frame ) --- 2889,2893 ---- "Press Ok to correct them before continuing.\n".. "If you press cancel then don't blame me if things don't work out for you.", ! "wxLuaSudoku - Invalid initial puzzle!", wx.wxOK + wx.wxCANCEL + wx.wxICON_ERROR, sudokuGUI.frame ) *************** *** 2895,2898 **** --- 2899,2903 ---- elseif sudokuGUI.IsCheckedMenuItem(sudokuGUI.ID_SHOW_MISTAKES) then sudokuGUI.sudokuSolnTable = sudokuGUI.SolveBruteForce(sudokuGUI.sudokuTables[1]) + if not sudokuGUI.sudokuSolnTable then -- try to make them correct the puzzle *************** *** 2900,2904 **** "The initial puzzle you've created cannot be or was not solved ".. "and therefore mistakes cannot be marked.\n".. ! "Press Ok to correct them before continuing.\n".. "If you press cancel then showing mistakes will be disabled.", "wxLuaSudoku - Invalid initial puzzle", --- 2905,2909 ---- "The initial puzzle you've created cannot be or was not solved ".. "and therefore mistakes cannot be marked.\n".. ! "Press Ok to continue 'Creating'.\n".. "If you press cancel then showing mistakes will be disabled.", "wxLuaSudoku - Invalid initial puzzle", *************** *** 2928,2932 **** local keep = wx.wxGetNumberFromUser("Set the difficulty of the new puzzle by clearing cells.", "Number of cell values to show", ! "wxLuaSudoku - generate puzzle?", sudokuGUI.difficulty, 1, 81, sudokuGUI.frame) --- 2933,2937 ---- local keep = wx.wxGetNumberFromUser("Set the difficulty of the new puzzle by clearing cells.", "Number of cell values to show", ! "wxLuaSudoku - Generate puzzle?", sudokuGUI.difficulty, 1, 81, sudokuGUI.frame) *************** *** 2936,2940 **** --- 2941,2948 ---- local solve_progress = 0 local start_time = os.time() + local last_time = start_time local solve_completed = true + local msg_idx = 1 + local progressDialog = wx.wxProgressDialog("wxLuaSudoku - Generating...", *************** *** 2951,2957 **** if (solve_progress >= 1000) then solve_progress = 0 end if solve_progress%10 ~= 0 then return true end ! local idx = math.floor((os.time()-start_time)/2)+1 ! if idx > sudokuGUI.sayings_n then idx = sudokuGUI.sayings_n end ! local msg = string.format("%s\nIteration # %d, current cell %d ", sudokuGUI.sayings[idx], count, cell) solve_completed = progressDialog:Update(solve_progress/10, msg) return solve_completed --- 2959,2967 ---- if (solve_progress >= 1000) then solve_progress = 0 end if solve_progress%10 ~= 0 then return true end ! if (msg_idx < sudokuGUI.sayings_n) and (os.time() - last_time > 4) then ! msg_idx = msg_idx + 1 ! last_time = os.time() ! end ! local msg = string.format("%s\nIteration # %d, current cell %d ", sudokuGUI.sayings[msg_idx], count, cell) solve_completed = progressDialog:Update(solve_progress/10, msg) return solve_completed *************** *** 2970,2991 **** local progressDialog = wx.wxProgressDialog("wxLuaSudoku - Ensuring Uniqueness...", string.format("%s\nIteration # %d, current cell %d ", sudokuGUI.sayings[1], 0, 0), ! 100, sudokuGUI.frame, wx.wxPD_AUTO_HIDE+wx.wxPD_CAN_ABORT+wx.wxPD_ELAPSED_TIME) ! local idx = 1 -- define handler function here so it'll work w/o gui function sudoku.GeneratePuzzleDifficultyHook(count, i, cell) if solve_completed == false then return false end -- canceled ! if math.floor((os.time()-start_time)/2) > 4 then ! idx = idx + 1 end ! if idx > sudokuGUI.sayings_n then idx = sudokuGUI.sayings_n end ! local msg = string.format("%s\nIteration # %d, current cell %d ", sudokuGUI.sayings[idx], count, cell) solve_completed = progressDialog:Update(i, msg) return solve_completed end sudokuGUI.sudokuSolnTable = TableCopy(s) local s1 = sudoku.GeneratePuzzleDifficulty(sudokuGUI.difficulty, TableCopy(s)) --- 2980,3019 ---- local progressDialog = wx.wxProgressDialog("wxLuaSudoku - Ensuring Uniqueness...", string.format("%s\nIteration # %d, current cell %d ", sudokuGUI.sayings[1], 0, 0), ! 81 - sudokuGUI.difficulty, sudokuGUI.frame, wx.wxPD_AUTO_HIDE+wx.wxPD_CAN_ABORT+wx.wxPD_ELAPSED_TIME) ! msg_idx = 1 ! last_time = os.time() ! local diff_count = 0 ! local diff_i = 0 ! local diff_cell = 0 ! -- define handler function here so it'll work w/o gui function sudoku.GeneratePuzzleDifficultyHook(count, i, cell) + diff_count = count + diff_i = i + diff_cell = cell if solve_completed == false then return false end -- canceled ! if (msg_idx < sudokuGUI.sayings_n) and (os.time() - last_time > 4) then ! msg_idx = msg_idx + 1 ! last_time = os.time() end ! local msg = string.format("%s\nIteration # %d, current cell %d, cells to go %d ", sudokuGUI.sayings[msg_idx], count, cell, 81-keep-i) solve_completed = progressDialog:Update(i, msg) return solve_completed end + -- hook into brute force solver to update the generate puzzle progress dialog + solve_progress = 0 + function sudoku.SolveBruteForceHook(guesses, cell) + solve_progress = solve_progress + 1 + if (solve_progress >= 1000) then solve_progress = 0 end + if solve_progress%10 ~= 0 then return true end + return sudoku.GeneratePuzzleDifficultyHook(diff_count, diff_i, diff_cell) + end + + sudokuGUI.sudokuSolnTable = TableCopy(s) local s1 = sudoku.GeneratePuzzleDifficulty(sudokuGUI.difficulty, TableCopy(s)) *************** *** 3002,3006 **** function sudokuGUI.OpenPuzzle() local fileDialog = wx.wxFileDialog(sudokuGUI.frame, "Open file", ! sudokuGUI.filepath, sudokuGUI.filename, "wxLuaSudoku files (*.sudoku)|*.sudoku|All files (*)|*", wx.wxOPEN + wx.wxFILE_MUST_EXIST) --- 3030,3034 ---- function sudokuGUI.OpenPuzzle() local fileDialog = wx.wxFileDialog(sudokuGUI.frame, "Open file", ! sudokuGUI.filePath, sudokuGUI.fileName, "wxLuaSudoku files (*.sudoku)|*.sudoku|All files (*)|*", wx.wxOPEN + wx.wxFILE_MUST_EXIST) *************** *** 3008,3017 **** local fileName = fileDialog:GetPath() local fn = wx.wxFileName(fileName) ! sudokuGUI.filepath = fn:GetPath() ! sudokuGUI.filename = fn:GetFullName() local s, msg = sudoku.Open(fileName) if s then ! sudokuGUI.frame:SetTitle("wxLuaSudoku - "..sudokuGUI.filename) sudokuGUI.sudokuTables_pos = 1 sudokuGUI.sudokuTables = {} --- 3036,3045 ---- local fileName = fileDialog:GetPath() local fn = wx.wxFileName(fileName) ! sudokuGUI.filePath = fn:GetPath() ! sudokuGUI.fileName = fn:GetFullName() local s, msg = sudoku.Open(fileName) if s then ! sudokuGUI.frame:SetTitle("wxLuaSudoku - "..sudokuGUI.fileName) sudokuGUI.sudokuTables_pos = 1 sudokuGUI.sudokuTables = {} *************** *** 3063,3067 **** function sudokuGUI.SaveAsPuzzle() local fileDialog = wx.wxFileDialog(sudokuGUI.frame, "Save file", ! sudokuGUI.filepath, sudokuGUI.filename, "wxLuaSudoku files (*.sudoku)|*.sudoku|All files (*)|*", wx.wxSAVE + wx.wxOVERWRITE_PROMPT) --- 3091,3095 ---- function sudokuGUI.SaveAsPuzzle() local fileDialog = wx.wxFileDialog(sudokuGUI.frame, "Save file", ! sudokuGUI.filePath, sudokuGUI.fileName, "wxLuaSudoku files (*.sudoku)|*.sudoku|All files (*)|*", wx.wxSAVE + wx.wxOVERWRITE_PROMPT) *************** *** 3070,3079 **** local fileName = fileDialog:GetPath() local fn = wx.wxFileName(fileName) ! sudokuGUI.filepath = fn:GetPath() ! sudokuGUI.filename = fn:GetFullName() result = sudoku.Save(fileName, sudokuGUI.GetCurrentGrid()) if result then ! sudokuGUI.frame:SetTitle("wxLuaSudoku - "..sudokuGUI.filename) else wx.wxMessageBox( "Unable to save file\n"..fileName, --- 3098,3107 ---- local fileName = fileDialog:GetPath() local fn = wx.wxFileName(fileName) ! sudokuGUI.filePath = fn:GetPath() ! sudokuGUI.fileName = fn:GetFullName() result = sudoku.Save(fileName, sudokuGUI.GetCurrentGrid()) if result then ! sudokuGUI.frame:SetTitle("wxLuaSudoku - "..sudokuGUI.fileName) else wx.wxMessageBox( "Unable to save file\n"..fileName, *************** *** 3209,3213 **** function sudokuGUI.SolveBruteForce(sudokuTable) local solve_progress = 0 - local start_time = os.time() local s = TableCopy(sudokuTable or sudokuGUI.GetCurrentGrid()) --- 3237,3240 ---- *************** *** 3250,3253 **** --- 3277,3283 ---- local solve_completed = true + local start_time = os.time() + local last_time = start_time + local msg_idx = 1 -- define handler function here so it'll work w/o gui *************** *** 3257,3263 **** if (solve_progress >= 1000) then solve_progress = 0 end if (solve_progress-1)%10 ~= 0 then return true end ! local idx = math.floor((os.time()-start_time)/2)+1 -- math.floor(count / 300) + 1 ! if idx > sudokuGUI.sayings_n then idx = sudokuGUI.sayings_n end ! local msg = string.format("%s\nIteration # %d, current cell %d ", sudokuGUI.sayings[idx], guesses.current, cell) solve_completed = progressDialog:Update(solve_progress/10, msg) return solve_completed --- 3287,3295 ---- if (solve_progress >= 1000) then solve_progress = 0 end if (solve_progress-1)%10 ~= 0 then return true end ! if (msg_idx < sudokuGUI.sayings_n) and (os.time() - last_time > 4) then ! msg_idx = msg_idx + 1 ! last_time = os.time() ! end ! local msg = string.format("%s\nIteration # %d, current cell %d ", sudokuGUI.sayings[msg_idx], guesses.current, cell) solve_completed = progressDialog:Update(solve_progress/10, msg) return solve_completed *************** *** 4018,4025 **** if read then if config:HasEntry(path.."/LastOpenedFilepath") then ! sudokuGUI.filepath = config:Read(path.."/LastOpenedFilepath") end if config:HasEntry(path.."/LastOpenedFilename") then ! sudokuGUI.filename = config:Read(path.."/LastOpenedFilename") end if config:HasEntry(path.."/GenerateDifficulty") then --- 4050,4057 ---- if read then if config:HasEntry(path.."/LastOpenedFilepath") then ! sudokuGUI.filePath = config:Read(path.."/LastOpenedFilepath") end if config:HasEntry(path.."/LastOpenedFilename") then ! sudokuGUI.fileName = config:Read(path.."/LastOpenedFilename") end if config:HasEntry(path.."/GenerateDifficulty") then *************** *** 4027,4032 **** end else ! config:Write(path.."/LastOpenedFilepath", sudokuGUI.filepath) ! config:Write(path.."/LastOpenedFilename", sudokuGUI.filename) config:WriteInt(path.."/GenerateDifficulty", sudokuGUI.difficulty) end --- 4059,4064 ---- end else ! config:Write(path.."/LastOpenedFilepath", sudokuGUI.filePath) ! config:Write(path.."/LastOpenedFilename", sudokuGUI.fileName) config:WriteInt(path.."/GenerateDifficulty", sudokuGUI.difficulty) end |