ANSI escape codes/sequences allow us to control the format, colour and text and ohter output options on video text terminals.
Example:
To clear the screen in the same fashion as the CLS command in Pascal write the following:
writeln(chr(27)+'[2J');
Note: This method can also be used to clear the screen in UNIX terminals and Telnet connections.