What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Save to XML

Pages: (2): « First [ 1 ] 2 » Last »
Save to XML
Author: Message:
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. Save to XML
Hi.
I'm from Denmark and my english isn't good, but i'll try and hope that you undertand :-D
I try to make a script which can auto-answer message, with a message the user have choosed, but i can't find out how to save the users settings in a XML-document as i later can get the settings again and use them.

I save the users settings in a variable here and now I will put the settings into a XML-document:
code:
function OnWndMainEvent_CtrlClicked(Wnd, Handling)
{
    switch(Handling)
    {
        case "knap_tilfoej":
            var Navn = Wnd.GetControlText("input_navn");
            var Modtaget = Wnd.GetControlText("input_modtaget");
            var Svar = Wnd.GetControlText("input_svar");
            break;
        case "knap_luk":
            Wnd.Close(1);
            break;
    }
}

Thanks in advance
Simon
10-29-2006 04:16 PM
Profile E-Mail PM Web Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
30 / Male / Flag
Joined: Apr 2006
Status: Away
RE: Save to XML
[Help!] Writing to XML files
10-29-2006 04:23 PM
Profile E-Mail PM Web Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Save to XML
Hi.
When i click on "knap_tilfoej" and try to save the settings nothing happens. It doesn't close the window and it doesn't save the settings.
Here is the script:
code:
function OnWndMainEvent_CtrlClicked(Wnd, Handling)
{
    switch(Handling)
    {
        case "knap_tilfoej":
            var Navn = Wnd.GetControlText("input_navn");
            var Modtaget = Wnd.GetControlText("input_modtaget");
            var Svar = Wnd.GetControlText("input_svar");
           
            var xml = new ActiveXObject("Microsoft.XMLDOM");
            xml.load("indstillinger.xml");
            var toAdd = xml.createElement("Navn");
            toAdd.appendChild(xml.createTextNode(Navn));
            xml.getElementsByTagName("Navn")[0].appendChild(toAdd);
            xml.save("indstillinger.xml");
            break;
        case "knap_luk":
            Wnd.Close(1);
            break;
    }
}
10-29-2006 04:36 PM
Profile E-Mail PM Web Find Quote Report
Plan-1130
Full Member
***

I keep askin' myself: why?

Posts: 142
73 / Male / –
Joined: Feb 2005
RE: Save to XML
xml.load("indstillinger.xml");
xml.save("indstillinger.xml");

I guess you need to insert the full path, like
MsgPlus.ScripFilesPath + "\\indstillinger.xml"
My Scripts: UltimatFlooder, Advanced PSM Chat, PlusPrivacy, PlusRemote

[Image: Plan-1130.png]
10-29-2006 07:47 PM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: Save to XML
unlikely... It should use a file in the local folder...
<Eljay> "Problems encountered: shit blew up" :zippy:
10-29-2006 09:44 PM
Profile PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: Save to XML
quote:
Originally posted by SnuZZer
Hi.
When i click on "knap_tilfoej" and try to save the settings nothing happens. It doesn't close the window and it doesn't save the settings.
Here is the script:

The window will not close unless you click on "knap_luk", which you didn't.

Also, try using full paths in the xml.load and xml.save.

Is there anything in the debug window when you do this?
10-29-2006 10:48 PM
Profile PM Find Quote Report
Plan-1130
Full Member
***

I keep askin' myself: why?

Posts: 142
73 / Male / –
Joined: Feb 2005
RE: Save to XML
quote:
Originally posted by SpunkyLoveMuff
unlikely... It should use a file in the local folder...
Which is the My Documents folder and i found that very unlikely to put an XML file...

Btw, if you want to close the window after saving the file (when it works) remove break;
code:
function OnWndMainEvent_CtrlClicked(Wnd, Handling)
{
switch(Handling)
{
case "knap_tilfoej":
var Navn = Wnd.GetControlText("input_navn");
var Modtaget = Wnd.GetControlText("input_modtaget");
var Svar = Wnd.GetControlText("input_svar");

var xml = new ActiveXObject("Microsoft.XMLDOM");
xml.load("indstillinger.xml");
var toAdd = xml.createElement("Navn");
toAdd.appendChild(xml.createTextNode(Navn));
xml.getElementsByTagName("Navn")[0].appendChild(toAdd);
xml.save("indstillinger.xml");
// Removed the break; here
case "knap_luk":
Wnd.Close(1);
break;
}
}


This post was edited on 10-30-2006 at 01:14 PM by Plan-1130.
My Scripts: UltimatFlooder, Advanced PSM Chat, PlusPrivacy, PlusRemote

[Image: Plan-1130.png]
10-30-2006 01:09 PM
Profile E-Mail PM Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Save to XML
Hi.
Now I have tried with MsgPlus.ScripFilesPath + "\\indstillinger.xml" but I can't get it work.

Heres my code:
code:
function OnWndMainEvent_CtrlClicked(Wnd, Handling)
{
    switch(Handling)
    {
        case "knap_tilfoej":
            var Sti = MsgPlus.ScriptFilesPath + "\\indstillinger.xml";
            var Navn = Wnd.GetControlText("input_navn");
            var Modtaget = Wnd.GetControlText("input_modtaget");
            var Svar = Wnd.GetControlText("input_svar");

            var xml = new ActiveXObject("Microsoft.XMLDOM");
            xml.load(Sti);
            var toAdd = xml.createElement("Navn");
            toAdd.appendChild(xml.createTextNode(Navn));
            xml.getElementsByTagName("Navn")[0].appendChild(toAdd);
            xml.save(Sti);
            Wnd.Close(1);
            break;
        case "knap_luk":
            Wnd.Close(1);
            break;
    }
}

And here is my XML-document (indstillinger.xml)
code:
<?xml version="1.0" encoding="UTF-8"?>
<Indstillinger>
</Indstillinger>
10-30-2006 02:31 PM
Profile E-Mail PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Save to XML
Can you please tell us what the debugger says? It gives important information about the error! ;)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
10-30-2006 03:10 PM
Profile E-Mail PM Web Find Quote Report
SnuZZer
Full Member
***

Avatar

Posts: 114
32 / Male / Flag
Joined: Jun 2006
O.P. RE: Save to XML
Hi.
When i open a script the debugger doesn't popup, isn't that the meaning?
I have checked the checkbox.
10-30-2006 04:49 PM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » 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