473,419 Members | 1,704 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 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 6993
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris Williams | last post by:
Hi... I'm trying to find some code samples that will show me how to capture non-character keypresses in a console app. I've tried the standard stuff, such as console.read and console.readline,...
4
by: baumann | last post by:
hi all, i want to use the fprintf to make log. if defined LOG_TO_FILE, it is easy to use fprintf to write the log file. if not defined LOG_TO_FILE, i want to simply write to error std...
2
by: Martín Marconcini | last post by:
Hello there, I'm writting (or trying to) a Console Application in C#. I has to be console. I remember back in the old days of Cobol (Unisys), Clipper and even Basic, I used to use a program...
2
by: Michael | last post by:
Hi everybody, I want to know if there is a function in the Console to "jump" to a specific position in a Console-Output window and write something there. Another question is, if I can write...
2
by: key9 | last post by:
Hi All I need a library which can afford "cisco" console or "juniper" console style control. (may be something like autocad's command windows) On programming running . It can afford a...
6
by: tony | last post by:
Hello! When you have windows forms you have the same possibility as when you have a Console application to use Console.Writeln to write whatever on the screen. Now to my question: Is it...
4
by: KC | last post by:
Hi, I don't know why this question is so hard to have an answer ? I search Google for a while ... and can't find any "good" answer. Using "throw new Error(msg)" does work ... but I believe...
4
by: =?Utf-8?B?RG91Z0U=?= | last post by:
Some people tryed to help in my previous post. But I don't quite have it. What I want to do is send stdout to something on a form textbox, panel, listbox -- something. I want to write to a form the...
5
by: =?Utf-8?B?SmFtZXMgV29uZw==?= | last post by:
Dear all, I'd like to know if there is any method to minimize command mode window when a console program is running. In my case, there are several console programs which run periodically in...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.