What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Error on length

Error on length
Author: Message:
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. Error on length
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.
07-16-2008 02:07 PM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: Error on length
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
<Eljay> "Problems encountered: shit blew up" :zippy:
07-16-2008 03:05 PM
Profile PM Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: RE: Error on length
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
07-16-2008 03:18 PM
Profile E-Mail PM Web Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: Error on length
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);

This post was edited on 07-16-2008 at 03:29 PM by Mnjul.
07-16-2008 03:28 PM
Profile PM Web Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: RE: Error on length
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?
07-16-2008 03:41 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On