Problems figuring out how to write file, etc

I’m having problems figuring out the file-plugin.
Everything works fine except for that little extra…

I’m writing a text file from a string variable. The text file is created and is ok.
I also keep a copy of the file in a BOLB field in the db.

This is where I’m having problems!
If I store the string I loose all the new line characters ‘\n’!?
If I store a file, when I try to open it I have the same problem (no newline chars)!

I’ve tried, the binary approach, without success:

// Writing
// sourceFile is path to good file
f_field = plugins.file.readFile(sourceFile); // store in bin format

//...
// reading
var fname = 'C:\\temp\\export.txt';
plugins.file.writeFile( fname,  f_field);
application.executeProgramInBackground('notepad.exe', fname);

I’ve also tried the TXT way, also loosing the newline chars:

/ Writing
// sourceFile is path to good file
f_field = tempText; // store contents of string var
//...
// reading
var fname = 'C:\\temp\\export.txt';
plugins.file.writeTXTFile( fname,  f_field);
application.executeProgramInBackground('notepad.exe', fname);

Any hints to put me on the right track?

Txs,
Miguel

Have you tried to open the file in something else but Notepad? On Windows, line breaks are different and notepad does not handle conversion right.

Hi Miguel,

maybe you can try replacing “\n” with “\r\n” before exporting it to file

\n = new line
\r = carriage return

patrick:
Have you tried to open the file in something else but Notepad? On Windows, line breaks are different and notepad does not handle conversion right.

It’s true I had realized that with Wordpad I didn’t have that problem.

automazione:
Hi Miguel,

maybe you can try replacing “\n” with “\r\n” before exporting it to file

\n = new line
\r = carriage return

I tried that when it came to my mind that windoze has different line termination chars (linux and mac are also different).

Like this all works fine.

Thanks for the help Enrico and Patrick,
Miguel

for windows there is a fantastic free TextEditor called: Notepad++
http://notepad-plus.sourceforge.net/nl/site.htm

Hope this helps