[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Reading a conf file
- From: Valentin <vsl@...>
- Date: Thu, 29 Sep 2016 03:15:24 +0200
> Okay all you smarty pants (tee hee)! I need to be able to replace the
> value of a line item in said conf files. This was my terrible attempt
> some moons ago:
As Sean has already mentioned, instead of identifying and changing a
particular line in your conf file, it would be much easier to just save
your full configuration again - unless you care about white space and
comments in the conf file. If not, the following minimal code would
write your conf table back to such a "INI-like" conf file:
function saveConfToFile (confTable, confFile)
local f = io.open(confFile, 'w')
if f==nil then return false end
for k,v in pairs(confTable) do
f:write(k..'='..v..'\n')
end
f:close()
return true
end
Disclaimer: untested email code
Valentin