What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Interface Writer | [release] 3.0 | 22/08/2010

2 votes - 5 average   Interface Writer | [release] 3.0 | 22/08/2010
Author: Message:
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: Interface Writer | [beta] 1.0
quote:
Originally posted by Matti
Well, you're not implementing our sample code properly. :P
You shouldn't re-enable the control when one item in the loop doesn't match the ID to test simply because you won't have all used IDs matching that one ID, you have to check whether there is at least one match.
js code:
        if (isNaN (objWnd.GetControlText("EdtLeft") * 1) == true || isNaN (objWnd.GetControlText("EdtDown") * 1) == true || isNaN (objWnd.GetControlText("EdtWidth") * 1) == true || isNaN (objWnd.GetControlText("EdtHeight")) == true)
        {
            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnAdd"), 0);
        }
        else
        {
>>>            var bCanChange = true;<<<
>>>            var sEdtId = objWnd.GetControlText("EdtId");<<<
            for (var X in WndLstId)
            {
>>>                if (WndLstId.length > 1 && sEdtId == WndLstId[X] && X == WndLstTStSel)<<<
                    {
>>>                        bCanChange = false;<<<
>>>                        break;<<<
                    }
                }
            }
>>>            Interop.Call("user32", "EnableWindow", objWnd.GetControlHandle("BtnChange"), bCanChange);<<<
        }
As you can see, you don't need an else-block anywhere, you simply check three things:
  1. Check whether there are IDs in the array.
  2. Check whether the currently chosen test ID matches the key name of the current item in the loop.
  3. Check whether this item is currently being edited.
When these three conditions are fulfilled for one item in the loop, we can say that the chosen ID is not unique and thus bCanChange has to be set to false in order to disable the edit button.
When these conditions are never fulfilled, bCanChange will never change from its original value (true) and the button will be enabled.

I have sorted that problem out now, thanks!  :)



quote:
Originally posted by vaccination
...so no one's noticed that it fails at the first hurdle yet?

Script fails to create xml files.

code:
<-- Start file creation. -->
> Attempting to create file "C:\Users\vaccination\Desktop\Windows.xml"...
Error: Object expected (code: -2146823281)
       File: WndWriterCreateFile.js. Line: 70.
Function OnWndWriterCreateFileEvent_CtrlClicked returned an error. Code: -2147352567

Line 70 =
jscript code:
else if (FileC(objWnd.GetControlText("EdtPath") + "\\" + objWnd.GetControlText("EdtName") + ".xml", true))

..FileC doesn't exist...

Ah, sorry.  I originally used a function for that, but I removed it.  I sorted that for the overwrite option, but not for the main writer.  Fixed!  :P

quote:
Originally posted by vaccination
Also, might want to read the corect folder from the registry, or at least use MsgPlus.ScriptFilesPath instead of just assuming it's "\Program Files\Plus!.." because it isn't always, for instance, on x64 machines.

There's a lot of other improvements you could make too, for instance instead of writing the xml to a text file and manually adding all the nodes with TextFile.WriteLine like you are, try using the XML DOM instead.

You should also include a preview feature to make the script actually useful, and should be relatively easy to add in.

Oh and you've used a few Plus! resources in your script - such as imgfind, imgsave, imgcode etc - and still included the files in the package, you could just call the resources directly from Plus!.

I know how to get the script's folder and registry path, but how can I get just the script base directory?



quote:
Originally posted by CookieRevised
Nice idea for a script and it has potential (y)... but...


quote:
Originally posted by Matti
Validation of numbers (for example, it will allow "text" as a valid height measurement)
js code:
var sFoo = "85.1";
var nFoo = 1 * sFoo; //Attempt a string to number conversion
if( isNaN(nFoo) ) nFoo = 0; //Failed, set to some default value or ignore the declaration

You don't need to multiply it with 1.
The next code will work just as good because the function isNaN() will already attempt to convert the variable to a number:
js code:
var sFoo = "85.1";
if( isNaN(sFoo) ) nFoo = 0

