What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Request] C/C++ Keywords Script

Pages: (2): « First [ 1 ] 2 » Last »
[Request] C/C++ Keywords Script
Author: Message:
Paril
Junior Member
**

Avatar
Admin of Paril's Projects

Posts: 69
31 / Male / Flag
Joined: Jul 2006
O.P. [Request] C/C++ Keywords Script
Hello everyone.

I'm new to the language (Jscript or whatever) that this uses, although I am skilled in C/C++.

Anyways, I want to try and make a plugin and will turn C/C++ keywords blue, comments green, etc.

I just need a starter, such as a code that will just turn one word blue, and I can do the rest.

I came up with this:

code:
function OnEvent_ChatWndSendMessage(pChatWnd, sMessage)
{
    if (sMessage.substr(0,1) == "if")
        sMessage.substr(0,1) = "[c=2]if[/c]";
    return sMessage;
}

but that didn't work.

I also tried..


code:
function OnEvent_ChatWndSendMessage(pChatWnd, sMessage)
{
    if (sMessage == "if")
        sMessage = "[c=2]if[/c]";
    return sMessage;
}

The first one works, but it only works when I say "if" and nothing else.
Any ideas?


-Paril Aughven Kalashnikov

This post was edited on 07-06-2006 at 01:19 AM by Paril.
07-06-2006 01:17 AM
Profile E-Mail PM Web Find Quote Report
Silentdragon
Full Member
***

Avatar
if(life==null && wrists) EmoAlert();

Posts: 148
Reputation: 2
34 / Male / –
Joined: Jun 2006
RE: [Request] C/C++ Keywords Script
sMessage.replace(/if/gi,"[c=2]if[/c]);

Should do most of it for you, comments would need to be done a little different.

This post was edited on 07-06-2006 at 01:26 AM by Silentdragon.
07-06-2006 01:26 AM
Profile E-Mail PM Web Find Quote Report
Paril
Junior Member
**

Avatar
Admin of Paril's Projects

Posts: 69
31 / Male / Flag
Joined: Jul 2006
O.P. RE: [Request] C/C++ Keywords Script
Yeah, I thought of that..
07-06-2006 01:29 AM
Profile E-Mail PM Web Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: [Request] C/C++ Keywords Script
quote:
Originally posted by Paril
The first one works, but it only works when I say "if" and nothing else.

sMessage is the whole message. in the first example, you check if the first letter is "if". in the second, you check if the whole message is "if". use Replace instead.
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
07-06-2006 01:29 AM
Profile PM Web Find Quote Report
Paril
Junior Member
**

Avatar
Admin of Paril's Projects

Posts: 69
31 / Male / Flag
Joined: Jul 2006
O.P. RE: [Request] C/C++ Keywords Script
Sorry for double post, but

That one you put there, doesn't work.

How do I use it?

just like:

function OnEvent_ChatWndSendMessage(pChatWnd, sMessage)
{
    if (sMessage == "if")
    sMessage.replace(/if/gi,"[c=2]if[/c]");
    return sMessage;
}


or what?


I want it to change every "if" that is in the text, not just the first one. Even just

function OnEvent_ChatWndSendMessage(pChatWnd, sMessage)
{
    sMessage.replace(/if/gi,"[c=2]if[/c]");
    return sMessage;
}

doesn't work.
Any ideas?
07-06-2006 01:31 AM
Profile E-Mail PM Web Find Quote Report
Silentdragon
Full Member
***

Avatar
if(life==null && wrists) EmoAlert();

Posts: 148
Reputation: 2
34 / Male / –
Joined: Jun 2006
RE: [Request] C/C++ Keywords Script
sMessage =  sMessage.replace(/if/gi,"[c=2]if[/c]");
07-06-2006 01:42 AM
Profile E-Mail PM Web Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: [Request] C/C++ Keywords Script
quote:
Originally posted by Paril
just like:

Again, think about it logically. sMessage is the _entire message._ You're checking to see if the entire message is equal to "if", which its not.
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
07-06-2006 01:45 AM
Profile PM Web Find Quote Report
Paril
Junior Member
**

Avatar
Admin of Paril's Projects

Posts: 69
31 / Male / Flag
Joined: Jul 2006
O.P. RE: [Request] C/C++ Keywords Script
Yeah, I replied before I saw your first message :(

Thanks Silentdragon, I got it.



But now, what about comments?
For one, // would only comment out the current line, but make the next line back to normal (but see, when MSN breaks lines, that messes it up..)

Or, just turning anything inside "/* */" green.. Possible?


-Paril
07-06-2006 01:48 AM
Profile E-Mail PM Web Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: [Request] C/C++ Keywords Script
you could replace // with Alt0003-3// and replace linefeeds with Alt0003

This post was edited on 07-06-2006 at 01:54 AM by ShawnZ.
Spoiler:
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
07-06-2006 01:53 AM
Profile PM Web Find Quote Report
Paril
Junior Member
**

Avatar
Admin of Paril's Projects

Posts: 69
31 / Male / Flag
Joined: Jul 2006
O.P. RE: [Request] C/C++ Keywords Script
Could you post an example please? I am really no good at Jscript :(
[Sorry for Double Post]

Ok, I finished the part with the blue keywords

Problem is, if I do a text that has one of the keywords in it, it turns that blue, example:

[c=12]int[/c] ;

i =ran[c=12]do[/c]m(1-10); // not real..

[c=12]switch[/c](i)
{
          [c=12]case[/c] 1:
    pr[c=12]int[/c]f ("the number is 1");
          [c=12]break[/c];
          [c=12]case[/c] 2:
    printf ("dfh");
          [c=12]break[/c];
          [c=12]default[/c]:
    [c=12]printf[/c] ("it's not 1 or 2!");
          [c=12]break[/c];
}

Any way to stop it from doing like:

ran[c=12]do[/c]m?

Do I, like, change this

    sMessage = sMessage.replace(/do/gi,"[c=12]do[/c]");

to like

    sMessage = sMessage.replace(/do /gi,"[c=12]do[/c]");

and add a space after the first do, so it makes sure it's not part of current text?

-Paril
07-06-2006 01:59 AM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« 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