What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » WLM Plus! Bug Reports » RemoveFormatCodes

RemoveFormatCodes
Author: Message:
Noixe
Junior Member
**


Posts: 25
– / Male / Flag
Joined: Jul 2008
O.P. RemoveFormatCodes
Hello,

I have create a simple function to see the result of RemoveFormatCodes:

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MsgKind) {

    MsgPlus.DisplayToast("Test", ("abcdefghi" == MsgPlus.RemoveFormatCodes(Message)));

                MsgPlus.DisplayToast("Test",  MsgPlus.RemoveFormatCodes(Message));


                           
}

But when I  receive message colored with my script "Random Gradiator" (using Bidirectional Gradation mode), the result of first toast window is "false":

For example, i write:

abcdefghi

it was sent with format code and i see it with color but in the second toast window I see:

abcd    efghi


I have tried to write manually the code generated by Random Gradiator :

MyMsg = "[.b][c=1]abcd[/c=2][c=2]efghi[/c=1][/b.]"

MsgPlus.DisplayToast("Test",  MsgPlus.RemoveFormatCodes(MyMsg));

but in this way the message printed is correct (without spaces).


This is a function used by script to insert color codes:

msg1 = Messaggio.substr(0, Messaggio.length / 2);
msg2 = Messaggio.substr(Messaggio.length / 2);

return BIU_a[form] + "[c=" + c1 + "]" + msg1 + "[/c=" + c2 + "]" +
                            "[c=" + c2 + "]" + msg2 + "[/c=" + c1 + "]" + BIU_c[form];

where c1 and c2 are a numbers

BIU_a is an array with the open tag: [.b], [.i], [.u], etc...

BIU_c is an array with the close tag: [/b.], [/i.], [/u.], etc..

if you want see the source you can download it from:

http://www.msgpluslive.it/scripts/view/429-Random-Gradiator

Thanks

P.S.: I have add the dots in the tag to make it visible.


This post was edited on 08-17-2008 at 12:01 PM by Noixe.
08-17-2008 11:57 AM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: RemoveFormatCodes
Why do the tags have periods in them?
<Eljay> "Problems encountered: shit blew up" :zippy:
08-17-2008 03:54 PM
Profile PM Find Quote Report
Noixe
Junior Member
**


Posts: 25
– / Male / Flag
Joined: Jul 2008
O.P. RE: RE: RemoveFormatCodes
quote:
Originally posted by SpunkyLoveMuff
Why do the tags have periods in them?

What's periods?

The dots?
08-17-2008 04:36 PM
Profile E-Mail PM Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
30 / Male / Flag
Joined: Apr 2006
Status: Away
RE: RemoveFormatCodes
quote:
Originally posted by SpunkyLoveMuff
Why do the tags have periods in them?
quote:
Originally posted by Noixe
P.S.: I have add the dots in the tag to make it visible.




quote:
Originally posted by Noixe
quote:
Originally posted by SpunkyLoveMuff
Why do the tags have periods in them?

What's periods?

The dots?
Yes, the dots.

And yea, displaying it as "abcd    efghi" is really weird. What is the exact string that you get when the message is sent? "[b][c=1]abcd[/c=2][c=2]efghi[/c=1][/b]"? Or something different?
08-17-2008 04:46 PM
Profile E-Mail PM Web Find Quote Report
Noixe
Junior Member
**


Posts: 25
– / Male / Flag
Joined: Jul 2008
O.P. RE: RemoveFormatCodes
I send: abcdefghi
and the result is false.

But if I assign the value in this way:

MyMsg = "[.b][c=1]abcd[/c=2][c=2]efghi[/c=1][/b.]"

MsgPlus.DisplayToast("Test",  MsgPlus.RemoveFormatCodes(MyMsg));

The result is correct, without spaces.

If you want, you can try with Random Gradiator the same thing.

You must choose "Bidirectional gradation".

The function can't remove the format code of string received from message.

Bye
08-17-2008 08:47 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RemoveFormatCodes
Nice catch... (aka: confirmed)

However the bug is not in the RemoveFormatCodes() function. This function acts like it should.

---

The bug is actually how the sMessage parameter is passed to the OnEvent_ChatWndReceiveMessage() event.

If [c=1]abcdef[/c] was received, it will be passed with all the tag characters being replaced by spaces:
(note that the bold tags don't matter, neither does it matter if you use a gradient or not or multiple color tags)


  send: [c=1]abcdef[/c]
passed: _____abcdef____



So your variable sMessage in MsgPlus.RemoveFormatCodes(sMessage) will already be "_____abcdef____" (thus without any tags). And of course its output is exactly the same as there are no tags to replace to begin with.

Example code to reproduce it
code:
function OnEvent_ChatWndReceiveMessage(oChatWnd, sOrigin, sMessage, nMsgKind) {
    Debug.Trace(sMessage);
}

of course, the underscores being used in this post (_) represent spaces ;)
.-= A 'frrrrrrrituurrr' for Wacky =-.
08-17-2008 10:07 PM
Profile PM Find Quote Report
Noixe
Junior Member
**


Posts: 25
– / Male / Flag
Joined: Jul 2008
O.P. RE: RemoveFormatCodes
I have tried it and I have see the same output, but I wanted knew also your opinion.

Is not strange this behaviour of sMessage parameter?

However, a solution could be apply a trim function at all substring.

Bye
08-18-2008 09:11 AM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RemoveFormatCodes
Yep, very strange behaviour.

And also very strange that this bug wasn't noticed before with all those scripts using the OnEvent_ChatWndReceiveMessage().... Especially since the bug exists since the first Plus! Live versions.
.-= A 'frrrrrrrituurrr' for Wacky =-.
08-18-2008 05:22 PM
Profile PM Find Quote Report
Noixe
Junior Member
**


Posts: 25
– / Male / Flag
Joined: Jul 2008
O.P. RE: RemoveFormatCodes
Maybe because only Random Gradiator make a massive use of color codes :)

Bye
08-18-2008 08:10 PM
Profile E-Mail PM Find Quote Report
« 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