Edit : The answer here shows how you can manipulate the console much more powerful than I knew. What I originally wrote is still applicable and may be useful if you do not have available tools, possibly in another language.
Save the logo and the initially generated state of the array, and then when you clear the console, write down the saved values ββagain, instead of using the same generation procedure.
As others have said, the console is not designed for this kind of operation, so you have to get around it.
Another option would be to write to a string or string constructor, rather than directly to the console, and then whenever the console needs to be updated, clear it and write the output / stream string to the console. This will allow you to perform string operations / regular expressions, etc. In the text of the output, to remove / leave certain things in place.
However, this will be associated with a lot of console overhead, as you end up retyping the entire output with each update.
A THAT solution might be to keep a parallel view of the line / stream of what you write on the console, and then when you need to clear, you can clear the string view, clear the console, and then write the line to the console again. That way, you would only add an extra write operation to your regular record, and most of the extra work would only happen when the console was cleaned up.
No matter what you do, writing to the console is never a quick operation, and if you perform many operations when writing to the console, it can significantly affect the performance of your application.
xan Dec 18 '08 at 14:16 2008-12-18 14:16
source share