What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Caching which windows have a command enabled

Caching which windows have a command enabled
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Caching which windows have a command enabled
It's not an array, it's a regular object.
quote:
Originally posted by matty
JScript code:
// Declare an object to hold our ChatWindows
var oChatWnds = {};


Basically, you're not defining an element in a zero-based numerical indexed array, you're setting an object property of a regular object. If you were going to use:
JScript code:
var oChatWnds = [];

and then set and delete the 1053th element, yes, then you'd be wasting memory and processing time. But here, we only define one object property which simply happens to have a numeric property name - no problems at all.

JavaScript is very lax at such kind of stuff, unlike C++ where you can't make arrays with mixed element types. Compare JavaScript's object creation (like in this example) with extending an empty class: you start with nothing and add stuff in it. You won't create more properties in the class than you want (compared to JavaScript arrays), there's no length property or not-enumerable methods like push and slice. You simply extend an empty object. :)

quote:
Originally posted by MrPickle
Would this be acceptable.
...
This would mean you wouldn't have massive gaps but you'd have to loop through the chats.
Correct, but it's much faster and efficient to have them indexed by handle in an object than looping through an array and checking the Handle property. Also, in your example code, there's no way to get access to the ChatWnd object itself through the array, however it could be you simply forgot that. :P
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
11-19-2008 12:44 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Caching which windows have a command enabled - by MrPickle on 11-18-2008 at 08:14 PM
RE: Caching which windows have a command enabled - by matty on 11-18-2008 at 08:52 PM
RE: Caching which windows have a command enabled - by MrPickle on 11-18-2008 at 09:39 PM
RE: Caching which windows have a command enabled - by Spunky on 11-18-2008 at 10:37 PM
RE: Caching which windows have a command enabled - by MrPickle on 11-18-2008 at 10:48 PM
RE: Caching which windows have a command enabled - by matty on 11-18-2008 at 11:07 PM
RE: Caching which windows have a command enabled - by MrPickle on 11-18-2008 at 11:19 PM
RE: Caching which windows have a command enabled - by Spunky on 11-19-2008 at 01:17 AM
RE: Caching which windows have a command enabled - by MrPickle on 11-19-2008 at 08:25 AM
RE: Caching which windows have a command enabled - by Matti on 11-19-2008 at 12:44 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