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

console.write easy peasy beginners question

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
"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.