Shoutbox

DevPlus - script testing/debug add-on... - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: DevPlus - script testing/debug add-on... (/showthread.php?tid=97770)

DevPlus - script testing/debug add-on... by whiz on 06-07-2011 at 08:24 AM

A little something I wrote to help me with testing certain things in scripts.

The ZIP folder has two files - DevPlus.js and DevPlus.xml.  Place both files in the root of the script you want to use it with, then reload the script.  A toolbar will appear in the top-right corner of the screen.

This is not a script!  Although it works on its own, it won't do much - you add it to your own script (but take it out when publishing scripts).

[Image: kBUw0.png]

From left to right: test script menu, test menu click, view script commands, test sent messages, toggle script debug, code evaluator.

If a button's not enabled, then you haven't got the corresponding function declared in your script (e.g. the first button requires OnGetScriptMenu() to be declared).

You can control how DevPlus starts.  At the bottom of the script file is the line DevPlus.Start().  By default, this will start DevPlus with Messenger.  You can change this by moving the line elsewhere (for example, triggered by a menu click or command, or just to startup using OnEvent_SigninReady() instead.

Bug, glitch, suggestion or problem?  Report here!  :)

Current version: 1.01


RE: DevPlus - script testing/debug add-on... by matty on 06-07-2011 at 04:45 PM

Interesting, this is a very good concept. I am curious of other features you could add to it.


RE: DevPlus - script testing/debug add-on... by whiz on 08-02-2011 at 07:05 PM

I'm considering adding a kind of variable lookup option, so you can enter a global variable name, and it'll give you an output of what it is (like print_r in PHP), and maybe some sort of window monitor (but this will need me to extend the MsgPlus::CreateWnd function - can this be done?).  Any other suggestions welcome.


RE: DevPlus - script testing/debug add-on... by Matti on 08-03-2011 at 09:02 AM

quote:
Originally posted by whiz
I'm considering adding a kind of variable lookup option, so you can enter a global variable name, and it'll give you an output of what it is (like print_r in PHP)
Good luck with that. I haven't found a proper method to retrieve or modify the global scope so far, I'd like to see what you come up with. In JavaScript (in a browser), you have the window object which contains the global scope but there's no such thing in JScript (as an application script).
quote:
Originally posted by whiz
and maybe some sort of window monitor (but this will need me to extend the MsgPlus::CreateWnd function - can this be done?).
I seriously doubt it. Plus! objects (MsgPlus, Messenger, PlusWnd,...) aren't regular objects, they're interfaces. They don't have a prototype  or constructor as regular JScript objects have.
RE: DevPlus - script testing/debug add-on... by whiz on 08-03-2011 at 01:07 PM

quote:
Originally posted by Matti
quote:
Originally posted by whiz
I'm considering adding a kind of variable lookup option, so you can enter a global variable name, and it'll give you an output of what it is (like print_r in PHP)
Good luck with that. I haven't found a proper method to retrieve or modify the global scope so far, I'd like to see what you come up with. In JavaScript (in a browser), you have the window object which contains the global scope but there's no such thing in JScript (as an application script).
Would it be possible to use eval (probably not the best method, but I don't see much else that can be used here):
js code:
var foo = 3; // declared globally

/* inside variable lookup events */
var variable = "foo"; // variable name as collected from user
var type = eval("typeof(" + variable + ")");
var value = eval(variable);
switch (type)
{
    case "undefined":
        return false; // does not exist
    case "string":
    case "number":
    case "boolean":
        return type + "|" + value; // just return value
    case "object":
        // iterate through properties, etc.
}
Of course, wouldn't use local variables here, since if they were searched for, then the local values would be returned.

Edit: have got this working, it seems, using a try/catch for if it exists or not.
Edit (again): it's got some object iteration too.  Here's an example:
js code:
[true, "hello", [1, 2, 3], 4, null]
code:
Type: object

[0] => (boolean) true
[1] => (string) hello
[2] => object...
--> [0] => (number) 1
--> [1] => (number) 2
--> [2] => (number) 3
[3] => (number) 4
[4] => null

quote:
Originally posted by Matti
quote:
Originally posted by whiz
and maybe some sort of window monitor (but this will need me to extend the MsgPlus::CreateWnd function - can this be done?).
I seriously doubt it. Plus! objects (MsgPlus, Messenger, PlusWnd,...) aren't regular objects, they're interfaces. They don't have a prototype  or constructor as regular JScript objects have.
I guess it could be done by adding calls to a DevPlus function when creating a window, but that's kinda messy (the whole point of this is that you just add the files without having to modify a script to support the debugging stuff...).  I'll have to see what I can come up with.
RE: DevPlus - script testing/debug add-on... by whiz on 08-22-2011 at 07:03 PM

I've noticed a potential issue with the script file...

Plus! loads files in alphabetical order, and, assuming you have DevPlus set-up as default to show as soon as the file is loaded, it checks for the existance of menu/command event handlers straight away.  So if they're in a file that comes alphabetically after DevPlus, they won't get detected.

The way round this is to rename the DevPlus file to something with a load of Z's at the start (or a NBSP, as I'm using), to ensure it loads last.  Or, you could just move the Start() function line to the initialize function of your script.  But yeah, otherwise it's not a problem...