Help: - 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: (/showthread.php?tid=70189)
Help: by Wakaki on 01-02-2007 at 01:57 PM
i have a window wich is acceable from the plus menu and i have two editcontrols but i want to let them have a value wich is in an textfile and when it is changed it saves the new line to the text file so like this
you just installed the script
you open the window and the default line is loadded in the EditControl(from a textfile) so you see a text box with the default line
The user then changes the line for another line and clicks a button: save
the old line is deleted from the tectfile and replaced for the new line
then the user reopens the window
and in the textbox now is the new line
i cant seemto figure this out so
plz help mme
p.s.
If you only know a bit of this plz post it
every bit helps
RE: Help: by Spunky on 01-02-2007 at 03:30 PM
If it's acessible from the Plus menu, it'll be using the event:
code: OnEvent_MenuClicked()
Within that event you'll create the interface window (MsgPlus.CreateWnd). Then use:
code: PlusWnd.SetControlText()
The function to read from a text file can be found on these forums, on Google and I'm fairly sure in MSDN (as well as function to save)
Then use:
code: OnWindowIdEvent_CtrlClicked()
and
code: PlusWnd.GetControlText
to save the contents of the text box back to the text file...
Thats the basics. If you need any more help with the functions mentioned here, they are covered in the scripting documentation and possibly on the forum again. If you can not find the functions to Read/Write to a text file (should be really easy btw), I'll post more detail
RE: Help: by Wakaki on 01-02-2007 at 03:47 PM
thank but how should i use
code: PlusWnd.SetControlText()
this is the part that creates the window:
code: function OnGetScriptMenu(Location)
{
var ScriptMenu ="<ScriptMenu>";
ScriptMenu +="<MenuEntry Id=\"window\">Polite Preferences</MenuEntry>";
ScriptMenu +="</ScriptMenu>";
return ScriptMenu;
}
function OnEvent_MenuClicked(MenuId, Location, Wnd)
{
switch(MenuId)
{
case "window":
MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
break;
}
}
so how should i use him there ??? with this default sentence:"hello nice to see you again"
btw the controlid is EdtWelcomeMsg
RE: Help: by Matti on 01-02-2007 at 04:06 PM
You should set a variable (like PlusWnd) which gets the return value of MsgPlus.CreateWnd, like:
code: var PlusWnd = MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
Then, you get the line from the file:
code: var filePath = MsgPlus.ScriptFilesPath + "\\myfile.txt";
var sLine = new ActiveXObject('Scripting.FileSystemObject').GetFile(filePath).OpenAsTextStream(1, -1).ReadLine();
Then, you set the value using SetControlText:
code: PlusWnd.SetControlText("EdtWelcomeMsg", sLine);
RE: RE: Help: by Wakaki on 01-02-2007 at 05:25 PM
quote: Originally posted by Mattike
You should set a variable (like PlusWnd) which gets the return value of MsgPlus.CreateWnd, like:
code: var PlusWnd = MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
Then, you get the line from the file:
code: var filePath = MsgPlus.ScriptFilesPath + "\\myfile.txt";
var sLine = new ActiveXObject('Scripting.FileSystemObject').GetFile(filePath).OpenAsTextStream(1, -1).ReadLine();
Then, you set the value using SetControlText:
code: PlusWnd.SetControlText("EdtWelcomeMsg", sLine);
thank you but it is still not clear how i should use that variable is it like this?
code: function OnGetScriptMenu(Location)
{
var ScriptMenu ="<ScriptMenu>";
ScriptMenu +="<MenuEntry Id=\"window\">Polite Preferences</MenuEntry>";
ScriptMenu +="</ScriptMenu>";
return ScriptMenu;
}
function OnEvent_MenuClicked(MenuId, Location, Wnd)
{
switch(MenuId)
{
case "window":
var filePath = MsgPlus.ScriptFilesPath + "\\myfile.txt";
var sLine = new ActiveXObject('Scripting.FileSystemObject').GetFile(filePath).OpenAsTextStream(1, -1).ReadLine();
var PlusWnd = MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
PlusWnd.SetControlText("EdtWelcomeMsg", sLine)
break;
}
}
i think actually not
but is it then like this
code: function OnGetScriptMenu(Location)
{
var ScriptMenu ="<ScriptMenu>";
ScriptMenu +="<MenuEntry Id=\"window\">Polite Preferences</MenuEntry>";
ScriptMenu +="</ScriptMenu>";
return ScriptMenu;
}
function OnEvent_MenuClicked(MenuId, Location, Wnd)
{
switch(MenuId)
{
case "window":
var=MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
break;
}
function readfileandsetdefault()
{
var filePath = MsgPlus.ScriptFilesPath + "\\myfile.txt";
var sLine = new ActiveXObject('Scripting.FileSystemObject').GetFile(filePath).OpenAsTextStream(1, -1).ReadLine();
var PlusWnd = MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
PlusWnd.SetControlText("EdtWelcomeMsg", sLine)
}
}
RE: Help: by Spunky on 01-02-2007 at 05:40 PM
code: function OnGetScriptMenu(Location)
{
var ScriptMenu ="<ScriptMenu>";
ScriptMenu +="<MenuEntry Id=\"window\">Polite Preferences</MenuEntry>";
ScriptMenu +="</ScriptMenu>";
return ScriptMenu;
}
function OnEvent_MenuClicked(MenuId, Location, Wnd)
{
switch(MenuId)
{
case "window":
var filePath = MsgPlus.ScriptFilesPath + "\\myfile.txt";
var sLine = new ActiveXObject('Scripting.FileSystemObject').GetFile(filePath).OpenAsTextStream(1, -1).ReadLine();
var PlusWnd = MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
PlusWnd.SetControlText("EdtWelcomeMsg", sLine)
break;
}
}
Like that. But you don't need the brackets (show in red)
EDIT: Actually the syntax is wrong there... it needs to be the FileSystemObject where it says filePath and filePath should be passed as a paramater
RE: Help: by Wakaki on 01-02-2007 at 06:14 PM
so like this:?
code: function OnGetScriptMenu(Location)
{
var ScriptMenu ="<ScriptMenu>";
ScriptMenu +="<MenuEntry Id=\"window\">Polite Preferences</MenuEntry>";
ScriptMenu +="</ScriptMenu>";
return ScriptMenu;
}
function OnEvent_MenuClicked(MenuId, Location, Wnd)
{
switch(MenuId)
{
case "window":
var filePath = MsgPlus.ScriptFilesPath + "\\myfile.txt";
var sLine = new ActiveXObject('Scripting.FileSystemObject').GetFile.FileSystemObject(filePath).OpenAsTextStream(1, -1).ReadLine();
var PlusWnd = MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
PlusWnd.SetControlText("EdtWelcomeMsg", sLine)
break;
}
|