I would like to see a simple set of functions to read a table from disk, and write it back to disk.
The files could be written in XML or even element format where the field name “=” field value with each field stored on a separate line would be good. Anything that could be stored in a table field should be able to be written and read back with these functions. I have done a little research and can’t find how to enumerate the table field names as text. this prevents is from writing our own functions to do the job. I know I could simply write them out, one field at a time but if something changes the field order, it would corrupt the function reading them back in.
the user should initialize the table in their preferred way in the event that the file does not exist when a read occurs. This would be the pre-initialization mode and would leave it the same way as it started if no file exists. The following code example could be a guide:
local xtable = {
element1 = 123,
userName= "",
highScore = 0
}
file = io.open ( path, "r" )
result = file:readTable(xTable)
io.close(file)
file = io.open(path, "a")
result = file:writeTable(xTable)
io.close(file)
Thanks!
stu [import]uid: 99429 topic_id: 37096 reply_id: 67096[/import]