Manipulating the cursor in a Console app

Consider this code:

for i as integer = 1 to 10
  StdOut.Write chr( 13 ) + "Now printing " + str( i )
next

Run that in Console and you will get what appears to be a single line that keeps updating its value at the end. What other codes are available? For example, could I emulate something like Top where the Terminal is cleared and the cursor is positioned at specific lines or positions? Can I change the color of the output?

This may help :
https://en.wikipedia.org/wiki/ANSI_escape_code
http://www.termsys.demon.co.uk/vtansi.htm
http://www.climagic.org/mirrors/VT100_Escape_Codes.html

It will depend on what “Real Terminal” the terminal software is emulating
which “may” be different between OSX , Win and Linux

VT100 is “usually” the emulation of choice, but not always, and sometimes not 100% accurate

for the OSX terminal app, this clears the screen

print Chrb(27)+"c"

but VT100 is

print Chrb(27)+"[2J"

Thanks to both of you. I’ll play with this information.

macOS “Terminal” is an xterm
at the very least a descendant of the original

echo $TERM

will tell you this

xTerms generally emulate VT220 and/or Tektronix 4010 terminals (see the wikipedia article for xterm) but you can select this for OS X terminal in Terminals preferences Pane (Preferences > Profiles > Advanced)