Screen Clock For IBM
Have you ever become submerged in a project while working on your computer and suddenly discovered it is hours past your bedtime? Or maybe you need to keep a detailed log of your worktime on the computer for business or tax purposes. If so, this utility is the answer-it constantly displays all this information and more on your monitor screen. It works with IBM PC and PCjr computers using DOS 2.0 or higher.
Large mainframe computers generally provide a sysline on the terminal screen which tells you the current date and time, who has logged on or off, and whether you've received any new electronic mail. Obviously, not all of these things apply to single-user personal computers, but some of the features would be nice to have.
"Screen Clock" is a short machine language program that prints the day of the week, date, current time, and log-on time at the top of the screen. This information appears no matter what else your computer is doing. You can be running a word processor, copying files, programming, or whateverthe day, date, and time will always be visible.
You might be wondering how it's possible to keep Screen Clock active while running another program; an IBM PC with PC-DOS isn't capable of multitasking. Screen Clock gets around this restriction by not using any PC-DOS function calls, relying instead on the BIOS (Basic Input/Output System) to handle the screen. This has several fortunate consequences:
• Sysline updates are not redirected to a file if you're using DOS file redirection.
• Sysline updates are not printed if you're echoing output to the printer. (But the sysline is printed if you press PrtSc for a screen dump.)
• Screen Clock always updates the current "active" screen. It doesn't matter if you switch from the monochrome monitor to the color monitor, change pages in the color screens, or even enter a graphics mode-the date and time are always there.
Winding Up The Clock
Type in the program listing below, save a copy on disk, then type RUN. The program is a BASIC loader that creates a machine language file on your disk with the filename CLOCK.COM. To start the clock, simply type CLOCK (upperor lowercase is fine) at the A> DOS prompt. A sysline similar to this should appear on the top line of your screen:
Wed Jan 01, 1986 12:01A (00:37)
The day of the week, date, and current time are self-explanatory. The figure in parentheses is the elapsed time (in hours and minutes) since Screen Clock was started or reset. This "log-on" time runs up to 23 hours and 59 minutes, then rolls over to 00:00.
When you run Screen Clock from DOS, you can select various options by appending commands after typing CLOCK. Each command consists of a slash (/) symbol, a character, and sometimes a number. Here are the commands and options:
/Cn (Chime) where n is an integer from 0 to 3. /C0 means no chiming; /C1 makes the clock chime hourly; /C2 chimes every half-hour; and /C3 chimes every 15 minutes. A chime is a low beep which lasts for less than one second. Even if the screen updates are turned off, Screen Clock always chimes if you have told it to. The default is no chiming.
/Un (Update) where n is an integer from 1 to 9. This sets how often screen updates are to take place-n is the number of halfseconds between updates. The more frequent the updates, the more often the date and time are refreshed on the screen. However, more frequent updates also make other programs run more slowly. The default is equivalent to /U2 (one second between updates).
/M (Military time). This selects military (24-hour) time.
/S (Standard time). This selects standard 12-hour time with an a.m./p.m. marker. Screen Clock defaults to standard time.
/R (Reset). This resets the logon timer. Screen Clock automatically resets itself to 00:00 when first run.
For example, typing CLOCK /U3/M/C1 at the DOS prompt loads and runs Screen Clock, sets updates every 1½ seconds, sets military time, and makes the clock chime every hour.
The Disappearing Clock
Occasionally, the Screen Clock sys line may get in the way. For example, it may hide text printed on the top line of the screen. You can make it disappear by pressing CTRL and both SHIFT kevs simultaneously. Pressing this combination again turns the sysline back on.
Since Screen Clock maintains its own clock, it might not agree precisely with the DOS clock. Gen erally, it's never more than half a minute off.
Note that the day, date, and time are reset every time you run Screen Clock. If you change the system date and time, you can reset Screen Clock by running it again. For example, the following would reset the display to 8:00 p.m. on February 14 (the A> prompts are supplied by DOS):
A> time 20:00:00
A> date 02-15-86
The log-on time is not reset unless you append the /R command to CLOCK.
Although Screen Clock makes it appear that your computer is doing more than one thing at a time, it's important to remember that computers can really perform only one task at a time (a factor of the basic architecture of all personal computers to date). If the computer spends some if its time updating the sysline, that's time away from running the main program. Thus, the more often the sysline is updated, the more time it steals from the computer, and the slower the main program seems to run. However, the part of Screen Clock that takes the most time is printing the sysline on the screen. If screen updates are turned off, there is virtually no slowdown. So during heavy number crunching you might want to turn the sysline updates off.
I've been using Screen Clock quite a bit and haven't noticed much loss of performance at all. It seems that the computer spends a lot of its time waiting for input (from the keyboard, the disk drives, and so on); all we're doing is giving it something else to do in its "spare time." I have yet to find a program which doesn't work with Screen Clock.
As the power of personal computers increases, it becomes possible to include features once found only on large mainframe computers. A sysline such as Screen Clock is another step in this direction.
How It Works
Mainframe syslines are generally on the bottom row of the screen. The Screen Clock sysline, however, must be on the top row because there's no way via PC-DOS to keep the bottom row from scrolling. The sysline would keep traveling up the screen every time the screen was scrolled. By placing the sysline on the top row, it can be refreshed each time it scrolls off the top of the screen.
The program itself is broken into two sections, resident and nonresident. The resident portion up dates the internal counters, sounds the chimes, and updates the screen display. It's driven by the user interrupt 1Ch and is executed about 18 times a second. The nonresident part sets the initial date and time and changes the program's options.
When you execute CLOCK.COM, the program first checks to see if the resident portion is already installed. This is important only when the program returns control to DOS. Then it sets the current date and time and checks for any optional parameters. After this, the program is ready to return to DOS. If the program was already installed, it simply returns to DOS and does nothing else. If it needs to be installed, it first deallocates the environment space, then returns to DOS with the "terminate but stay resident" call to store the resident portion of the program safely in memory.
For instructions on entering this listing, please refer to "COMPUTE!'s Guide to Typing In Programs" in this issue of COMPUTE!.
IBM Screen Clock
EF 100 CLS:LOCATE 10,10:PRINT"Wr
iting file ..."
OM 110 OPEN "clock.com" FOR OUTP
UT AS #1
EL 120 FOR I=1 TO 1310:READ BYTE
<0 THEN FOR J=1 TO ABS(BY
GH 130 PRINT#1,CHR$(BYTE);
GO 140 NEXT I:CLOSE 1
FJ 150 IF CKSUM <> 124185 THEN P
RINT"** Error in DATA sta
tements **":KILL ""clock.c
HJ 160 PRINT:PRINT"File for cloc
k.com has been created.":
KN 200 DATA 233,51,4,74,97,110,
DG 210 DATA 97,114,32,65,112,11
EB 220 DATA 1.17,110,32,74,117,1
NP 230 DATA 101,112,32,79,99,11
NJ 240 DATA 101,99,32,31,28,31,
FP 250 DATA 31,30,31,83,117,110
JK 260 DATA 117,101,32,87,101,1
PH 270 DATA 114,105,32,83,97,11
6, SL, -C, 1 , fn, t , o.
AE 280 DATA 19,2,-5,240,18,0,1,
ML 290 DATA 117,108,80,83,81,82
6K 300 DATA 200,142,216,142,192
OP 310 DATA 133,0,160,108,1,58,
BM 320 DATA 91,1,232,158,1,137,
CJ 330 DATA 128,62,111,1,0,116,
GI 340 DATA 93,95,94,90,89,91,8
NC 350 DATA 36,7,60,7,116,6,198
ON 360 DATA 128,62,115,1,0,117,
BJ 370 DATA 198,6,115,1,1,128,6
PE 380 DATA 232,197,0,195,180,1
CN 390 DATA 180,3,205,16,137,22
OH 400 DATA 205,16,185,31,0,176
HO 410 DATA 250,180,2,13x3,62,11
PM 420 DATA 16,195,128,62,199,1
NA 430 DATA 58,6,198,1,119,5,25
JA 440 DATA 6,199,1,255,228,97,
EA 450 DATA 22,197,1,128,250,0,
DO 460 DATA 1,0,117,8,128,62,19
DC 470 DATA 128,250,1,116,50,12
PN 480 DATA 128,62,196,1,0,116,
KK 490 DATA 30,128,62,95,1,15,1
BF 500 DATA 0,116,22,195,128,62
OM 510 DATA 62,196,1,0,116,7,19
PO 520 DATA 195,198,6,196,1,1,1
JJ 530 DATA 182,230,67,184,102,
GF 540 DATA 228,97,12,3,230,97,
OI 550 DATA 191,116,1,252,139,5
PJ 560 DATA 129,1.98,63,1,185,4,
GC 570 DATA 1,209,230,209,230,1
OB 580 DATA 243,164,160,99,1,23
FH 590 DATA 160,101,1,232,12,1,
FO 600 DATA 176,32,170,1-39,14,9
CE 610 DATA 1,1,184,32,40,171,1
IP 620 DATA 180,1,232,242,0,176
NO 630 DATA 136,62,114,1,180,3,
FP 640 DATA 180,2,186,-2,205,16
KH 650 DATA 206,172,180,14,205,
IH 660 DATA 114,1,139,22,112,1,
NB 670 DATA 139,7,187,69,4,247,
CK 680 DATA 232,138,204,195,187
AD 690 DATA 232,43,0,187,104,1,
JL 700 DATA 1,195,255,7,117,3,2
DI 710 DATA 24,114,17,129,63,17
FJ 720 DATA 199,71,2,-2,249,195
AH 730 DATA 131,62,102,1,6,118,
IA 740 DATA 254,6,99,1,139,22,9
OM 750 DATA 22,99,1,115,42,198,
NI 760 DATA 97,1,131,62,97,1,12
PL 770 DATA 1,1,0,254,6,100,1,1
FA 780 DATA 11B,9,198,6,100,1,0
PD 790 DATA 138,218,50,255,138,
CA 800 DATA 16,246,6,100,1,3,11
JH 810 DATA 0,116,2,254,194,195
IG 820 DATA 196,171,195,182,32,
EB 830 DATA 128,253,12,114,5,18
EK 840 DATA 117,2,181,12,138,19
JL 850 DATA 138,193,232,209,255
MB 860 DATA 170,195,82,101,113,
BM 870 DATA 79,83,32,50,46,48,3
CE 880 DATA 111,118,101,46,13,1
PG 890 DATA 110,115,116,97,108,
Fl 900 DATA 115,105,100,101,110
BH 910 DATA 111,110,32,111,102,
OK 920 DATA 13,10,36,39,32,117,
CH 930 DATA 32,112,97,114,97,10
PH 940 DATA 10,36,83,112,101,99
ED 950 DATA 110,117,109,98,101,
JK 960 DATA 49,45,57,32,102,111
KG 970 DATA 115,119,105,116,99,
JE 980 DATA 99,105,102,121,32,9
FO 990 DATA 114,32,102,114,111,
DP 1000 DATA 111,114,32,39,67,3
J6 1010 DATA 104,13,10,36,-2,47
KI 1020 DATA 117,9,186,125,4,18
CC 1030 DATA 0,55,205,33,136,22
PF 1040 DATA 4,211,235,67,137,3
HM 1050 DATA 33,190,200,1,141,1
IE 1060 DATA i66,13i,249,0,116,
10 1070 DATA 33,184,28,37,186,2
JE 1080 DATA 32,0,232,87,0,161,
KP 1090 DATA 205,33,184,0,49,13
NJ 1100 DATA 8,0,232,63,0,184,0
KK 1110 DATA 180,0,205,26,137,2
BD 1120 DATA 180,42,205,33,50,2
JD 1130 DATA 97,1,136,22,99,1,1
BI 1140 DATA 233,108,7,128,249,
DH 1150 DATA 6,101,1,136,14,100
BF 1160 DATA 129,0,252,172,60,3
BN 1170 DATA 58,6,53,5,116,241,
IL 1180 DATA 116,39,60,77,116,5
0G 1190 DATA 116,59,60,67,116,9
LP 1200 DATA 33,88,138,212,180,
KC 1210 DATA 9,205,33,31,195,38
CI 1220 DATA 199,6,106,1,-2,235
KE 1230 DATA 1,235,170,38,198,6
OD 1240 DATA 60,49,114,221,60,57
FN 1250 DATA 138,224,210,228,2,
GC 1260 DATA 136,186,221,4,180,
LB 1270 DATA 48,114,13,60,51,11
LO 1280 DATA 1,233,109,255,186,
LM 1290 DATA 160,0