Sign in to follow this  
Followers 0
Vorbis

Carriage Return/Line Feed in Structured Text

5 posts in this topic

I wrote a Function Block with Structured Text. Within that I write a string to a Text File using the TEXT_WRITE command. So far it works just fine. But I would like to add an Carriage Return/Line Feed (like hitting the "Return" Key on the Keyboard). The "W447-E1-10 CX-Programmer Operation Manual" tells me to simply write '$n' to the end of a line. But that just doesnt work.

Share this post


Link to post
Share on other sites
Hello Vorbis Can you post your line of code? I have used WRITE_TEXT like this... write_text(MyTextHere,Filename,'$N1',0); Note the $N1. Can't remember where I found this! Good luck in the world cup Paraffin 'Rooney' Power Edited by ParaffinPower

Share this post


Link to post
Share on other sites
My code (which I reduced to test) at the Moment is: Text:='test'; Filename:='\ename'; WRITE_TEXT(Text, Filename, '$N', 0); Mhh, strange. I just wanted to paste what I see in the Textfile. The strange thing is, the Fast Reply Window of the Forum gives me a line break where I see two squares in notepad. So probably my code was ok all the time but maybe notepad preferences are somehow strange? When I open it with WordPad or ConTEXT Editor it has two linebreaks, so I tried '$N1' but that resulted in the same, no linebreak but squares in notepad and two linebreaks in ConTEXT and WordPad. Does anybody know why notepad is giving me squares while other programms give me linebreaks? And why two linebreaks? Two linebreaks are better than none, but if possible i'd like to get it to giving me just one linebreak. Thanks for help and wishing us luck for the world cup, Paraffin Power, but it seems as if we don't need luck, we got skill ;) Vorbis

Share this post


Link to post
Share on other sites
Now I'm confused even more. If you insert the "$N" into the String instead of the third parameter of the WRITE_FILE command it works perfectly. It shows just one Linebreak in NotePad as well as other Text editors. Text:='one$Ntwo$N'; Filename:='\Filename'; WRITE_TEXT(Text, Filename, '', 0); Creates a Textfile with: This is all so confusing... they definately need to enhance Structured Text Programming. Vorbis

Share this post


Link to post
Share on other sites
And another update on that subject that might be interesting for others. This didn't do what I expected it to do: Text:=CONCAT(Text,'$N'); WRITE_TEXT(Text, Filename, '', 0); Whereas the following code writes "Text" into the File and adds an Line Break at the end. But, again, that File is displayed wrong in NotePad but correctly in WordPad and (most important to me) Excel. LineBreak:='$N'; Text:=CONCAT(Text,LineBreak); WRITE_TEXT(Text, Filename, '', 0); I wonder whether it's just strange or it's me not getting the point.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0