ini files... you cant live whitout them, so i decided to make a semi-ini-save system, theres no images cause this is just a set of functions helping you to make saves

please tell me if you find any bugs, or have suggestions
Functions 
iniSave.open 
iniSave.open(file,[force])
opens file, once you opened a file, you dont need to open it again, however if you really need to re read the file, set force to true(this WILL discard changes made by iniSave.write and iniSave.save), force is optinal, returns true if succesfull
example:
Code:1
2
3
if iniSave.open("sys/lua/settings/example.txt") then
print("successfully opened example.txt")
end
iniSave.write 
iniSave.write(file,label,variable,newValue)
writes data to a file (be in mind, that you need to save the file, in order for the file to be affected), returns true if successfull
example:
Code:1
iniSave.write("sys/lua/settings/example.txt","settings","hello",5)
iniSave.read 
iniSave.read(file,label,variable,default)
reads data from file, if it fails (wrong file?, wrong label?, wrong variable?), it will return default (argument 4) AND act as iniSave.write, and write the default, to the file
example:
Code:1
data = iniSave.read("sys/lua/settings/example.txt","settings","hello",5)
iniSave.save 
iniSave.save(file)
this actually saves the changes made by iniSave.write and iniSave.read, to the file, returns true if successfull
example:
Code:1
2
3
if iniSave.save("sys/lua/settings/example.txt") then
print("successfully saved example.txt")
end
iniSave.saveAll 
iniSave.saveAll()
performs iniSave.save on all files that has been opened, returns true if successfull
example:
iniSave.getLabelNames 
iniSave.getLabelNames(file)
gets all labels from a file, returns a table
example:
Code:1
iniSave.getLabelNames("sys/lua/settings/example.txt")
iniSave.getVarNames 
iniSave.getVarNames(file,label)
gets all variables from a label, in a file, returns a table
example:
Code:1
variables = iniSave.getVarNames("sys/lua/settings/example.txt","settings")
Exampels 
example 1 
Code:1
2
3
iniSave.open("sys/lua/example.txt")
print(iniSave.read("sys/lua/example.txt","settings","hello",5))
iniSave.save("sys/lua/example.txt")
example.txt has written:[settings]
number:hello=5
sry but i didnt have time to make more examples
edited 1×, last 24.07.13 08:47:52 am