In any case, whiz, check your code more carefully so you don't forget crucial stuff or make small mistakes. Although it wouldn't result in a wrong check (because of the above), you forgot to multiply the "EdtHeight" with 1 when you implemented the code posted by Matti:
code:
if (isNaN(objWnd.GetControlText("EdtWidth") * 1) == true || isNaN(objWnd.GetControlText("EdtHeight") * 1) == true)
So in this case you are lucky that you didn't needed the *1 at all, but in other cases such mistakes might result in hard to find bugs...
So, the above line can be written as:
code:
if (isNaN(objWnd.GetControlText("EdtWidth")) || isNaN(objWnd.GetControlText("EdtHeight")))


Fixed.  None of them use it now.  ;)

quote:
Originally posted by CookieRevised
Also:
Remember to take the casing of strings into consideration when you compare strings. Code like:
js code:
for( var i in WndLstId ) {
>>>    if( WndLstId[i] == sTestId ) {<<<
        bIsUniqueId = false;
        break;
    }
}
...will fail if the Id of one control is "BtnTest" and the other control "Btntest".
You must convert the strings to the same casing (eg: lowercase) when comparing.

Even if the control id is case sensitive and using "BtnTest" for one control and "Btntest" for another is allowed, it is still a good idea to still dissallow it in your script because it is not recommended and not good practice and as a result such things _will_ eventually result in errors in the used scripts. So:
js code:
if( WndLstId[i][b].toLowerCase() === sTestId.toLowerCase() ) {
PS: also notice the use of === (is identical) instead of == (is equal). Learn more about the difference here.

Applied to all validators.  Thanks for the tip!  ;)

