Shoutbox

[HELP] Get/set item text - 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] Get/set item text (/showthread.php?tid=83720)

[HELP] Get/set item text by SmokingCookie on 05-14-2008 at 05:19 PM

Hi,

I have a(nother) question:

"PlusWndObject.LstView_SetItemText" and "PlusWndObject.LstView_SetItemText" don't work..

Code 1 (SET):

code:
for(i = 1; i <= LastNotif; i++) {
D = XmlParser.selectSingleNode("//Notification" + i);
NotificationNames[i] = D.getAttribute("Value");
WndNotifs.LstView_AddItem("LstVNotifs",NotificationNames[i]);
NotificationPages[i] = Script.MainUrl + D.getAttribute("Page");
WndNotifs.LstView_SetItemText("LstVNotifs",i,2,NotificationPages[i]);
}


Code 2 (GET):

code:
nPage = WndNotifs.LstView_GetItemText("LstVNotifs",ItemIdx,2);


"get" returns nothing.. Set does nothing either..

Could anybody please help me?
RE: [HELP] Get/set item text by mynetx on 05-14-2008 at 05:29 PM

Hello SmokingCookie,

try opening the Script Debug window and use the Debug.Trace method to see what is going on. Any errors in the debug window? Also try validating your Window XML, using Interface Tester. Post your results here.

Regards,
mynetx

/edit: please edit your avatar url to point to a valid image rather than to http://img81.imageshack.us/my.php?image=draughtsdx2.jpg ...


RE: [HELP] Get/set item text by SmokingCookie on 05-14-2008 at 05:36 PM

XML is valid (already checked it a thousand times).

nPage returns an empty string (in the debugger).
No errors revealed either..
Please note that in both cases I need the second column from the right.


RE: [HELP] Get/set item text by mynetx on 05-14-2008 at 05:42 PM

Your loop goes from i = 1 to the i = LastNotif.
But the index in the ListView is null-based... so why not try
WndNotifs.LstView_SetItemText("LstVNotifs",i-1,2,NotificationPages[i]);
instead of
WndNotifs.LstView_SetItemText("LstVNotifs",i,2,NotificationPages[i]);
?


RE: [HELP] Get/set item text by SmokingCookie on 05-14-2008 at 05:46 PM

Doesn't matter: I have 3 items to be loaded in the listview conrol, none of them have text in the 2nd collumn..


RE: [HELP] Get/set item text by CookieRevised on 05-14-2008 at 05:53 PM

The row and columns of a listview are base-0.
This means that the first row is row 0 (not row 1) and the first column is column 0 (not column 1).

code:
for(i = 1; i <= LastNotif; i++) {
    D = XmlParser.selectSingleNode("//Notification" + i);
    NotificationNames[i] = D.getAttribute("Value");
    // Adds a new item in the first column (column index 0) and on the next row (which is row with index 0 in the first iteration of the loop, not index 1)
    WndNotifs.LstView_AddItem("LstVNotifs",NotificationNames[i]);
    NotificationPages[i] = Script.MainUrl + D.getAttribute("Page");
    // Yet here you tell Plus! to add data in the third column (index 2) on the second row (index "i"), which doesn't exist yet
    WndNotifs.LstView_SetItemText("LstVNotifs",i,2,NotificationPages[i]);
}
If you want to keep the i variable starting at 1 you must substract 1 from the index for the row and column you whish to set...

Same for GetItemText.

To make it very clear: If you want this kind of list:

Name          Age
----------------------
Jana            25
Chris            19
Kurt             31

You would do:
LstView_AddItem("mylist", "Jana")
LstView_SetItemText("mylist", 0, 1, "25")

LstView_AddItem("mylist", "Chris")
LstView_SetItemText("mylist", 1, 1, "19")

LstView_AddItem("mylist", "Kurt")
LstView_SetItemText("mylist", 2, 1, "31")

and:

LstView_GetItemText("mylist", 0, 0) will return "Jana"
LstView_GetItemText("mylist", 1, 1) will return "19"

RE: [HELP] Get/set item text by SmokingCookie on 05-14-2008 at 05:58 PM

Wow, you guys managed to fix it :D :P

Thanks (again (A) ) :D

EDIT::

That's indeed very clear, thank you very much :D