Shoutbox

Error on length - 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: Error on length (/showthread.php?tid=84865)

Error on length by SnuZZer on 07-16-2008 at 02:07 PM

Hey.

Here I am - again. I don't hope, you feel like I'm spamming the forum or so. The other way around, you choose yourself, if you wanna answer or not.

Anyway.

There's not that much to say. I have the following code:

quote:
function OnWinEvent_LstViewDblClicked(Wnd, Id, Chosen)
{
    var ShowQuote = MsgPlus.CreateWnd("ShowQuote.xml", "WinShow");
    var Breaks = Wnd.LstView_GetItemText("ListView", Chosen, 1).split("\\n");
   
    var LongestBreak = 0;
   
    for(i=0;i<=Breaks.length;i++)
    {
        Debug.Trace(Breaks[i]);
       
        if(LongestBreak < Breaks[i].length)
        {
            LongestBreak = Breaks[i].length;
        }
    }
   
    var Height = 1 * Breaks.length * 11 + 96;
    var Width = 1 * 50 * 5;
   
    ShowQuote.SetControlText("TxtQuote", Wnd.LstView_GetItemText("ListView", Chosen, 1).replace(/\\n/gi, "\r"));
    ShowQuote = Interop.Call("user32.dll", "SetWindowPos", ShowQuote.Handle, 0, 0, 0, Width, Height, 18);
}

And it gives me this error:
quote:
Function called: OnEvent_Initialize
Function called: OnWinEvent_LstViewDblClicked
This neither.
You are right.
It suxx!

Error: 'length' er null eller ikke et objekt (code: -2146823281)
       File: WoWForge Quotes.js. Line: 77.
Function OnWinEvent_LstViewDblClicked returned an error. Code: -2147352567

As you might have figured out, the item, I'm doubleclicking in the list has the following value:
quote:
This neither.\nYou are right.\nIt suxx!

I'm getting my data from this XML-document:
http://www.snuzzer.dk/wowforge/admin-msgplus-xml.php


Please ask, if there's something you don't understand.
RE: Error on length by Spunky on 07-16-2008 at 03:05 PM

You need to split \n not \\n... that is probably returning an empty var (which would not have a length) insted of an array with 0 entries


RE: RE: Error on length by SnuZZer on 07-16-2008 at 03:18 PM

quote:
Originally posted by SpunkyLoveMuff
You need to split \n not \\n... that is probably returning an empty var (which would not have a length) insted of an array with 0 entries

With \n instead of \\n, I get this error:
quote:
Function called: OnEvent_Initialize
Function called: OnWinEvent_LstViewDblClicked
1
This neither.\nYou are right.\nIt suxx!

Error: 'length' er null eller ikke et objekt (code: -2146823281)
       File: WoWForge Quotes.js. Line: 78.
Function OnWinEvent_LstViewDblClicked returned an error. Code: -2147352567

RE: Error on length by Mnjul on 07-16-2008 at 03:28 PM

Try use

for(i=0;i<Breaks.length;i++)

instead of

for(i=0;i<=Breaks.length;i++)


, as there's no Breaks[Breaks.length] (see, there's Break[0] to Break[Breaks.length-1], totaling to Breaks.length items);


RE: RE: Error on length by SnuZZer on 07-16-2008 at 03:41 PM

quote:
Originally posted by Mnjul
Try use

for(i=0;i<Breaks.length;i++)

instead of

for(i=0;i<=Breaks.length;i++)


, as there's no Breaks[Breaks.length] (see, there's Break[0] to Break[Breaks.length-1], totaling to Breaks.length items);

Thanks. It seems to work now.

Okay. What I tried to do is to count number of lines and multiply it with 10 to set the height of the window.
Then I would take the number of characters in the longest line and mulitply it with about five for the width.
It doesn't seem to be a great plan.

Does anybody have an idea, how to make it smarter?