home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
30TURUTL
/
CLOCKPAS.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-02-18
|
3KB
|
121 lines
{ This is a simple clock routine to be used with TURBO PASCAL.
It demonstrates the use of both TURBO "intr" and "msdos"
routines. The actual workings of interrupt routines and dos calls
are best found in the DOS manual NOT HERE !!! for obivous reasons.
However this segment of code can be altered and used by anyone who knows
TURBO PASCAL. I have found it of great use for time/date stamping of
printed reports from pascal and other screen routines requiring default
dates etc.
Uploaded on 10/10/84 IBM PC USERS GROUP MILWAUKEE
Direct comments or questions to me, JON GRAY
on the MILWAUKEE IBM PC USERS GROUP RBBS.
One Hint: Stay away from the interrupt stuff if you don't know it
or plan to do a few COLD STARTS...
}
{$C- CNTL C and CNTL S off}
program clock (input, output);
type
regpack = record
ax,bx,cx,dx,bp,si,ds,es,flags: integer;
end { record };
timestr = string[11];
datestr = string[15];
function date : datestr;
const
montharr : array [1..12] of string[3] =
('Jan','Feb','Mar','Apr','May',
'Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var
recpack:regpack;
month, day:string[2];
year:string[4];
dx, cx, result, tmpmonth:integer;
begin
with recpack do
begin
ax:= $2a shl 8;
end;
msdos (recpack);
with recpack do
begin
str(cx:4, year);
str(dx mod 256:2, day);
str(dx shr 8:2, month);
end;
val (month, tmpmonth, result);
date:= day + '-' + montharr[tmpmonth] + '-' + year
end; { date }
{********************************************************************}
function time : timestr;
var
recpack:regpack;
ah, al, ch, cl, dh:byte;
hour, min, sec, ampm:string[2];
tmptime, result:integer;
begin
ah := $2c;
with recpack do
begin
ax := ah shl 8 + al;
end;
intr($21,recpack);
with recpack do
begin
str(cx shr 8:2, hour);
str(cx mod 256:2, min);
str(dx shr 8:2, sec);
end;
if (hour > '12') then
begin
val (hour, tmptime, result);
tmptime:= tmptime - 12;
str (tmptime:2, hour);
ampm:= 'pm'
end
else
ampm:= 'am';
if (min[1] = ' ') then
min[1]:= '0';
if (sec[1] = ' ') then
sec[1]:= '0';
time := hour + ':' + min + ':' + sec + ' ' + ampm;
end; { time }
{********************************************************************}
procedure clock;
var
oldtime, curtime:string[11];
begin
clrscr;
gotoxy (23,12);
write (date);
gotoxy (23,15);
lowvideo;
writeln ('***** PRESS ANY KEY TO BEGIN *****');
normvideo;
gotoxy (1,20);
write ('COMMENTS OR QUESTIONS ? CONTACT: JON GRAY IBM PC USERS GROUP - MILWAUKEE');
repeat
oldtime:= time;
repeat
curtime:= time;
until (oldtime <> curtime);
gotoxy (47,12);
write (time);
until keypressed;
end; { clock }
{********************************************************************}
begin { main program }
clock;
end. { main program }*************************