|Eͻ
|E |5The Happy Hacker|E       ^1 The CLR Command |E        |5The Happy Hacker|E 
|Eͼ
^C^1by James Barberousse, ODM Staff^0


^CPC Hackers of the world unite!

With Issue 60 (Our 5 Year Anniversary!), On Disk Monthly reinstates 
its Happy Hacker department by popular demand.  In this column, we 
explore a wide range of technical issues about the PC and 
programming.  Welcome aboard, Hackers!

This month we present The CLR Command, a menu/batch file utility to 
clear the text video screen using different screen wipes, different 
foreground/background colors, and different ASCII characters.  The 
program can be run as a menu application--an environment that allows 
you to quickly change wipe/color/character combinations and observe 
the wipe, and as a batch file utility with up to 4 parameters--a 
slick program to call from your AUTOEXEC.BAT.

To invoke CLR as a menu, type ^1CLR^0 from DOS.  The screen that
appears will explain how to use the 4 parameters to achieve different
screen wipe effects and allow you to try every combination of wipe,
character, and color.  Only the first parameter is required; the
other 3 are optional.  Thus, you may enter 1, 2, 3, or 4 parameters.
Typing too many parameters or typing an invalid parameter causes CLR
to automatically go to the menu.

The best way to learn the operation of CLR is to play with the menu
version and observe the wipes and the required parameters.  Make a
note of your favorite parameter combinations so that you can include
them in your batch files.  Pretty cool, huh?  WELL, HOW DOES IT WORK?

^1Text Screen Colors^0
Inside CLR, you may select one of 16 foreground colors and one of 16 
background colors.  This gives a total of 256 different color 
combinations (16 * 16 = 256).  The foreground/background combination 
for a single character on the screen is called its text screen color 
attribute.  In CLR, these different colors may be selected from 2 
scrolling pick-lists (one for foreground, one for background).  Note 
that if the foreground and background colors are the same, the screen 
becomes a solid, blank color.  This can be very useful.  See ^1Screen 
^1Blanker^0 below.

Note:  Normally, DOS allows 8 blinking and 8 non-blinking background 
colors, for a total of 16 different backgrounds.  However, the 
blinking capability can be turned off, allowing 16 non-blinking 
background colors.  When run as a menu, CLR turns the blinking off 
(providing 16 foreground and 16 background colors with no blinking), 
and upon exit, CLR restores blinking.  However, the batch file 
invocation of CLR turns off blinking and does not restore it, thus 
allowing you to display the upper 8 background colors.  This creates 
an interesting and subtle side effect:  If your screen's background 
color is any of the upper 8 colors (DARKGRAY to WHITE) and you invoke 
CLR as a menu, when you return to DOS the screen will be blinking!  
This is perfectly normal; with blinking restored, DOS simply 
interpreted the background color as a blinking color.


^1ASCII Codes^0
ASCII stands for American Standard Code for Information Interchange.  
Every character that can be displayed on the PC video text screen is 
assigned a number called its ASCII code.  These codes range from 0 to 
255 and include all characters on the keyboard and some not available 
on the keyboard.  These ASCII character codes may be selected from a 
scrolling pick-list (with the exception of codes 0 to 31, which are 
control character codes and code 255).

^1Text Video Memory^0
When you look at your PC's video text screen, you are looking 
directly into your computer's memory.  Everything displayed on the 
text screen is stored somewhere in memory, and there is special 
hardware to read that memory and interpret it as characters on your 
screen.  Every character displayed on the screen requires 2 bytes of 
memory.  One byte is the ASCII code for the character, and the other 
byte is the foreground/background color attribute.  In 80 column 
mode, the PC's text screen can display 25 lines of 80 characters 
each, for a total of 25 * 80 = 2000 characters or bytes.  But every 
character displayed can have a separate foreground/background color 
combination, which doubles the total memory required for the screen.  
This brings the memory-mapped text screen to 4000 bytes.

^1How CLR Works^0
Since each screen position is controlled by 2 bytes of memory (one 
for the character and one for the color) and since we can access this 
memory just like any other memory, we have what we need to blast any 
character/color combination onto the screen in any pattern we want.  
And this is exactly what CLR does.

^1Screen Blanker^0
As mentioned above, if the foreground and background colors are the 
same, regardless of the character, the screen becomes a solid color.  
This is useful as a screen blanker, a program that blanks your 
computer screen while you are away to prevent burn-in.  Try executing
^1BLANK1.BAT^0 and ^1BLANK2.BAT^0 from DOS.  These batch files use 
CLR to clear your screen to black on black--which, of course, is 
black!  Use a text editor to examine these files and modify them to 
suit you.

^1Outside On Disk Monthly^0
To run CLR outside the On Disk Monthly menu, type

   ^1CLR^0  or  ^1CLR parm1 parm2 parm3 parm4^0.

Disk files this program uses:
^FCLR.EXE
^FBLANK1.BAT
^FBLANK2.BAT
