Shoutbox

what is wrong with this script? - 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: what is wrong with this script? (/showthread.php?tid=71098)

what is wrong with this script? by Wakaki on 01-27-2007 at 04:53 PM

code:
//global variables:   
        var fsObj = new ActiveXObject("Scripting.FileSystemObject");
        var fileObj = fsObj.OpenTextFile(MsgPlus.ScriptFilesPath + '\\defwelcomemsg.txt', 1);
        var DefWelcomemsg = fileObj.ReadAll();
        fileObj.Close();
       
        var fsObj2 = new ActiveXObject("Scripting.FileSystemObject");
        var fileObj2 = fsObj2.OpenTextFile(MsgPlus.ScriptFilesPath + '\\defgoodbyemsg.txt', 1);
        var DefGoodbyemsg = fileObj2.ReadAll();
        fileObj2.Close();
       

//functions
function OnEvent_Initialize(MessengerStart)
{

}

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 PlusWnd = MsgPlus.CreateWnd( 'windows_new.xml', 'Polite', 0 );
        PlusWnd.SetControlText("EdtWelcomeMsg", DefWelcomemsg)
        PlusWnd.SetControlText("EdtGoodbyeMsg", DefGoodbyemsg)
       
        break;
    }
       
}



function OverwriteFile (file, content)
{
        var fileObj4 = new ActiveXObject("Scripting.FileSystemObject").OpenTextFile(MsgPlus.ScriptFilesPath + '\\' + file, 2, 0);
        fileObj4.Write(content);
        fileObj4.Close();
}

function OnPoliteEvent_CtrlClicked(PlusWnd, CtrlId) {
if(CtrlId == "Btnlol") {
OverwriteFile("defwelcomemsg.txt", PlusWnd.GetControlText("EdtWelcomeMSg"));
OverwriteFile("defgoodbyemsg.txt", PlusWnd.GetControlText("EdtGoodbyeMsg"));

}
}


function OnEvent_Signin(Email)
{
     var Message = DefWelcomemsg;
     MsgPlus.DisplayToast("Hello", Message);

}
function OnEvent_Signout(Email)
{
    var Message = DefGoodbyemsg;
     MsgPlus.DisplayToast("Goodbye", Message);
}


function OnEvent_Uninitialize(MessengerExit)
{
}



it doesn;t work
RE: what is wrong with this script? by deAd on 01-27-2007 at 04:55 PM

What exactly doesn't work about it?


RE: what is wrong with this script? by foaly on 01-27-2007 at 04:55 PM

could you be a bit more specific? for example: what doesn't work..
or show us the debug output...


RE: what is wrong with this script? by Wakaki on 01-27-2007 at 05:24 PM

edit:i fixed it but now there is another problem

my save button doesn;t work


RE: what is wrong with this script? by Eljay on 01-27-2007 at 05:35 PM

Does "defwelcomemsg.txt" actually contain anything? That error means youre trying to read an empty file.


RE: what is wrong with this script? by Wakaki on 01-27-2007 at 05:38 PM

code:
function OnPoliteEvent_CtrlClicked(PlusWnd, CtrlId) {
if(CtrlId == "Btnlol") {
OverwriteFile("defwelcomemsg.txt", PlusWnd.GetControlText("EdtWelcomeMSg"));
OverwriteFile("defgoodbyemsg.txt", PlusWnd.GetControlText("EdtGoodbyeMsg"));

}



this function doesn;t work:S

this is my window xml file:

code:
<?xml version="1.0" encoding="UTF-16" ?>
- <Interfaces xmlns="urn:msgplus:interface" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:msgplus:interface PlusInterface.xsd">
- <GlobalColors>
- <GlobalColor Id="green">
  <Red>80</Red>
  <Green>200</Green>
  <Blue>65</Blue>
  <Alpha>220</Alpha>
  </GlobalColor>
- <GlobalColor Id="bg">
- <BaseColor>
  <Saturation>2</Saturation>
  <Brightness>0.6</Brightness>
  <Transparency>82</Transparency>
  </BaseColor>
  </GlobalColor>
  </GlobalColors>
- <Window Id="Polite" Version="1">
- <Attributes>
  <Caption>Windows Live Messenger</Caption>
  </Attributes>
- <TitleBar>
- <Title>
  <Text>Preferences</Text>
  </Title>
  </TitleBar>
  <Position Width="475" Height="155" />
  <DialogTmpl />
- <Controls>
- <Control xsi:type="StaticControl" Id="LblTop">
  <Position Top="9" Width="404" Left="80" Height="20" />
  <Transparency>180</Transparency>
  <Caption>Fill the fields below in if you want to change youre Welcome or Goodbye message:</Caption>
  </Control>
- <Control xsi:type="StaticControl" Id="LblWelcomeMsg">
  <Position Top="35" Width="112" Left="9" />
  <Caption>Current Welcome message:</Caption>
  </Control>
- <Control xsi:type="EditControl" Id="EdtWelcomeMsg">
  <Position Top="35" Width="300" Left="100" />
  </Control>
- <Control xsi:type="StaticControl" Id="LblGoodbyeMsg">
  <Position Top="70" Width="112" Left="9" />
  <Caption>Current Goodbye message:</Caption>
  </Control>
- <Control xsi:type="EditControl" Id="EdtGoodbyeMsg">
  <Position Top="70" Width="300" Left="100" />
  </Control>
- <Control xsi:type="ButtonControl" Id="BtnCancel">
  <Position Left="400" Top="100" Width="50" />
  <Caption>Close</Caption>
  </Control>
- <Control xsi:type="ButtonControl" Id="Btnlol">
  <Position Left="330" Top="100" Width="50" />
  <Caption>Save</Caption>
  </Control>
  </Controls>
  </Window>
  </Interfaces>