You could do this:
That won't work the way you're thinking - when you assign a table to a variable (such as the ones http.get() returns), you're really assigning a
pointer to a table. When you copy "req" to "reqbefore", it's not the table that gets copied, but rather it's the pointer; you end up with two variables leading to the one table.
Eg:
local a = {}
local b = a
b[2] = "World"
print("Hello "..a[2]) --> "Hello World"
This line is also busted:
while not counter == lines do
Putting aside that you forgot to increment counter, Lua will read that as
while (not counter) == lines do; "not counter" will resolve as false, which will never equal "lines" and so the loop won't repeat.
There's also no need to iterate through the handle twice - you could
do as hbomb did to get it done within a single loop, perhaps even use the readLine function as an actual iterator function in order to simplify it further. Something like that which Sewbacca was aiming for:
local request = http.get("http://example.com")
for line in request.readLine do
-- Parse line here
end
req.close()
Frankly I reckon InDieTasten has it right, though - simply using
textutils.serialise() /
textutils.unserialise() seems like the way to go here.
It sees the semicolon and bracket as an emoticon I think, and for some reason inserts those characters.
Indeed. Using the full post editor to disable emoticons is the workaround.