10 posts
Posted 19 March 2012 - 08:59 PM
Hello, I am building a mail server.
my code so far is:
In my program, when it runs into
sp = spllit( message, "#$" )
where #$ is what I split my id and message with,
it tells me that there is a nil value.
Am I doing something wrong?
Thanks,
JR98
715 posts
Posted 19 March 2012 - 09:12 PM
It would help to see the actual code for your split function, but so far I'd guess you just mistyped the call to it.
You tried to call spllit, which might not exist, I guess you wanted to call split ( with one "l" ).
10 posts
Posted 19 March 2012 - 09:32 PM
Oops, I accidentally misspelled that code because I was typing fast, sorry.
Here is the code for the Server
rednet.open("top")
while true do
event, id, message = os.pullEvent()
if event == "rednet_message" then
print("incoming message" )
sp = split( message, "#$" )
msg = sp[1]
id = tonumber(sp[0])
print(id)
print(msg)
end
end
The Client Software is like so, yet I don't think it has anything to do with the client program:
term.clear()
term.setCursorPos(1, 1)
print("To:")
t = io.read()
print("Body:")
b = io.read()
msg = table.concat( { t, b }, "#$" )
rednet.open("top")
rednet.send(2, msg)
rednet.close("top")
715 posts
Posted 19 March 2012 - 09:52 PM
So where is the code for the split function?
Because if you have none, then that's at least an explanation for the error "attempt to call nil", because you can't call a function that doesn't exist (i.e. is "nil").
Lua doesn't have a native split function, you have to program your own or take one from the internet.
If that's actually the case for you, then take a look at these examples:
http://lua-users.org/wiki/SplitJoin
10 posts
Posted 19 March 2012 - 09:56 PM
So where is the code for the split function?
Because if you have none, then that's at least an explanation for the error "attempt to call nil", because you can't call a function that doesn't exist (i.e. is "nil").
Lua doesn't have a native split function, you have to program your own or take one from the internet.
If that's actually the case for you, then take a look at these examples:
http://lua-users.org/wiki/SplitJoin
Oh, I did not realize that. Thanks.