![]() [Help] 'undefined' is null or not an object. - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4) +---- Forum: Scripting (/forumdisplay.php?fid=39) +----- Thread: [Help] 'undefined' is null or not an object. (/showthread.php?tid=85929) [Help] 'undefined' is null or not an object. by Timma on 09-14-2008 at 04:22 AM
code: Just a few things first, textray is an array formed by str.split(" ");, text is a blank predefined variable and str is the message typed in. I get the error "'undefined' is null or not an object." on the lines with substring on them. What I was trying to do here, if you can't see it, is reverse the words, and if a word is a link, don't reverse it. The problems only started when I began to use the array. I just used the string before. Say if you do need more of the script. If it's easier for you, you can just rewrite the code ![]() RE: [Help] 'undefined' is null or not an object. by Matti on 09-14-2008 at 01:30 PM
Change the <= to a = in your for() loops. That should do it. RE: [Help] 'undefined' is null or not an object. by Timma on 09-15-2008 at 09:31 AM Alright, I did that. And it seems to crash my MSN whenever someone sent me a message. RE: [Help] 'undefined' is null or not an object. by pollolibredegrasa on 09-15-2008 at 10:34 AM
quote:Change that line to either code:or code: Array.length gives the number of items +1, so when it reaches this number in the loop you've come to an array item that doesn't exist, hence the 'undefined' error. At least, that's my understanding of it ![]() Hope this helps ![]() RE: [Help] 'undefined' is null or not an object. by Jesus on 09-15-2008 at 11:20 AM
quote:it does not. (well, in some specific cases it does, but not in this case) quote: Because Timma's textray is made by using string.split(), it is a contiguous array. In this case textray.length gives you the exact number of elements in the array textray. The reason textray[textray.length] does not exist, is because the elements counter is zero-based, whereas textray.length is not. example: If you have a string of only one word as input, string.split(" ") will return an array (textray) with only 1 element. this element is stored in textray[0], but textray.length will be 1. RE: [Help] 'undefined' is null or not an object. by Timma on 09-16-2008 at 05:51 AM
So do I implement a check for if it's one word? code: Or just use that code? RE: [Help] 'undefined' is null or not an object. by Jesus on 09-16-2008 at 09:34 AM you can use that code |