Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

String handling; carriage return line feed (new line); 0d0a

$
0
0

Hello, I have a managed WinForms app (Visual Studio 2013, Visual COBOL 2.2) with a TextBox (Multline = True and AcceptsReturn = True) and it is sized to allow entry of multiple lines of text, which may be entered using the Enter key.  I also have the same app except it is done in C#.

As you know, using the Enter key will cause a Carriage Return Line Feed (hex oa0d aka \r\n) pair of characters (non-printable) to be embedded into textBox1::Text wherever the user has entered the Enter key, and this causes any following text to be visually put at the beginning of the next visual line, etc.  You CAN'T see these embedded non-printable characters with a watch on textBox1::Text in the debugger (although you can with C#, what a bummer!).  In any event, I then take the contents of textBox1::Text to a string and pass that string to a third-party app (MS Word, in fact).  When I get the string back from Word, it has been stripped of the Line Feeds characters but the Carriage Return characters are still there.  And I put this string back to textBox1::Text.  So, then, if in C#, if I want to put these back, I just do this (this works):

textBox1.Text = textBox1.Text.Replace("\r", System.Environment.NewLine)  

( or I think textBox1.Text = textBox1.Text.Replace("\r", "\r\n") will work too )

So, you would think in Visual COBOL, I could do this as the equivalent:

set textBox1::Text = textBox1::Text::Replace("\r", type System.Environment::NewLine)

(  or set textBox1::Text = textBox1::Text::Replace("\r", "\r\n")  )

But, it does not work.

I guess it has to do with the way strings are represented / not represented in Visual COBOL vs. other Net languages.

Can you please tell me how to do this in Visual COBOL?

Thanks,

Austin


Viewing all articles
Browse latest Browse all 4356

Trending Articles