471,337 Members | 1,161 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

console.write easy peasy beginners question

I'm messing about with a console app that does some tedious data
processing, I want to show activity in the console window.

What I wanted was -
followed by \
followed by |

etc;

ie a bar revolving on the spot

console.write advances the character position by one though

Can I send a backspace through? (Have tried .write(8) .write 0x08
which is ascii BS but it keeps printing the number...)

Ta.

Oct 18 '07 #1
5 6870
On Oct 18, 11:17 am, simonl <silang...@hotmail.comwrote:
I'm messing about with a console app that does some tedious data
processing, I want to show activity in the console window.

What I wanted was -
followed by \
followed by |

etc;

ie a bar revolving on the spot

console.write advances the character position by one though

Can I send a backspace through? (Have tried .write(8) .write 0x08
which is ascii BS but it keeps printing the number...)

Ta.
I've done the same exact thing before. It was a while ago, but I think
I moved the cursor back by using the Console.CursorLeft method.

Oct 18 '07 #2
To elaborate, before you start drawing your spinning cursor, you will
want to store the location of the cursor using the static CursorLeft and
CursorTop properties on the Console class.

After you write your character, you will want to call the static
SetCursorPosition method on the Console class, setting the location to the
values you obtained before, and then write your character again.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<za***@construction-imaging.comwrote in message
news:11**********************@q5g2000prf.googlegro ups.com...
On Oct 18, 11:17 am, simonl <silang...@hotmail.comwrote:
>I'm messing about with a console app that does some tedious data
processing, I want to show activity in the console window.

What I wanted was -
followed by \
followed by |

etc;

ie a bar revolving on the spot

console.write advances the character position by one though

Can I send a backspace through? (Have tried .write(8) .write 0x08
which is ascii BS but it keeps printing the number...)

Ta.

I've done the same exact thing before. It was a while ago, but I think
I moved the cursor back by using the Console.CursorLeft method.

Oct 18 '07 #3
"simonl" <si*******@hotmail.comschrieb im Newsbeitrag
news:11**********************@e34g2000pro.googlegr oups.com...
>
Can I send a backspace through? (Have tried .write(8) .write 0x08
which is ascii BS but it keeps printing the number...)
You can cast a number to char. So it would be:
..Write((char)8)

This would write a backspace to the console, though I don't know the exact
effect of this on the console. You will have to try ;)

You also can use character escapes: \b is backspace IIRC.
So '\b' means a backspace char, and "\b" would be a string with a single
backspace character.

Christof

Oct 18 '07 #4
On 18 Oct, 16:36, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
To elaborate, before you start drawing your spinning cursor, you will
want to store the location of the cursor using the static CursorLeft and
CursorTop properties on the Console class.

After you write your character, you will want to call the static
SetCursorPosition method on the Console class, setting the location to the
values you obtained before, and then write your character again.

Luvverly, and lots more ascii graphics tools to play with too.

Oct 18 '07 #5
"Christof Nordiek" <cn@nospam.dewrote:
You can cast a number to char. So it would be:
.Write((char)8)
This would write a backspace to the console, though I
don't know the exact effect of this on the console.
It works fine. I suppose "\b" is theoretically more portable though.

using System.Threading;
....
while (true) foreach (char ch in new char[] { '|', '\\', '-', '/' })
{
Console.Write(ch + "\b");
Thread.Sleep(100);
}

Eq.
Oct 18 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Chris Williams | last post: by
4 posts views Thread by baumann | last post: by
2 posts views Thread by Michael | last post: by
2 posts views Thread by key9 | last post: by
4 posts views Thread by KC | last post: by
4 posts views Thread by =?Utf-8?B?RG91Z0U=?= | last post: by
5 posts views Thread by =?Utf-8?B?SmFtZXMgV29uZw==?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.