Shoutbox

newb @ work... - 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: newb @ work... (/showthread.php?tid=63623)

newb @ work... by ins4ne on 07-19-2006 at 06:56 PM

help me guys :( i just created some code from the scripting documentations and modified a bit. now i got a menu when i click the plus symbol in the contactlist. but when i click on feature 1, 2 or advanced feature 1, 2 a window pops up that should only popup for "about"...

code:
<ScriptInfo xmlns="urn:msgplus:scripts" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:msgplus:scripts PlusScripts.xsd">

<Information>
<Name>Test Script</Name>
</Information>

<ScriptMenu>
<MenuEntry Id="MnuFeat1">Feature 1</MenuEntry>
<MenuEntry Id="MnuFeat2">Feature 2</MenuEntry>

<SubMenu Label="Advanced">
<MenuEntry Id="MnuAdvFeat1">Advanced Feature 1</MenuEntry>
<MenuEntry Id="MnuAdvFeat2">Advanced Feature 2</MenuEntry>
</SubMenu>

<Separator/>
<MenuEntry Id="MnuAbout">About...</MenuEntry>
</ScriptMenu>

</ScriptInfo>

code:
function OnEvent_MenuClicked(MnuAbout)
{
var Wnd = MsgPlus.CreateWnd("Window.xml", "WndTest");
}

function OnWndTestEvent_CtrlClicked(Wnd, ControlId)
{
if(ControlId == "BtnClose") Wnd.Close(1);
}

whats my problem? i forgot something?
RE: nwwb @ work... by absorbation on 07-19-2006 at 07:02 PM

code:
if(ControlId == "BtnClose") {
Wnd.Close(1);
}
You had to add { to tell the script what to do if ControlId was BtnClose :).
RE: nwwb @ work... by Stigmata on 07-19-2006 at 07:02 PM

code:
function OnEvent_MenuClicked(MnuAbout)
{
var Wnd = MsgPlus.CreateWnd("Window.xml", "WndTest");
}

function OnWndTestEvent_CtrlClicked(Wnd, ControlId)
{
if(ControlId == "BtnClose"){ Wnd.Close(1); }
}

RE: nwwb @ work... by Pai on 07-19-2006 at 07:02 PM

You did, and you didn't :P You did remember to *check* if the ID pressed was MnuAbout, but you did it the wrong way.

It should be like this:

code:
function OnEvent_MenuClicked(IdClicked)
{
if (IdClicked == "MnuAbout") var Wnd = MsgPlus.CreateWnd("Window.xml", "WndTest");
}



edit: guys, that's not what he asked :P And he can use
code:
if(ControlId == "BtnClose") Wnd.Close(1);
without any problems, as long as it is one single statement...
RE: nwwb @ work... by ins4ne on 07-19-2006 at 07:06 PM

aaaaaaaaaah thx Pai :) it works now... just like i said newb @work. but one day i will code myself without errors :)


RE: nwwb @ work... by ins4ne on 07-19-2006 at 07:33 PM

sorry for double post but editing the previous would be a bit weird... so my new problem...

code:
function OnEvent_MenuClicked(IdClicked)
{
if (IdClicked == "MnuAbout")
var Wnd = MsgPlus.CreateWnd("Window.xml", "WndTest");
}

function OnWndTestEvent_CtrlClicked(Wnd, ControlId)
{
if(ControlId == "BtnOK"){ Wnd.Close(1); }
}

function OnEvent_MenuClicked(IdClicked)
{
if (IdClicked =="MnuToast")
var Message = "Hello";
MsgPlus.DisplayToast("", Message);
}

some conflicts... the same as my first problem... click all menus, always empty toasts. only menu toast gives me message Hello!
RE: nwwb @ work... by Silentdragon on 07-19-2006 at 07:44 PM

You can only have one MenuClicked event. You need to do all the work in that one event. And if statements without {} only work for the next line. So do this

code:
function OnWndTestEvent_CtrlClicked(Wnd, ControlId)
{
        if(ControlId == "BtnOK"){ Wnd.Close(1); }
}

function OnEvent_MenuClicked(IdClicked)
{
        if (IdClicked == "MnuAbout") var Wnd = MsgPlus.CreateWnd("Window.xml", "WndTest");
        else if (IdClicked =="MnuToast") {
                  var Message = "Hello";
                  MsgPlus.DisplayToast("", Message);
        }
}

Btw you also wrote ass instead of as.
RE: nwwb @ work... by ins4ne on 07-19-2006 at 07:47 PM

ok... so i wasnt very far away... i tried a bit on my own so take a look

code:
function OnEvent_MenuClicked(IdClicked)
{
if (IdClicked == "MnuAbout")
var Wnd = MsgPlus.CreateWnd("Window.xml", "WndTest");
if (IdClicked == "MnuToast")
var Message = "Hello";
MsgPlus.DisplayToast("", Message);
}

i wrote that before i read your post Silentdragon...

