Extension split
Posted: 08 May 2006, 14:09
Sooo Lapo. I think I found a weird bug.
I've been testing for the last half hour and finally managed to separate the error wich seems to be the following.
I'm developing an extension that sends a long message to the client. Because sometime the parameters will vary I made some custom strings that I parse inside the extension.
Somewhere inside the parsing something went wrong.
I'm using the str method for sending the texts.
The code looks something like this
This is where the problem occurs. If I split the params[1] (my second parameter) after a my separator the separator will show up inside the array as an element. Maybe the space is confusing? I don't know .. Maybe you can help on this matter.
If I send a message with a string like "Lapi | SFS | Adrian | goflash"
it will output something like this
[thu_challenge.as]: ppp[0] = Lapi
[thu_challenge.as]: ppp[1] = |
[thu_challenge.as]: ppp[2] = SFS
[thu_challenge.as]: ppp[3] = |
[thu_challenge.as]: ppp[4] = Adrian
[thu_challenge.as]: ppp[5] = |
[thu_challenge.as]: ppp[6] = goflash
Weird.. really weird.
The split actually works when called on a string defined in that function but not when it is recieved a a parameter.
Any insights?
I've been testing for the last half hour and finally managed to separate the error wich seems to be the following.
I'm developing an extension that sends a long message to the client. Because sometime the parameters will vary I made some custom strings that I parse inside the extension.
Somewhere inside the parsing something went wrong.
I'm using the str method for sending the texts.
The code looks something like this
Code: Select all
function handleRequest (cmd, params, user, fromRoom)
{
switch (cmd)
{
case "debug" :
var response = new Array();
// here goes the problem
ppp = params[1].split (" | "); // this is my separator
for (var x = 0;x<ppp.length;x++) {
trace("ppp["+x+"]=" +ppp[x])
}
If I send a message with a string like "Lapi | SFS | Adrian | goflash"
it will output something like this
[thu_challenge.as]: ppp[0] = Lapi
[thu_challenge.as]: ppp[1] = |
[thu_challenge.as]: ppp[2] = SFS
[thu_challenge.as]: ppp[3] = |
[thu_challenge.as]: ppp[4] = Adrian
[thu_challenge.as]: ppp[5] = |
[thu_challenge.as]: ppp[6] = goflash
Weird.. really weird.
The split actually works when called on a string defined in that function but not when it is recieved a a parameter.
Any insights?