There you are, happily – but surreptitiously – playing away at a vintage game of “Adventure,” when… suddenly, you see the boss approaching! Quick! Don't get caught! How to erase the evidence of your dalliance?
Well. Since you're playing vintage, text-mode “Adventure,” you're playing it in (or on) a terminal screen – either an antique VT100/200 (etc.), or more likely, in a terminal emulation window (on your PC) like PuTTY, Reflection, TeraTerm, or similar. These are all ANSI-standards-based terminals (even the emulated terminal windows), and they'll all respond to the ANSI escape-sequence (command) to “erase the screen” – thus saving you from embarrassment and a scolding from your boss.
How? It just takes a bit of set-up work in your personal VMS LOGIN.COM command file. You need to create a command alias – like
CLS – which you can quickly enter (type) as a command at the DCL
$-prompt to “clear the screen now!” “CLS” is a handy mnemonic and abbreviation for “clear screen” – make up your own if you don't like this one. Keep it short and sweet, so you can remember and enter it in a hurry!
Edit your own LOGIN.COM file to add this (first approximation) alias command under the INTERACTIVE section (or label) of that file:
$ cls == "TYPE /PAGE=CLEAR_SCREEN NLA0:"
Exit from your text editor, saving your changes – To try this out, execute your command file interactively to define the new alias command:
…and then try your new command:
If you've made no typos in the above, any residual text on your screen should vanish, replaced with a clean white (or black?) screen with your
$-prompt in the upper-left-hand corner, and the cursor blinking happily to its right. It can't get much better than this!… Or can it?
It turns out that this preliminary version of our CLS alias command elicits the right behavior, but it's pretty “expensive” to execute, especially when what's required to clear an ANSI-terminal screen is a command of about 10 ASCII characters. This preliminary version:
That's actually a lot of work for VMS and DCL to do just to clear your terminal screen. This can be done much more efficiently, at the expense of just a little bit more setup in your LOGIN.COM file:
$ esc[0,8]= %X1B ! 27 decimal, 033 octal - ESCape character $ _bckscrL = esc + "[?5h" ! set background light $ _bckscrD = esc + "[?5l" ! set background dark $ _clrscr = esc + "[m" - ! set rendition normal + esc + "[H" - ! cursor to 0,0 + esc + "[2J" ! clear entire screen $ ! $ cls == "WRITE sys$output _clrscr" $ clsd == "WRITE sys$output _bckscrL,_clrscr" $ clsl == "WRITE sys$output _bckscrD,_clrscr"
Cut-&-paste the above lines into your LOGIN.COM file, this time replacing the previous “
cls == TYPE /PAGE…” command with these lines. Exit from your text editor session again, saving your work, then:
…and then try your new command:
Again, your screen should clear just fine. So!… Why is the above better than the first/preliminary version?
Those somewhat complicated commands in this second example do this:
escwhich contains a single ASCII “escape character” (ASCII code value 27, or 33-octal, or 1B-hex).
esc(escape) character is used to construct three more DCL variables (each beginning with an underscore “
_” character to stress their intermediate nature) which are escape-sequence commands to (in order):
_bckscL: set the terminal's background to light (white);
_bckscD: set the terminal's background to dark (black); and
_clrscr: clear the entire screen.
clr: Clear the screen;
clsd: Clear the screen, make background dark (black); and
clsl: Clear the screen, make background light (white).
In other words,
clsd will change your screen's background to light or dark (respectively) while clearing it, and
cls will simply clear the screen retaining the current background. Try 'em out!
For more information (TL;DR) about ANSI escape-sequences, see Wikipedia: https://en.wikipedia.org/wiki/ANSI_escape_code.