Page 1 of 1

Create txt file with line breaks in TI process

Posted: Tue Sep 11, 2012 8:01 pm
by holger_b
Dear forum,

did anybody ever manage to write a .txt file with line breaks in TI? The background of this is, I currently create a status email message which is properly formatted, and I would like to simply store the same text in a flat log file, but asciioutput keeps swallowing the line breaks. I tried it with CHAR(10), CHAR(13) and \n, no success. I also tried ExecuteCommand('cmd /c echo ' | sMessage | ' > filename.txt', 1), but no avail.

I know I could do this with a series of asciioutput commands, but I would much prefer a nicer way... Any hints?

Thank you
Holger

Re: Create txt file with line breaks in TI process

Posted: Tue Sep 11, 2012 9:59 pm
by lotsaram
holger_b wrote:I know I could do this with a series of asciioutput commands, but I would much prefer a nicer way... Any hints?
Multiple ASCIIOutput. 1 ASCIIOUtput = 1 line.

Re: Create txt file with line breaks in TI process

Posted: Wed Sep 12, 2012 7:59 am
by holger_b
Thanks you lotsaram. I did it like this:

Code: Select all

DataSourceASCIIQuoteCharacter = '';
sOutputMsg = sMessage;
nNextLF = SCAN(LF,sOutputMsg);

while( nNextLF > 0 );
   sThisLine = subst( sOutputMsg, 1, nNextLF - 1 );
   asciioutput( sys_log, sThisLine );
   sOutputMsg = subst( sOutputMsg, nNextLF + 1, long( sOutputMsg ));
   nNextLF = SCAN(LF,sOutputMsg);
end;
LF is CHAR(10) btw.

Regards
Holger