What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » HELP - Searching for "7"?

HELP - Searching for "7"?
Author: Message:
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. HELP - Searching for "7"?
Javascript code:
function OnWndBrowserEvent_CtrlClicked(objWnd, strControlId)
{
    switch (strControlId)
    {
        case "BtnGo":
            if (CmdMode)
            {
                CmdMode = false;
                var Command;
                var Message = objWnd.GetControlText("EdtAddress");
                var Parameter = new Array();
                var SiteM;
                var SArray = new Array();
                SArray = Message.split(" ");
                Message = "";  
                for (SiteM in SArray)
                {
                    switch(SiteM)              
                    {
                        case "0":  
                            Command = SArray[SiteM].toLowerCase();
                        break;
                        default:
                            Parameter[SiteM] = SArray[SiteM].toLowerCase();
                            Message += " " + SArray[SiteM];
                        break;
                    }
                }
                if (Command == "!search")
                {
                    Debug.Trace("> Command received: !search");
                    if (Parameter[2] == undefined)
                    {
                        ParamError();
                    }
                    else if (Parameter[2] == "")
                    {
                        ParamError();
                    }
                    else
                    {
                        if (Parameter[1] == "google")
                        {
                            Search(Parameter[1].length + 1,Parameter[1]);                        }
                        else if (Parameter[1] == "yahoo")
                        {
                            Search(Parameter[1].length + 1,Parameter[1]);                        }
                        else
                        {
                            ParamError();
                        }
                    }
                }
            }
    }
}

Javascript code:
function Search(Term,Engine)
{
    Sound("StartLoad");
    Wnd.setControlText("EdtAddress", Address);
    var URL;
    if (Engine == "google")
    {
        URL = "http://www.google.com/search?q=";
    }
    else if (Engine == "yahoo")
    {
        URL = "http://search.yahoo.com/search?p=";
    }
    Browser.Navigate2(URL + Term);    Debug.Trace("> Searching for query \"" + Term + "\".");}


If I type "!search google test page", the term is from parameter 2 onwards ("test page"), and the search engine is parameter 1 ("google").  However, typing this in results in a Google results page for the term "7".  :S  Similarly, replace "google" with "yahoo", and the term, no matter what is entered, is set to "6".  I've also tried using variables to store the engine/term, but the same happens.  Why?  :^)
03-01-2009 10:23 AM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: HELP - Searching for "7"?
quote:
Originally posted by whiz
Why?  :^)
Do you even read what you're highlighting?
Javascript code:
                        if (Parameter[1] == "google")
                        {
                            Search(Parameter[1].length + 1,Parameter[1]);                        }
                        else if (Parameter[1] == "yahoo")
                        {
                            Search(Parameter[1].length + 1,Parameter[1]);                        }
                        else
                        {

Look what you're sending as your first parameter. What is the result of executing "Parameter[1].length + 1", you think? ...A string? I don't think so. You're taking the length of Parameter[1] ("google" or "yahoo", so 6 or 5) and add 1 to it, resulting in either 7 or 6 - just like you found out.

My guess is that you wanted to get the substring starting at that position, since that's where your search terms start. So, basically, you replace the first two highlighted lines with:
Javascript code:
Search(Message.substr(Parameter[1].length + 1), Parameter[1]);



These are the kind of things a script developer should be able to debug and find the problem by himself... 8-)

This post was edited on 03-01-2009 at 10:38 AM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
03-01-2009 10:37 AM
Profile E-Mail PM Web Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: HELP - Searching for "7"?
...oh, I get it now.  *-)  Thanks.
03-01-2009 10:41 AM
Profile E-Mail PM Find Quote Report
« 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