-->
Page 1 of 1

dofile doesn't work from callback funcion

PostPosted: Sun Jul 29, 2018 5:56 pm
by timg11
I have a createUDPsocket with related callback function:

Code: Select alls=net.createUDPSocket()
s:on("receive",function(s,c)
---snip---
end)


If I put a dofile in the callback like this:


Code: Select alls=net.createUDPSocket()
s:on("receive",function(s,c)
---snip---
dofile("lcdprint.lua").lcdprint("Testing-1-2-3--",4,0)
---snip---
end)


it is not executed or has no effect.

If it is called like this:

Code: Select alls=net.createUDPSocket()
s:on("receive",function(s,c)
---snip---
tmr.alarm(4, 1000, 1, function() dofile("lcdprint.lua").lcdprint("Testing-1-2-3--",4,0) end )
---snip---
end)


it works - lcdprint is executed.

Can anyone explain why?