I'm using SICStus 4.2.0 and I was not able to find out how to clear the content of the console. Is it even possible?
4 Answers
write('\33\[2J').
This is in no way specific to SICStus. It is the ANSI escape code and works in any ISO conforming system.

- 10,264
- 13
- 101
- 209
While SWI-Prolog provides a tty_clear
predicate in its tty
library, Sicstus doesn't seem to have a built-in alternative for this. But there is a simple workaround (for unix/linux, may not be that simple on windows): You can start the sicstus
shell via rlwrap
, which is a readline-wrapper for arbitrary shell commands. Besides the obvious benefit of the command history, this also means you can now use other shell functionality in sicstus, like the left/right arrow keys, home/end keys, Ctrl-k for deleting everything after the cursor, and Ctrl-l
to clear the screen.
rlwrap
is available as a package for many linux distributions, for windows you would need to use cygwin - this article describes how to setup rlwrap with powershell (for use with sqlplus in this case) so I guess powershell is a requirement too.
In summary, once you have rlwrap installed, simply start sicstus as rlwrap sicstus
and use Ctrl-l
to clear the screen.

- 5,103
- 3
- 34
- 54
I have spent some time looking through the documentation and I could not find a way to programmatically clear the console screen (in case this is possible, I am happy to be proven wrong). Alternatively, you might want to use SPIDER, that is a SICStus Prolog IDE: http://sicstus.sics.se/spider/ In Spider, the ordinary TopLevel interface has the option of clearing the current content of the console. Hope this helps.

- 1,341
- 7
- 38
- 68
If you're using swipl, then add this line in your user init file:
cls:-write('\33\[2J').
That should do it.

- 17,446
- 6
- 47
- 96