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

XML Help...
Author: Message:
Haydn5149
New Member
*


Posts: 3
Joined: Jul 2009
O.P. XML Help...
Im new at XML, and im wondering how i would...  "load" all the lines of a specified .txt file in to an XML ListBoxControl and then "save" all the info back to the .txt file?
07-24-2009 04:46 AM
Profile E-Mail PM Find Quote Report
ryxdp
Senior Member
****


Posts: 804
Reputation: 16
29 / Male / Flag
Joined: Jun 2006
RE: XML Help...
Take a look at the ReadLine() method, which should help you a lot (especially the while loop at the end of the first example) ;)

As for saving it again, see the WriteLine method link in the sidebar.

This post was edited on 07-24-2009 at 06:39 AM by ryxdp.
07-24-2009 06:36 AM
Profile PM Find Quote Report
Haydn5149
New Member
*


Posts: 3
Joined: Jul 2009
O.P. RE: XML Help...
i made this, it reads the file to the end but it returns

code:
Error: 'undefined' is null or not an object (code: -2146823281)
       File: XMLFile.js. Line: 24.
Error: 'undefined' is null or not an object (code: -2146823281)
       File: XMLFile.js. Line: 24.
Error: 'undefined' is null or not an object (code: -2146823281)
       File: XMLFile.js. Line: 24.

Heres the script

code:
function loadItems(PlusWnd)
{
    var filename = (MsgPlus.ScriptFilesPath + '\\processes2.txt')
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var f = fso.OpenTextFile(filename);
    while (!f.AtEndOfStream)
        {
           var readFileLine = f.ReadLine();
           var PIDv = ReadIni(ConfigFile, 'Processes', readFileLine, 0)
           var MSNn = ReadIni(ConfigFile, 'Names', PIDv, 0)
        PlusWnd.LstBox_AddItem('ProcessLBox', readFileLine, pitems + 1);
        PlusWnd.LstBox_AddItem('FileNameLBox', PIDv, nitems + 1);
        PlusWnd.LstBox_AddItem('MSNNameLBox', MSNn, mitems + 1);
        }
    f.Close();
}

Any ideas?

mitems nitems pitems are globals, read and write ini function exists in my script also

This post was edited on 07-24-2009 at 08:48 AM by Haydn5149.
07-24-2009 08:17 AM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: XML Help...
You will need to post the entire XMLFile.js code. Use [code=js][/code] to wrap the code to make it easier to read. With just posting that we have no idea what line 24 is.

However I suspect it is because you are not specifying all of the parameters for OpenTextFile.

js code:
function loadItems(PlusWnd) {
    var filename = (MsgPlus.ScriptFilesPath + '\\processes2.txt')
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var f = fso.OpenTextFile(filename, 0x1 /* ForReading */, false /* Do not create if it doesn't exist */);
    while (!f.AtEndOfStream) {
        var readFileLine = f.ReadLine();
        var PIDv = ReadIni(ConfigFile, 'Processes', readFileLine, 0)
        var MSNn = ReadIni(ConfigFile, 'Names', PIDv, 0)
        PlusWnd.LstBox_AddItem('ProcessLBox', readFileLine, pitems + 1);
        PlusWnd.LstBox_AddItem('FileNameLBox', PIDv, nitems + 1);
        PlusWnd.LstBox_AddItem('MSNNameLBox', MSNn, mitems + 1);
    }
    f.Close();
}
07-24-2009 12:57 PM
Profile E-Mail PM Find Quote Report
Haydn5149
New Member
*


Posts: 3
Joined: Jul 2009
O.P. RE: XML Help...
ok, Heres the full XMLFile.js

its not complete, but im just trying to get it to display the contents when loadFiles(PlusWnd) is called

js code:
var pitems;
var pword;
var nitems;
var nword;
var mitems;
var mword;

function showConfig(PlusWnd)
{
    WndOptions = MsgPlus.CreateWnd("dialogMain.xml", "options");
    loadItems(PlusWnd);
}

function loadItems(PlusWnd)
{
    var filename = (MsgPlus.ScriptFilesPath + '\\processes2.txt')
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var f = fso.OpenTextFile(filename);
    while (!f.AtEndOfStream)
        {
           var readFileLine = f.ReadLine();
           var PIDv = ReadIni(ConfigFile, 'Processes', readFileLine, 0)
           var MSNn = ReadIni(ConfigFile, 'Names', PIDv, 0)
        PlusWnd.LstBox_AddItem('ProcessLBox', readFileLine, pitems + 1);
        PlusWnd.LstBox_AddItem('FileNameLBox', PIDv, nitems + 1);
        PlusWnd.LstBox_AddItem('MSNNameLBox', MSNn, mitems + 1);
        }
    f.Close();
}

function newProcess(PlusWnd)
{
    pitems = PlusWnd.LstBox_GetCount("ProcessLBox");
    pword = PlusWnd.GetControlText('Processes');
    nitems = PlusWnd.LstBox_GetCount("FileNameLBox");
    nword = PlusWnd.GetControlText('FileNames');
    mitems = PlusWnd.LstBox_GetCount("MSNNameLBox");
    mword = PlusWnd.GetControlText('MSNDispNames');
    PlusWnd.LstBox_AddItem('ProcessLBox', pword, pitems + 1);
    PlusWnd.LstBox_AddItem('FileNameLBox', nword, nitems + 1);
    PlusWnd.LstBox_AddItem('MSNNameLBox', mword, mitems + 1);
}

function OnoptionsEvent_CtrlClicked(PlusWnd, ControlId) {
    if (ControlId == "BtnLoad") {
        loadItems(PlusWnd);
    }
    if (ControlId == "BtnSave") {
    }
    if (ControlId == "BtnAdd") {
        newProcess(PlusWnd);
    }
    if (ControlId == "BtnClose") {
        PlusWnd.Close(1)
    }
}

FIXED, i wasnt detecting PlusWnd.LstBox_ as it was loading at the same time as building XML, having it on individual load button works

This post was edited on 07-25-2009 at 07:31 AM by Haydn5149.
07-25-2009 05:39 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