Shoutbox

HELP : Need a solution to load messages to jscript. - 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: HELP : Need a solution to load messages to jscript. (/showthread.php?tid=90437)

HELP : Need a solution to load messages to jscript. by Saki on 04-30-2009 at 06:53 AM

Hello everyone

I am new for jscript, I am developing a program (script) to send a auto message to my friends, whom stay online for too long. I mean, I will notice them for take a little break from computer online.

Now my script almost complete just left in a part of load data (nice and worm messages) for send it out.

I try to search for this solution for a week but still no exactly I want.

In my idea, I think to prepare messages in local XML file (same directory of the script), then open and load it to script array, then random select them to send out. I looking the way to do this work.

I hope will has someone show me an answer in a sample XML file that contain messages. Also a script to load and random select their message in array to display.

Thank you so much for your help.
Sakpong (Thailand)

ps. I also attached my (modified) script. In case you need to understand more in my idea.


Dear everyone

I'm looking in Tips's topic(http://shoutbox.menthix.net/showthread.php?tid=56747). I feel I am found a solution (Reading the contents of a file) in there. It's seem not to hard. Next I must separate it to array.
I will try to implement it and will tell the result soon.

Sorry to annoy you. The solution is seem to very closely but I am looking in wrong places.

But if someone have any good suggestions, please. I always open for your opinion.

Thank you so much.
RE: HELP : Need a solution to load messages to jscript. by Saki on 04-30-2009 at 09:49 AM

Dear everyone

This problems are still on.  :(

I try (some tips from http://shoutbox.menthix.net/showthread.php?tid=56747&page=1)

    code :
    var msgFile    = MsgPlus.ScriptFilesPath+"\\Messages.xml";
    function file_exists(file)
    {
       return new ActiveXObject("Scripting.FileSystemObject").FileExists(file);
    }
    -----------------------------------------------------------------------------------

and

    code :
    -----------------------------------------------------------------------------------
    function get_file_contents(file)
    {
        var fileSys = new ActiveXObject("Scripting.FileSystemObject");
        var fileH = fileSys.OpenTextFile(file, 1, 0);
        var text = fileH.ReadAll();
        fileH.close();
        return text;
    }
    -----------------------------------------------------------------------------------

Both function is work fine to load plain text file, but not work to parse XML file. If I change to prepare messages in text file, I still have problems in parser data. Because one message can be either one sentence or more sentences. That maybe a new problem to split messages to array.

Then I try (XML request) next one, even I don't know what are output should be.

// -------------------------------------------------------------------
// XML request
function NewRequest(service)
{
    xmlFile = service;
    Debug.Trace("Calling: "+xmlFile);
    var xml = new ActiveXObject("MSXML2.DOMDocument.4.0");
    xml.validateOnParse = false;
    xml.async = false;
    xml.load(xmlFile);
    var resp = xml.documentElement;
   
    return resp;
}
// -------------------------------------------------------------------

But I found an error. They say cannot to create obj from
var xml = new ActiveXObject("MSXML2.DOMDocument.4.0");

Because I am very new in XML, I not sure about XML structure.
I don't know how to parse information out.

Please help me! please give me some basic samples will be very kindness.

Thanks


RE: HELP : Need a solution to load messages to jscript. by Spunky on 04-30-2009 at 12:04 PM

The ".4.0" specifies a version of the ActiveXObject to use, although you may not have it. try removing it and seeing if you getany results from just "MSXML2.DOMDocument"


RE: HELP : Need a solution to load messages to jscript. by Saki on 04-30-2009 at 02:50 PM

Thank you Spunky so much. :D

It's done. Script modified follow your advice work very well.
Now I can continue coding.

Thank Thank Thank:D