What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » New line problem, when \n doesn't work!

New line problem, when \n doesn't work!
Author: Message:
Saki
New Member
*


Posts: 6
Joined: Apr 2009
O.P. Happy  New line problem, when \n doesn't work!
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.

.plsc File Attachment: XMLtest.plsc (6.22 KB)
This file has been downloaded 108 time(s).

This post was edited on 05-02-2009 at 12:09 AM by Saki.
05-01-2009 06:41 PM
Profile E-Mail PM Find Quote Report
ShawnZ
Veteran Member
*****

Avatar

Posts: 3146
Reputation: 43
32 / Male / Flag
Joined: Jan 2003
RE: New line problem, when \n doesn't work!
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>
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.
05-01-2009 08:00 PM
Profile PM Web Find Quote Report
Saki
New Member
*


Posts: 6
Joined: Apr 2009
O.P. RE: RE: New line problem, when \n doesn't work!
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
05-02-2009 12:09 AM
Profile E-Mail PM Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: New line problem, when \n doesn't work!
you could try \r\n as this is what windows prefers...
05-02-2009 11:39 AM
Profile PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: New line problem, when \n doesn't work!
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");
05-05-2009 11:27 AM
Profile 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