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

Pages: (14): « First « 1 [ 2 ] 3 4 5 6 » Last »
2 votes - 5 average   Interface Writer | [release] 3.0 | 22/08/2010
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: BETA - Interface Writer 1.0!
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")))


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.

----

The above are all small details but can make a very big difference. So, a very big tip: before adding new stuff and/or features, revise your entire script very carefully as it contains many (small but crucial) errors and potential bugs, like vaccination already said.

;)

This post was edited on 05-25-2009 at 06:50 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
05-25-2009 06:24 PM
Profile PM Find Quote Report
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
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
RE: BETA - Interface Writer 1.0!
Looks interesting..
* roflmao456 tries it out

edit: neat (Y)

This post was edited on 05-27-2009 at 06:53 PM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
05-27-2009 06:50 PM
Profile PM Web Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: Interface Writer | [release] 1.2
Thanks!  ;)

Note to all: please post any bugs or errors you encounter!  :)

This post was edited on 06-14-2009 at 02:30 PM by whiz.
05-27-2009 07:02 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: BETA - Interface Writer 1.0!
How about some screenshots.
05-27-2009 07:05 PM
Profile E-Mail PM Find Quote Report
vaccination
Veteran Member
*****

Avatar

Posts: 2513
Reputation: 43
32 / Male / –
Joined: Apr 2005
RE: BETA - Interface Writer 1.0!
Um...

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


----

quote:
Originally posted by whiz
I know how to get the script's folder and registry path, but how can I get just the script base directory?

I don't think you read my post correctly, you read the registry* to get the script folders path. [or alternatively, if you get the current script folder path from msgplus.scriptfilefolder then just use substr(-<whatever>) to minus the unnecessary part.]

*hklm\software\patchou\messenger plus! live\scriptsdir

----

Also, you're *still* packing plus resources in the script that you can just call from Plus!.

This post was edited on 05-27-2009 at 07:17 PM by vaccination.
[Image: jumbled.png]
05-27-2009 07:13 PM
Profile PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: Interface Writer | [release] 1.2
quote:
Originally posted by vaccination
Um...

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



I think I have fixed that now (I will re-upload the file in a moment)...

quote:
Originally posted by vaccination
quote:
Originally posted by whiz
I know how to get the script's folder and registry path, but how can I get just the script base directory?

I don't think you read my post correctly, you read the registry* to get the script folders path. [or alternatively, if you get the current script folder path from msgplus.scriptfilefolder then just use substr(-<whatever>) to minus the unnecessary part.]

*hklm\software\patchou\messenger plus! live\scriptsdir

So can I use "MsgPlus.ScriptFilesPath", and then remove the "\Interface Writer"?

quote:
Originally posted by vaccination
Also, you're *still* packing plus resources in the script that you can just call from Plus!.

I have removed unnecessary images from the directory, and replaced them in the Windows.xml file with the Messenger Plus! image versions.  Some, like the add/delete button images, I have left as-is because they're from the Windows Live Messenger resource extraction - they look better.  ;)

This post was edited on 06-14-2009 at 02:31 PM by whiz.
05-27-2009 07:45 PM
Profile E-Mail PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: Interface Writer | [release] 1.2
quote:
Originally posted by matty
How about some screenshots.

Done.  ;)  Click here...

This post was edited on 06-28-2009 at 09:37 AM by whiz.
05-27-2009 08:05 PM
Profile E-Mail PM Find Quote Report
vaccination
Veteran Member
*****

Avatar

Posts: 2513
Reputation: 43
32 / Male / –
Joined: Apr 2005
RE: BETA - Interface Writer 1.0!
quote:
Originally posted by whiz

quote:
Originally posted by vaccination
quote:
Originally posted by whiz
I know how to get the script's folder and registry path, but how can I get just the script base directory?

I don't think you read my post correctly, you read the registry* to get the script folders path. [or alternatively, if you get the current script folder path from msgplus.scriptfilefolder then just use substr(-<whatever>) to minus the unnecessary part.]

*hklm\software\patchou\messenger plus! live\scriptsdir

So can I use "MsgPlus.ScriptFilesPath", and then remove the "\Interface Writer"?

Precisely. (Or a better way would be to just read the registry value IMO but whatever =p)
[Image: jumbled.png]
05-27-2009 09:28 PM
Profile PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: Interface Writer | [release] 1.2
quote:
Originally posted by vaccination
Precisely. (Or a better way would be to just read the registry value IMO but whatever =p)

Then how do you do that?  ;)

This post was edited on 06-14-2009 at 02:31 PM by whiz.
05-28-2009 03:26 PM
Profile E-Mail PM Find Quote Report
Pages: (14): « First « 1 [ 2 ] 3 4 5 6 » Last »
« 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