home *** CD-ROM | disk | FTP | other *** search
- program gtime;
- uses crt, comunit, stopwatch, dos, ioerrmsg;
- var cl1: clock;
- s1: string[80];
- hour, min, sec, sec100: word;
- i: byte;
- res: integer;
- parmfile: text;
- timezone: 0..23;
- comport: 1..2;
- dialcmd: string[80];
- resetcmd: string[80];
- procedure checktime;
- begin
- if stopclock(cl1)>30 then begin
- writeln('TIMEOUT');
- if dcd then hangup;
- halt;
- end;
- end;
-
- procedure check_io;
- var i: integer;
- begin
- i := IOresult;
- if i<> 0 then begin
- writeln('I/O error #',i, ' on PARMFILE: ', errmsg(i));
- halt;
- end;
- end;
-
- begin
- echo_on := true;
- status_change_proc := do_nothing;
- ClrScr;
- {$I-}
- assign(parmfile,'parmfile');
- check_io;
- reset(parmfile);
- readln(parmfile,timezone);
- check_io;
- readln(parmfile,comport);
- check_io;
- readln(parmfile,resetcmd);
- check_io;
- readln(parmfile,dialcmd);
- check_io;
- close(parmfile);
- check_io;
- {$I+}
- startclock(cl1);
- display_error := true;
- initcom(comport,200,B1200,8,1,no_par);
- sendln(resetcmd);
- repeat
- s1 := getln;
- checktime;
- until s1='OK';
- sendln(dialcmd);
- repeat
- checktime
- until dcd;
- repeat
- s1 := getln;
- checktime;
- until (length(s1)>=10) and (copy(s1,length(s1)-2,3)='UTC');
- i := length(s1)-9;
- val(copy(s1,i,2), hour, res);
- val(copy(s1,i+2,2), min, res);
- val(copy(s1,i+4,2), sec, res);
- hour := (hour+24-timezone) mod 24;
- settime (hour, min, sec, 0);
- hangup;
- end_com;
- gotoxy(1,23);
- write ('Press any key to exit.');
- repeat
- gettime(hour , min,sec,sec100);
- gotoxy(1,24);
- write (hour:2,':',min:2,':',sec:2);
- until keypressed;
- end.