Reading a file
Posted: Tue Aug 14, 2012 9:56 am
Hi!
I have this small problem when reading the lines of a text document using the following code.
The text file, as an example
The problem is that the code adds the line to the table even if it contains an empty space or an a. I have a feeling that this could be caused by the "new line" unicode, but I haven't made any progress there, which I'm asking you to help me.
I know I can probably solve this by checking the line with a string function to see it's first character matches a etc.
Thank you for the help!
I have this small problem when reading the lines of a text document using the following code.
Code: Select all
for line in love.filesystem.lines("questions.txt") do
if line ~= "" or line ~= "a" then
table.insert(canvas_questions, line)
end
print(line) -- for debugging purposes
end
Code: Select all
Raggadish
Dunadump
a
Ropperish
I know I can probably solve this by checking the line with a string function to see it's first character matches a etc.
Thank you for the help!