The Processing Console
in
Programming Questions
•
2 years ago
Need your help, read on...
In the past more than one person has asked if it's possible to remove lines that were printed out to Processing console. This was last discussed here. The general consensus being that this is not possible. This issue became relevant to me, because I have made a sketch which has multiple progress indicators (i.e. counting from 0 to 1500 for example) in one draw cycle. Currently the output is a few thousand lines like this:
So my next option was to investigate exactly how the console works by examining it in action and checking out the source code. As it turns out Processing's console uses a temporary folder with a randomized name to store two text files (stderr.txt for system.out.err and stdout.txt for system.out). On WinXP this temporary directory can be found here:
C:\Documents and Settings\ [username] \Local Settings\Temp\console [longRandomNumber] .tmp
...where [username] and [longRandomNumber] are as described.
Here is an example sketch to run so you can see what happens...
Some findings:

In the past more than one person has asked if it's possible to remove lines that were printed out to Processing console. This was last discussed here. The general consensus being that this is not possible. This issue became relevant to me, because I have made a sketch which has multiple progress indicators (i.e. counting from 0 to 1500 for example) in one draw cycle. Currently the output is a few thousand lines like this:
Since it's all happening in a few draws I can't use the regular window as a progress indicator. Now ideally I would have two, constantly updated, lines in the console instead of a few thousand. Online I found a few tips for this to use text commands like "\r" or "\b" but their succes apparently depends on the specific console used and in Processing they do not work. Which returns us to the current starting point that removing/clearing in the console is not possible.Batch x of x | Reading frame xx of xxxx ( x%)
So my next option was to investigate exactly how the console works by examining it in action and checking out the source code. As it turns out Processing's console uses a temporary folder with a randomized name to store two text files (stderr.txt for system.out.err and stdout.txt for system.out). On WinXP this temporary directory can be found here:
C:\Documents and Settings\ [username] \Local Settings\Temp\console [longRandomNumber] .tmp
...where [username] and [longRandomNumber] are as described.
Here is an example sketch to run so you can see what happens...
- int count;
- void setup() {
- for (int i=0; i<10; i++) {
- count++;
- println(count);
- }
- exit();
- }
Some findings:
- You know how there are always 10 empty lines at the start of every console output? Well apparantly this is where they come from, because they are also there in the textfile.
- These text files are cumulative as long as you have your sketch open. Even though the visible console on your screen 'clears' on a new run, the textfile is still cumulative and never cleared (obviously for logging purposes). So there is by definition some kind of 'console clearing functionality' built in even the current code.
- directly improving the existing Processing source code to add a console.clear() function
- employing the already built-in clearing functionality during a sketch instead of only at the start of a new run
- temporarily overriding some of the EditorConsole functions
- tampering with those textfiles
- ...or something else.

1