Shoutbox

Why does Plus! parse sent messages twice? - 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: WLM Plus! General (/forumdisplay.php?fid=23)
+----- Thread: Why does Plus! parse sent messages twice? (/showthread.php?tid=75961)

Why does Plus! parse sent messages twice? by matty on 07-08-2007 at 09:18 PM

It appears that Plus! parses messages twice. How come?

For instance if you have this code:

code:
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage){
    Debug.Trace(sMessage);
}

If the sent message is (!VER) command we all know that Plus! will convert that the the version information.

However if you have this code:

code:
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage){
    Debug.Trace(sMessage);
    return oChatWnd.EditText.replace(/\(!VER\)/g, '(!VER)\nthis is a test');
}

You would expect that the returned message should be
(!VER)
this is a test

However it isn't Plus! will parse the message again after that function is complete.

Plus! should, in all reality, only parse the message after each script has completed that function if it exists. This will save CPU cycles.

I know it isn't visible to the naked eye or can't appear to be taking any more time to parse twice but it makes the poor CPU work that much harder.
RE: Why does Plus! parse sent messages twice? by Patchou on 07-08-2007 at 11:37 PM

the message is parsed again if modified so that script developers can use commands and tags like (!VER). I doubt it makes any difference to anybody's computer :).


RE: Why does Plus! parse sent messages twice? by matty on 07-08-2007 at 11:49 PM

Ok well why parse it a first time? Why not only parse it once? sMessage should be the unparsed string you shouldn't have to read the EditText to get the unparsed string.


RE: Why does Plus! parse sent messages twice? by Patchou on 07-09-2007 at 04:18 AM

this is by design and it's meant to work like that. As you said, you can already get the unparsed text from the edit text value.


RE: Why does Plus! parse sent messages twice? by markee on 07-09-2007 at 01:59 PM

I think the unparsed text is VERY useful to the user and if anything should be what is there rather than what the script puts out as that is what the user typed to make it work, just like a command.

I realise there is the (!T) thing, but lets make an example as if a script did this instead.

User types:

code:
The current time here is (!T)

Output sent:
code:
The current time here is 11:54:32 PM

The second line is already redundant as (!T) is dynamic against the time and it has already past (unless you were to repeat yourself in an exact multiple of 24hours from that time afterwards).  The first line however is very critical to make it easier to show again and is more useful to both parties as it is the current and not the past.

This related to anything that is subject to time (in any form) or has some in built mechanism to not repeat itself.  This also has consequences in the likes of Message Customizer! Live because of the compounding colours (which would just build up again an again).  Therefore, for the ease of the user, I really think the script output should be removed completely as this is not the text they wrote or the command they executed.
RE: Why does Plus! parse sent messages twice? by Volv on 07-09-2007 at 02:16 PM

markee, that's not true. It's a bit like the principle which was brought up before where when you type /nick (!T) you want it to show the time at which you typed the command rather than the time at which you look at your nickname... I believe that all of MsgPlus's default commands should override anything which scripts do, especially tags like (!T) which are placed into the message to indicate the current time.

As Patchou already said, if you really want to "you can already get the unparsed text from the edit text value."


RE: Why does Plus! parse sent messages twice? by CookieRevised on 07-10-2007 at 12:20 AM

Texts need to be parsed again. Remember that your script isn't the only script which is running (probably)...

Your script can output something which another script on its turn needs to change or parse or whatever.

Hence, when your script outputs something differently, it is only logical that it is again send to all the scripts again.

That you might end up with a buildup of tags is the fault of the script developper (to say it in a crude way). It is the responsebility of the programmer to make his script parsing and changing messages in a proper way.

imho