Posted 15 July 2013 - 04:30 PM
Hello Guys, I'm working on a program, which has to split one string, two times to get all transmitted arguments, my problem is, that my split-function only splits once, and when I run it the second time, it returns just the input .. . ?!?
My Split function (placed in api "strings"):
How I call it:
Anyone know, how I can fix this ?
mark332
PS: If my english has mistakes, leave it be, I'm german ;)/>
My Split function (placed in api "strings"):
function split(splitString, delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( splitString, delimiter, from )
while delim_from do
table.insert( result, string.sub( splitString, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( splitString, delimiter, from )
end
table.insert( result, string.sub( splitString, from ) )
return result
end
How I call it:
id, message = rednet.receive(6) -- message == "bla=tree!SP!leave"
TableMessage = strings.split(message,"=") -- returns { "bla" , "tree!SP!leave" }
TableM = strings.split(TableMessage[2], "!SP!") -- returns { "tree!SP!leave" , nil}
Anyone know, how I can fix this ?
mark332
PS: If my english has mistakes, leave it be, I'm german ;)/>