Shoutbox

New line problem, when \n doesn't 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: New line problem, when \n doesn't work! (/showthread.php?tid=90465)

New line problem, when \n doesn't work! by Saki on 05-01-2009 at 06:41 PM

Hi all
I have a problem when I already read messages from XML file.
Each messages combined multi-sentence and "\n" to tell messages go to new line. Then I will send that messages to chat window. The result does not make new line like I planed.

Here is my XML file sample (test.xml)
<root>
    <node>Hello, I saw you continuely online more than 60 minutes.\nPlease take a little time to break for your good healthy.\nI'm also apologize for this interupt, this is testing</node>
    <node>bra bra...2 \nbra bra..</node>
    <node>bra bra...3 \nbra bra..</node>
    <node>bra bra...4 \nbra bra..</node>
</root>


Here is my code
function OnEvent_Initialize(MessengerStart)
{
    var Email = "sakpong@live.com";
        var file     = MsgPlus.ScriptFilesPath+"\\test.xml";
    var rootXML = XMLNewRequest(file);
    var aMsg = rootXML.childNodes.item(0);

    var bMsg = "Hello, I saw you continuely online more than 60 minutes.\nPlease take a little time to break for your good healthy.\nI'm also apologize for this interupt, this is testing";

    Messenger.OpenChat(Email).EditText_ReplaceSel(aMsg));
}


Here is chat window's result from case that aMsg is read from XML.
Hello, I saw you continuely online more than 60 minutes.\nPlease take a little time to break for your good healthy.\nI'm also apologize for this interupt, this is testing

Here is chat window's result from case that bMsg is string variable.
This result is I want it be. But I can't fixed all data in script like this case.
Hello, I saw you continuely online more than 60 minutes.
Please take a little time to break for your good healthy.
I'm also apologize for this interupt, this is testing


I try to use String()'s function with aMsg but it's still not work.
Someone help me please.

Thank you so much.

Also I attached this test script, but code still be confuse. Because it's in testing and many dummy functions are in code. Also XML data mostly represent in Thai language.


RE: New line problem, when \n doesn't work! by ShawnZ on 05-01-2009 at 08:00 PM

why not just do this?

    <node>Hello, I saw you continuely online more than 60 minutes.
Please take a little time to break for your good healthy.
I'm also apologize for this interupt, this is testing</node>


RE: RE: New line problem, when \n doesn't work! by Saki on 05-02-2009 at 12:09 AM

quote:
Originally posted by ShawnZ
why not just do this?

    <node>Hello, I saw you continuely online more than 60 minutes.
Please take a little time to break for your good healthy.
I'm also apologize for this interupt, this is testing</node>


Arr..., Thanks ShanwZ.
The solution is not I expected, but it work. :)
Sadly, I must go back to edit all data in XML. :S

RE: New line problem, when \n doesn't work! by NanaFreak on 05-02-2009 at 11:39 AM

you could try \r\n as this is what windows prefers...


RE: New line problem, when \n doesn't work! by SmokingCookie on 05-05-2009 at 11:27 AM

The point is: Notepad shows you "\n", but Windows makes it "a backslash followed by small N". In other word, what seems to be "\n", is actually "\\n". You may replace that sort of stuff using a RegExp:

JScript code:
new RegExp("\\n","gim");