EDIT: i hope i dont annoy you by asking all this things :(
RE: nwwb @ work... by ins4ne on 07-19-2006 at 08:46 PM

sorry again for double post but whats the problem in this

code:
function OnSoundEvent_CtrlClicked(Wnd, ControlId)
{
if (ControlId == "BtnPlay")
var Message = "Sound not playing! Learn about MsgPlus.PlaySound! :P";
MsgPlus.DisplayToast("", Message, "notify.wav");
}
else if (ControlId == "BtnClose"){ Wnd.Close(1); }

and show me how to play and stop a sound...
RE: nwwb @ work... by Pai on 07-19-2006 at 09:15 PM

The problem is that you have to include the { } s in an if statement, except if you only want one line of code executed.

For clearing up:

code:
if (condition == "whatever") DoStuff('hello');
code:
if (condition == "whatever") {
   var doWhat = 'hello';
   DoStuff(doWhat);
}

So, your code should be:
code:
function OnSoundEvent_CtrlClicked(Wnd, ControlId)
{
    if (ControlId == "BtnPlay") {
        var Message = "Sound not playing! Learn about MsgPlus.PlaySound! :P";
        MsgPlus.DisplayToast("", Message, "notify.wav");
   }

    if (ControlId == "BtnClose") Wnd.Close(1);

}

To play the sound then the toast is displayed, notify.wav must be on your script's directory.

If you want to play a sound when you want (ie without being when the toast fires up) you use MsgPlus.Playsound('sound.wav'); and sound.wav must be in your script's directory. If you want to play a sound outside the script's directory, use "\" before. Example: "\C:\sound.wav".
RE: nwwb @ work... by ins4ne on 07-20-2006 at 03:25 PM

so guys... newb is back :'(... i got the same code as yesterday but today a bit modified. so i got that idea ;) its only for scripting training and meuh... dont talk about it, isnt very  important... so now my problem

code:
function OnEvent_MenuClicked(IdClicked)
{
if (IdClicked == "MnuAbout")
var Wnd = MsgPlus.CreateWnd("About.xml", "About");
else if (IdClicked == "MnuToast")
{
var Message == "Hello " + Messenger.MyName + ":)";
MsgPlus.DisplayToast("", Message, "notify.wav");
}
else if (IdClicked == "MnuSound")
var Wnd = MsgPlus.CreateWnd("Sound.xml", "Sound");
}
else if (IdClicked == "MnuGoogle")
var Wnd = MsgPlus.CreateWnd("Google.xml", "Google");
}

I got error on line 7...
quote:
Originally posted by Scriptdebugger
Fehler: ';' erwartet.
       Zeile: 7. Code: -2146827284.

RE: nwwb @ work... by RaceProUK on 07-20-2006 at 03:38 PM

I don't mean to sound rude, but do you ever read your own code? You've missed a brace yet again! These are things that reading your own code will pick up!
Forget it, the brace was ghiding behind the code tag you didn't close properly.


RE: newb @ work... by ins4ne on 07-20-2006 at 03:46 PM

what do you mean by that? where's the fault? make it bold please.
so where is the problem in that piece of code?


RE: newb @ work... by BstrdSmkr on 07-20-2006 at 05:38 PM

the problem is here:

var Message == "Hello " + Messenger.MyName + "(Smilie)";
MsgPlus.DisplayToast("", Message, "notify.wav");

it needs to be:

var Message = "Hello " + Messenger.MyName + "(Smilie)";
MsgPlus.DisplayToast("", Message, "notify.wav");

"==" is used to see if two things are already equal.  "=" is used to make one thing equal to another.

some times your request for help gets lost in the sea of other requests ;)   hope that helps!


RE: newb @ work... by ins4ne on 07-20-2006 at 05:40 PM

oh dear... i will never get that... "==" is not "="... :'( thx anyway :)

EDIT: still an error... says in line 4 must be a ";" added...


RE: newb @ work... by BstrdSmkr on 07-20-2006 at 06:28 PM

ok, show what you have so far.


RE: newb @ work... by ins4ne on 07-20-2006 at 06:30 PM

sorry... youre abit too late. markee helped me on WLM... he said "=" for variables and "==" when i want to say that something is equal another thing :). everything works nice now.


RE: newb @ work... by Ezra on 07-20-2006 at 06:31 PM

Please READ your code... There are soo much errors :S

code:
function OnEvent_MenuClicked(MnuId)
{
  switch(MnuId)
  {
    case "MnuAbout":
      var Wnd = MsgPlus.CreateWnd("About.xml", "About");
      break;
    case "MnuToast":
      var Message = "Hello " + Messenger.MyName + ":D";
      MsgPlus.DisplayToast("Title", Message, "notify.wav");
      break;
    case "MnuSound":
      var Wnd = MsgPlus.CreateWnd("Sound.xml", "Sound");
      break;
    case "MnuGoogle":
      var Wnd = MsgPlus.CreateWnd("Google.xml", "Google");
      break;
  }
}

Also it's more usefull to use a switch instead of lots of else if.

And there is no real use in using so much xml files, just use one and put all the windows in there.
RE: newb @ work... by ins4ne on 07-20-2006 at 06:35 PM

ok. if you explain me how to do that i will :)