What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » DLL function detection (?) + weird error

DLL function detection (?) + weird error
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: DLL function detection (?) + weird error
The problem with your code is that you call "e.moveNext()" at the beginning of your loop. This means that it'll start off by index 1 in the Enumerator object and will go past the end. Thus, you're actually missing the first contact and then you go past the end of the enumeration, giving you that "empty object" error. :)

In fact, there's an even better way to do this. Instead of using your numeric "i" variable in your for-loop, you can do the checks with the Enumerator and let the "i" variable increase with it. You don't even need to put it at the end of the loop yourself, you can place in the incremental statement by separating it with a comma from the "e.moveNext()"! And you can also do the same to define both the "i" and "e" variables! :P

This can give you code as short as this:
code:
for(var e = new Enumerator(Messenger.MyContacts), i = 0; !e.atEnd(); e.moveNext(), i++) {
Contact = e.item();
EmailArray[i] = Contact.Email;
WndEmail.Combo_AddItem("Email",Contact.Email);
}

Red = initial statement
Green = conditional statement
Blue = incremental statement
Just to show you how much you can simplify a piece of JScript by pushing it to the limits... :)

This post was edited on 04-14-2008 at 04:16 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
04-14-2008 04:13 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
DLL function detection (?) + weird error - by SmokingCookie on 04-13-2008 at 05:14 PM
RE: DLL function detection (?) + weird error - by ShawnZ on 04-13-2008 at 05:52 PM
RE: RE: DLL function detection (?) + weird error - by SmokingCookie on 04-13-2008 at 06:00 PM
RE: DLL function detection (?) + weird error - by ShawnZ on 04-13-2008 at 06:03 PM
RE: DLL function detection (?) + weird error - by SmokingCookie on 04-13-2008 at 06:07 PM
RE: DLL function detection (?) + weird error - by felipEx on 04-13-2008 at 08:30 PM
RE: DLL function detection (?) + weird error - by matty on 04-14-2008 at 11:44 AM
RE: DLL function detection (?) + weird error - by SmokingCookie on 04-14-2008 at 02:52 PM
RE: DLL function detection (?) + weird error - by Matti on 04-14-2008 at 04:13 PM
RE: DLL function detection (?) + weird error - by SmokingCookie on 04-14-2008 at 04:19 PM
RE: DLL function detection (?) + weird error - by Matti on 04-14-2008 at 04:40 PM
RE: DLL function detection (?) + weird error - by SmokingCookie on 04-14-2008 at 04:47 PM


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