Hi,
I have a problem that I don't understand. I try to split a string into an array, here's what I'm expecting :
Code:
local myTable = strsplit("," , "A,B,C,D,E,F", 6)
> should be returning
myTable = {"A", "B", "C", "D", "E", "F"}
I know strsplit isn't a native lua function but it is implemented by blizzard in WoW.
And it works !
When I type /dump strsplit("," , "A,B,C,D,E,F", 6) I get this :
Code:
[1]="A",
[2]="B",
[3]="C",
[4]="D",
[5]="E",
[6]="F"
... so what's your problem you might be thinking.
The problem is, when I try to use that code into my addon file, it returns "A". As a string.
I'll show you the addon code part that works on that, can you tell me if you see a mistake leading to this ? Thanks.
Code:
local addChans = strupper(additionalChannelsEditBox:GetText()) -- here I have a string of the format "A, B, C, D, E, F"
addChans = gsub(addChans, " ", "") -- now it's "A,B,C,D,E,F" without extra spaces
addChans = strsplit(",", addChans, 6) -- should be {"A", "B", "C", "D", "E", "F"}, is "A"
I have checked the first two lines by printing their result, they are working as intended. At first I thought the issue might come from the addChan variable becoming a table from a string (power of the lua !) but even by declaring a new local variable for the table it didn't work.
Any advice ?
Iphi.
P.S. : sorry for bad English, if any too big mistakes please tell me I'll correct. Not my native language ^^