Posted 01 May 2013 - 11:01 AM
Here is the code In full: http://pastebin.com/nzkjcdwt
I am writing a todo list and message board and I have the todo list functionality fully working including saving and loading data from files.
The problem I'm having is in loading and saving data for the message board.
I want to save both the username and the message in a table within a table.
e.g Table[1] would have another table in it storing more information.
I use this technique in my code for the GUI but I'm struggling with this part of the code (lines 82-102):
If you cant tell from the code the separate file will be set up like this "username:message"
So when it comes to reading the file i want it to separate the string and save them as two separate variables in a table within a table.
Any help or advice on my coding will be greatly appreciated! :)/>
I am writing a todo list and message board and I have the todo list functionality fully working including saving and loading data from files.
The problem I'm having is in loading and saving data for the message board.
I want to save both the username and the message in a table within a table.
e.g Table[1] would have another table in it storing more information.
I use this technique in my code for the GUI but I'm struggling with this part of the code (lines 82-102):
local file = fs.open("mes","r")
local i = 1
local line = file.readLine()
for username, mess in string.gmatch(line, "(%w+):(/>/>%w+)") do
mesData[i].user = username
mesData[i].message = mess
print(i)
line = file.readLine()
if line == nil then
break
else
i = i + 1
end
end
file.close()
If you cant tell from the code the separate file will be set up like this "username:message"
So when it comes to reading the file i want it to separate the string and save them as two separate variables in a table within a table.
Any help or advice on my coding will be greatly appreciated! :)/>