By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,894 Members | 2,002 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,894 IT Pros & Developers. It's quick & easy.

console project question

P: n/a
sgr
Is there any way to do that C# always writes in the same line of the console?
Oct 2 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
sgr wrote:
Is there any way to do that C# always writes in the same line of the
console?
Use a carriage return:

Console.Out.Write( "\r" + TextToWrite );

Cleaning the line for previous output is left as an exercise for the reader
:-)

Ebbe

Oct 2 '06 #2

P: n/a
Console.SetCursorPosition method in .NET 2.0.

Not sure about 1.x though.

Glenn

"sgr" <sg*@discussions.microsoft.comwrote in message
news:58**********************************@microsof t.com...
Is there any way to do that C# always writes in the same line of the
console?

Oct 2 '06 #3

P: n/a
sgr,

..NET 2.0 Console class has new method for controlling the caret position. I
believe you can use this to position the caret at the begining of the line
you want to rewrite. In 1.x thought this method doesn't exist, however you
can use the ASCII control symbols to move the caret. Originally these
symbols are meant to be used to control a printer devices, thus the names
doesn't fit well with the conception of the screen:
- CR (carriage return) - 0xD ('\r') moves the caret at the beginning of the
line
- LF (line feed) - 0xA ('\n') moves the caret on the next line (same column
thought); this is the reason microsoft used two characters for new line -
"\r\n"
- BS (backspace) - 0x8 ('\b') - move the caret one position ot the left
- HT (horizontal tab) 0x9 ('\t') - move the caret one tabulation on the
right.

You can use thought to control the caret position on the console window.

--
HTH
Stoitcho Goutsev (100)

"sgr" <sg*@discussions.microsoft.comwrote in message
news:58**********************************@microsof t.com...
Is there any way to do that C# always writes in the same line of the
console?

Oct 2 '06 #4

P: n/a
" You can use thought to control the caret position on the console window."

-- Fantastic! Does this mean that they've released the Microsoft Telepathy
API 1.0?
:-)
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Stoitcho Goutsev (100)" wrote:
sgr,

..NET 2.0 Console class has new method for controlling the caret position. I
believe you can use this to position the caret at the begining of the line
you want to rewrite. In 1.x thought this method doesn't exist, however you
can use the ASCII control symbols to move the caret. Originally these
symbols are meant to be used to control a printer devices, thus the names
doesn't fit well with the conception of the screen:
- CR (carriage return) - 0xD ('\r') moves the caret at the beginning of the
line
- LF (line feed) - 0xA ('\n') moves the caret on the next line (same column
thought); this is the reason microsoft used two characters for new line -
"\r\n"
- BS (backspace) - 0x8 ('\b') - move the caret one position ot the left
- HT (horizontal tab) 0x9 ('\t') - move the caret one tabulation on the
right.

You can use thought to control the caret position on the console window.

--
HTH
Stoitcho Goutsev (100)

"sgr" <sg*@discussions.microsoft.comwrote in message
news:58**********************************@microsof t.com...
Is there any way to do that C# always writes in the same line of the
console?


Oct 2 '06 #5

P: n/a
Hahaha :-D. Sorry misspelled :)
--
Stoitcho Goutsev (100)

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:01**********************************@microsof t.com...
>" You can use thought to control the caret position on the console window."

-- Fantastic! Does this mean that they've released the Microsoft Telepathy
API 1.0?
:-)
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Stoitcho Goutsev (100)" wrote:
>sgr,

..NET 2.0 Console class has new method for controlling the caret
position. I
believe you can use this to position the caret at the begining of the
line
you want to rewrite. In 1.x thought this method doesn't exist, however
you
can use the ASCII control symbols to move the caret. Originally these
symbols are meant to be used to control a printer devices, thus the names
doesn't fit well with the conception of the screen:
- CR (carriage return) - 0xD ('\r') moves the caret at the beginning of
the
line
- LF (line feed) - 0xA ('\n') moves the caret on the next line (same
column
thought); this is the reason microsoft used two characters for new line -
"\r\n"
- BS (backspace) - 0x8 ('\b') - move the caret one position ot the left
- HT (horizontal tab) 0x9 ('\t') - move the caret one tabulation on the
right.

You can use thought to control the caret position on the console window.

--
HTH
Stoitcho Goutsev (100)

"sgr" <sg*@discussions.microsoft.comwrote in message
news:58**********************************@microso ft.com...
Is there any way to do that C# always writes in the same line of the
console?



Oct 3 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.