string on a new line (I/O file)

YudinEdYudinEd Posts: 90
var sPath = FileDialog.doFileDialog(false);file = new DzFile( sPath );file.open( file.WriteOnly );var str1="1th string";var str2="\n 2th string";file.writeLine(str1+str2);file.close();

 

Hi! Why  does not work \n ? How can I write a string on a new line?

Post edited by YudinEd on

Comments

  • Works for me. Are you perhaps using a text editor that requires a carriage return and a line feed for a new line to view the output?

  • YudinEdYudinEd Posts: 90
    edited September 2017

    Thanks for answer.   I did use the Notepad and the Wordpad (default text editors in Windows 7) - it don't work :(

    Post edited by YudinEd on
  • It worked in TextPad - Notepad is quite limited.

  • SimonJMSimonJM Posts: 5,982
    edited September 2017

    Using Win7 Pro I it works, partially.

    Viewing in Notepad I see:

    1th string  2th string

    (when I C/P that in here I get the linefeed)

    Viewing in Wordpad I see:

    1th string
     2th string

    Smacks very much of what Richard says - Windows 'wants' crlf (\r\n) as a 'proper' end of line, and if I add a \r immediately before the \n and re-run then Notepad does show the linefeed.

     

     

     

    Post edited by SimonJM on
  • YudinEdYudinEd Posts: 90
    edited September 2017

    Thanks. \r\n is fine working. In Notepad too :) 

     

    var sPath = FileDialog.doFileDialog(false);file = new DzFile( sPath );file.open( file.WriteOnly );var str1="1th string\r\n";var str2=" 2th string";file.writeLine(str1+str2);file.close();

     

    Post edited by YudinEd on
Sign In or Register to comment.