This post was edited on 06-14-2009 at 02:30 PM by whiz.
05-27-2009 05:37 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Interface Writer | [release] 3.0 | 22/08/2010 - by whiz on 05-25-2009 at 02:55 PM
RE: BETA - Interface Writer 1.0! - by matty on 05-25-2009 at 03:16 PM
RE: BETA - Interface Writer 1.0! - by Spunky on 05-25-2009 at 03:26 PM
RE: Interface Writer | [beta] 1.0 - by whiz on 05-25-2009 at 03:31 PM
RE: BETA - Interface Writer 1.0! - by Matti on 05-25-2009 at 04:02 PM
RE: BETA - Interface Writer 1.0! - by Spunky on 05-25-2009 at 04:07 PM
RE: BETA - Interface Writer 1.0! - by Matti on 05-25-2009 at 04:11 PM
RE: Interface Writer | [beta] 1.0 - by whiz on 05-25-2009 at 05:15 PM
RE: BETA - Interface Writer 1.0! - by Matti on 05-25-2009 at 05:41 PM
RE: BETA - Interface Writer 1.0! - by vaccination on 05-25-2009 at 05:41 PM
RE: BETA - Interface Writer 1.0! - by CookieRevised on 05-25-2009 at 06:24 PM
RE: Interface Writer | [beta] 1.0 - by whiz on 05-27-2009 at 05:37 PM
RE: BETA - Interface Writer 1.0! - by roflmao456 on 05-27-2009 at 06:50 PM
RE: Interface Writer | [release] 1.2 - by whiz on 05-27-2009 at 07:02 PM
RE: BETA - Interface Writer 1.0! - by matty on 05-27-2009 at 07:05 PM
RE: Interface Writer | [release] 1.2 - by whiz on 05-27-2009 at 08:05 PM
RE: BETA - Interface Writer 1.0! - by vaccination on 05-27-2009 at 07:13 PM
RE: Interface Writer | [release] 1.2 - by whiz on 05-27-2009 at 07:45 PM
RE: BETA - Interface Writer 1.0! - by vaccination on 05-27-2009 at 09:28 PM
RE: Interface Writer | [release] 1.2 - by whiz on 05-28-2009 at 03:26 PM
RE: BETA - Interface Writer 1.0! - by vaccination on 05-28-2009 at 03:59 PM
RE: Interface Writer | [release] 1.2 - by whiz on 05-28-2009 at 04:01 PM
RE: BETA - Interface Writer 1.0! - by vaccination on 05-28-2009 at 04:07 PM
RE: Interface Writer | [release] 1.2 - by whiz on 05-28-2009 at 04:12 PM
RE: Interface Writer | [beta] 1.0 -> [release] 1.2 - by mynetx on 06-14-2009 at 03:58 PM
RE: Interface Writer | [release] 1.2 - by whiz on 06-14-2009 at 04:16 PM
RE: Interface Writer | [beta] 1.0 -> [release] 1.2 - by mynetx on 06-14-2009 at 04:56 PM
RE: Interface Writer | [beta] 1.0 -> [release] 1.2 - by SmokingCookie on 06-14-2009 at 05:34 PM
RE: Interface Writer | [beta] 1.0 -> [release] 1.2 - by vaccination on 06-14-2009 at 10:04 PM
RE: Interface Writer | [release] 1.2 - by whiz on 06-15-2009 at 03:16 PM
RE: Interface Writer | [beta] 1.0 -> [release] 1.2 - by SmokingCookie on 06-15-2009 at 04:30 PM
RE: Interface Writer | [release] 1.2 - by whiz on 06-15-2009 at 06:27 PM
RE: Interface Writer | [beta] 1.0 -> [release] 1.2 - by SmokingCookie on 06-15-2009 at 07:51 PM
RE: Interface Writer | [release] 1.2 - by whiz on 06-15-2009 at 08:03 PM
RE: Interface Writer | [beta] 1.0 -> [release] 1.2 - by SmokingCookie on 06-16-2009 at 12:17 PM
RE: Interface Writer | [beta] 1.0 -> [release] 1.2 - by Flippy on 06-17-2009 at 11:47 AM
RE: Interface Writer | [release] 1.2 - by whiz on 06-17-2009 at 06:56 PM
RE: RE: Interface Writer | [release] 1.2 - by SmokingCookie on 06-28-2009 at 07:13 AM
RE: Interface Writer | [beta] 1.0 -> [release] 1.5 - by CookieRevised on 06-22-2009 at 06:11 PM
RE: RE: Interface Writer | [beta] 1.0 -> [release] 1.5 - by whiz on 06-27-2009 at 02:57 PM
RE: Interface Writer | [beta] 1.0 -> [release] 1.5 - by CookieRevised on 06-28-2009 at 01:16 AM
RE: Interface Writer | [release] 1.5 - by whiz on 06-28-2009 at 09:30 AM
RE: Interface Writer | [release] 1.5 - by SmokingCookie on 06-28-2009 at 03:24 PM
RE: Interface Writer | [release] 1.5 - by whiz on 06-29-2009 at 06:31 PM
RE: Interface Writer | [release] 1.5 - by SmokingCookie on 06-29-2009 at 07:12 PM
RE: Interface Writer | [release] 1.5 - by mynetx on 06-30-2009 at 07:31 AM
RE: Interface Writer | [release] 2.0 | 07/11/2009 - by whiz on 11-07-2009 at 01:49 PM
RE: Interface Writer | [release] 2.0 | 07/11/2009 - by mynetx on 11-07-2009 at 02:04 PM
RE: Interface Writer | [release] 2.0 | 07/11/2009 - by whiz on 11-07-2009 at 02:32 PM
RE: RE: Interface Writer | [release] 2.0 | 07/11/2009 - by CookieRevised on 11-07-2009 at 05:43 PM
RE: Interface Writer | [release] 2.0 | 07/11/2009 - by mynetx on 11-07-2009 at 06:28 PM
RE: RE: Interface Writer | [release] 2.0 | 07/11/2009 - by CookieRevised on 11-07-2009 at 11:07 PM
RE: Interface Writer | [release] 2.0 | 07/11/2009 - by whiz on 11-08-2009 at 11:57 AM
RE: Interface Writer | [release] 2.0 | 07/11/2009 - by CookieRevised on 11-08-2009 at 05:56 PM
RE: Interface Writer | [release] 2.0 | 07/11/2009 - by whiz on 11-09-2009 at 06:52 PM
RE: Interface Writer | [release] 2.0 | 07/11/2009 - by CookieRevised on 11-10-2009 at 07:45 AM
RE: Interface Writer | [release] 2.0 | 07/11/2009 - by whiz on 11-10-2009 at 04:14 PM
RE: Interface Writer | [release] 2.2 | 29/11/2009 - by whiz on 11-29-2009 at 05:19 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by whiz on 01-30-2010 at 01:16 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by SmokingCookie on 01-30-2010 at 01:25 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by MeEtc on 01-31-2010 at 02:40 AM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by whiz on 01-31-2010 at 08:48 AM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by whiz on 01-31-2010 at 04:00 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by SmokingCookie on 01-31-2010 at 05:04 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by MeEtc on 02-01-2010 at 12:01 AM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by whiz on 02-02-2010 at 06:34 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by SmokingCookie on 02-10-2010 at 07:32 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by whiz on 02-11-2010 at 08:03 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by SmokingCookie on 02-12-2010 at 08:34 AM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by whiz on 02-12-2010 at 07:41 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by SmokingCookie on 02-13-2010 at 08:49 AM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by whiz on 02-14-2010 at 10:50 AM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by SmokingCookie on 02-14-2010 at 11:01 AM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by whiz on 02-14-2010 at 11:22 AM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by SmokingCookie on 02-14-2010 at 12:53 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by whiz on 02-14-2010 at 01:41 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by SmokingCookie on 02-14-2010 at 01:44 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by whiz on 02-14-2010 at 02:00 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by SmokingCookie on 02-14-2010 at 02:04 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by whiz on 02-14-2010 at 02:12 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by CookieRevised on 02-14-2010 at 04:32 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by whiz on 02-14-2010 at 06:32 PM
RE: RE: Interface Writer | [release] 2.5 | 30/01/2010 - by SmokingCookie on 02-14-2010 at 08:09 PM
RE: Interface Writer | [release] 2.5 | 30/01/2010 - by whiz on 02-16-2010 at 02:57 PM
RE: Interface Writer | [release] 2.7 | 16/02/2010 - by billyy on 02-16-2010 at 04:20 PM
RE: Interface Writer | [release] 2.7 | 16/02/2010 - by whiz on 02-16-2010 at 04:58 PM
RE: Interface Writer | [release] 2.7 | 16/02/2010 - by billyy on 02-16-2010 at 05:55 PM
RE: Interface Writer | [release] 2.7 | 16/02/2010 - by whiz on 02-17-2010 at 08:13 PM
RE: Interface Writer | [release] 2.7 | 16/02/2010 - by billyy on 02-17-2010 at 08:23 PM
RE: Interface Writer | [release] 2.7 | 16/02/2010 - by whiz on 02-18-2010 at 08:57 AM
RE: Interface Writer | [release] 2.7 | 16/02/2010 - by billyy on 02-18-2010 at 08:03 PM
RE: Interface Writer | [release] 2.7 | 16/02/2010 - by whiz on 02-18-2010 at 08:18 PM
RE: Interface Writer | [release] 2.7 | 16/02/2010 - by billyy on 02-18-2010 at 08:21 PM
RE: Interface Writer | [release] 2.7 | 16/02/2010 - by whiz on 02-20-2010 at 11:27 AM
Interface Writer | [beta] 2.8 | 21/02/2010 - by whiz on 02-21-2010 at 05:28 PM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by billyy on 02-21-2010 at 06:20 PM
RE: Interface Writer | [beta] 2.8 | 21/02/2010 - by whiz on 02-21-2010 at 06:38 PM
RE: RE: Interface Writer | [beta] 2.8 | 21/02/2010 - by billyy on 02-23-2010 at 04:14 PM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by SmokingCookie on 02-23-2010 at 10:58 AM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by whiz on 02-23-2010 at 04:05 PM
RE: RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by SmokingCookie on 02-23-2010 at 05:02 PM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by whiz on 02-24-2010 at 06:51 PM
RE: RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by SmokingCookie on 02-24-2010 at 06:57 PM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by whiz on 02-24-2010 at 07:17 PM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by SmokingCookie on 02-24-2010 at 07:20 PM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by whiz on 02-24-2010 at 07:25 PM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by SmokingCookie on 02-24-2010 at 07:30 PM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by billyy on 02-26-2010 at 11:21 PM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by whiz on 02-28-2010 at 10:15 AM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by billyy on 02-28-2010 at 01:05 PM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by whiz on 02-28-2010 at 01:37 PM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by billyy on 02-28-2010 at 01:40 PM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by whiz on 02-28-2010 at 02:53 PM
RE: Interface Writer | [release] 2.7 ~ [beta] 2.8 | 16/02/2010 - by billyy on 02-28-2010 at 02:58 PM
RE: Interface Writer | [beta] 2.8 | 16/02/2010 - by whiz on 03-02-2010 at 03:46 PM
RE: Interface Writer | [release] 2.9 | 10/03/2010 - by whiz on 03-10-2010 at 08:26 PM
RE: Interface Writer | [release] 2.9 | 10/03/2010 - by SmokingCookie on 03-14-2010 at 09:42 AM
RE: Interface Writer | [release] 2.9 | 10/03/2010 - by whiz on 03-14-2010 at 11:11 AM
RE: Interface Writer | [release] 2.9 | 10/03/2010 - by whiz on 05-24-2010 at 08:38 PM
RE: Interface Writer | [release] 2.9 | 10/03/2010 - by SmokingCookie on 05-25-2010 at 07:17 PM
RE: Interface Writer | [release] 2.9 | 10/03/2010 - by matty on 05-25-2010 at 07:32 PM
RE: Interface Writer | [release] 2.9 | 10/03/2010 - by whiz on 05-26-2010 at 06:25 PM
RE: Interface Writer | [beta] 3.0 (+ [release] 2.9) | 17/06/2010 (+ 10/03/2010) - by mynetx on 06-17-2010 at 08:26 AM
RE: Interface Writer | [beta] 3.0 (+ [release] 2.9) | 17/06/2010 (+ 10/03/2010) - by whiz on 06-17-2010 at 08:39 AM
RE: Interface Writer | [beta] 3.0 r2 | 24/07/2010 - by whiz on 07-24-2010 at 04:34 PM
RE: RE: Interface Writer | [beta] 3.0 r2 | 24/07/2010 - by SmokingCookie on 07-25-2010 at 06:53 AM
RE: Interface Writer | [beta] 3.0 r2 | 24/07/2010 - by whiz on 07-25-2010 at 09:46 AM
RE: Interface Writer | [beta] 3.0 r2 | 24/07/2010 - by SmokingCookie on 07-25-2010 at 09:52 AM
RE: Interface Writer | [beta] 3.0 r2 | 24/07/2010 - by whiz on 07-25-2010 at 10:05 AM
RE: Interface Writer | [beta] 3.0 r2 | 24/07/2010 - by SmokingCookie on 07-25-2010 at 04:30 PM
RE: Interface Writer | [beta] 3.0 r2 | 24/07/2010 - by whiz on 07-25-2010 at 04:40 PM
RE: Interface Writer | [beta] 3.0 r2 | 24/07/2010 - by SmokingCookie on 07-25-2010 at 04:44 PM
RE: Interface Writer | [release] 3.0 | 22/08/2010 - by whiz on 08-22-2010 at 03:28 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