DECLARE SUB StripCRLF (x$) ' ************************************************************************** ' Software to access the NIST Automated Computer Time Service ' (Works with QBASIC compiler included with MS-DOS 5.0 and 6.0) ' ************************************************************************** ' Define Modem Initialization String ' ************************************************************************** attention$ = "ATZX3" ' ************************************************************************** ' Define number of timecodes to receive ' ************************************************************************** receivelines% = 10 ' ************************************************************************** ' COM Port Setting (set to either COM1: or COM2:) ' ************************************************************************** comport$ = "COM2:" ' ************************************************************************** ' Baud Rate Setting (set to 1200 for 1200 baud, or 300 for 300 baud) ' ************************************************************************** baudrate$ = "1200" ' ************************************************************************** ' Dialing Method (set to T for tone dialing, P for pulse dialing) ' ************************************************************************** pulse$ = "T" ' ************************************************************************** ' Phone Number (eliminate area code, add access codes if necessary) ' ************************************************************************** phone$ = "1-303-494-4774" ' ************************************************************************** ' housekeeping functions ' ************************************************************************** ON ERROR GOTO Handler ' trap errors CLS ' clear screen IF baudrate$ = "1200" THEN codefix% = 6 ELSE codefix% = 0 ' ************************************************************************** ' print opening text on screen ' ************************************************************************** PRINT "NIST Automated Computer Time Service (ACTS)" PRINT PRINT "Dialing ACTS, please wait..." PRINT ' ************************************************************************** ' set up modem for 8 data bits, 1 stop bit, and no parity ' ************************************************************************** communicate$ = comport$ + baudrate$ + ",N,8,1" ' ************************************************************************** ' call the Automated Computer Time Service (ACTS) ' ************************************************************************** OPEN communicate$ FOR RANDOM AS #1 LEN = 256 PRINT #1, attention$ ' initialize modem g = TIMER DO LOOP UNTIL ABS(TIMER - g) > 3 ' pause for 3 seconds PRINT #1, "ATD" + pulse$ + phone$ ' dial number printline% = 1 ' count first line DO timecode$ = "" ' clear timecode$ DO ' read in characters s$ = INPUT$(1, #1) timecode$ = timecode$ + s$ LOOP UNTIL s$ = "#" OR s$ = "*" OR s$ = CHR$(13) CALL StripCRLF(timecode$) ' clean up timecode SELECT CASE timecode$ ' check for errors CASE "ERROR", "NO DIALTONE", "BUSY", "NO CARRIER", "NO ANSWER" CLOSE #1 GOTO Handler END SELECT otm$ = s$ ' check for on-time marker IF otm$ = "*" OR otm$ = "#" THEN PRINT #1, otm$ ' send OTM back to NIST PRINT timecode$ ' print timecode on screen printline% = printline% + 1 ' increment print line END IF LOOP UNTIL printline% > receivelines% ' get next timecode t$ = MID$(timecode$, 10 + codefix%, 8) ' get time from timecode TIME$ = t$ ' set time on computer d$ = MID$(timecode$, 4 + codefix%, 5) + "-" ' get date from timecode d$ = d$ + MID$(timecode$, 1 + codefix%, 2) DATE$ = d$ ' set date on computer PRINT #1, "ATH" ' hang up telephone CLOSE #1 PRINT PRINT "The computer's clock has been set." ' print message on screen END ' ************************************************************************** Handler: ' print error message PRINT PRINT "Communications Error - Check Phone Line and COM port setting." PRINT END ' ************************************************************************** SUB StripCRLF (x$) STATIC ' strips all carriage returns and line feeds from a string y$ = "" FOR i% = 1 TO LEN(x$) z$ = MID$(x$, i%, 1) IF ASC(z$) <> 10 AND ASC(z$) <> 13 THEN y$ = y$ + z$ END IF NEXT i% x$ = y$ END SUB