home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / COMMUNIC / CA24_1.ZIP / SCRIPTS.ZIP / SETTIME.CMD < prev    next >
Encoding:
Text File  |  1989-03-06  |  3.7 KB  |  131 lines

  1. S0 = "   "              ; values are: EST, CST, MST, PST, EDT, CDT, MDT, PDT
  2. ;
  3. ; ----- COM-AND set DOS clock
  4. ;
  5. ;    This script dials the US Naval Observatory and setts the DOS clock
  6. ;    with the time obtained.
  7. ;
  8. ;    S0 should be set with your timezone (EST, CST, MST, or PST)... if
  9. ;    left blank, this script will look for an EBL variable &ZONE... if
  10. ;    that is not found, this script will ask for it.
  11. ;
  12. ;    Note that this script, as supplied, only invokes DOS's TIME command
  13. ;    to set the clock.  If you have a hardware clock, the TIME command of
  14. ;    DOS will not necessarily change the hardware clock (and thus last
  15. ;    accross a power off).
  16. ;
  17. ;    The value in S0, if supplied, establishes the timezone.  You must
  18. ;    manually decide (for now) if daylight savings is used in your area.
  19. ;
  20. ; ------------------------------
  21. ;    Script: John Poindexter, commenced 2/89
  22. ; ------------------------------
  23. ;
  24. ;    If the value in S0 is null, look for EBL's &ZONE
  25. ;
  26. LEGEND "SETTIME v1.0"
  27. IF NULL S0        ; If value not set above
  28.    EBL S0 &ZONE     ; .. Ask EBL if it knows the zone
  29. ELSE            ; If set above
  30.    SET SUCCESS ON    ; .. Fake EBL good completion
  31.    ENDIF
  32. ;
  33. ;    If no EBL and no value, open a window and ask
  34. ;
  35. IF FAILED        ; No zone in script, and no EBL
  36.    WOPEN 10,1, 13,77 (contrast) Exit
  37.    ATSAY 11, 3 (contrast) "Enter your timezone (EST, EDT, CST, CDT, ...)"
  38.    ATSAY 12, 3 (contrast) "->"
  39.    ATSAY 13,26 (contrast) " Press ESC to exit"
  40.    ATGET 12,6  (contrast) 3 S0
  41.    WCLOSE        ; Restore screen under
  42.    IF NULL S0        ; Null entry terminates script
  43.       GOTO EXIT
  44.       ENDIF
  45.    ENDIF
  46. ;
  47. ;    Using the Zone value, look up the hour offset
  48. ;
  49. S1 = "E5C6M7P8"         ; Time zone letters and time difference from GMT.
  50. FIND S1 S0(0:0) N0    ; Case insensitive table lookup
  51. IF NOT FOUND        ; Unknown zone character
  52.    MESSAGE "^M^JYou need to include your time zone in S1 in script.^M^J"
  53.    EXIT
  54.    ENDIF
  55. ;
  56. ;    COmpute the hour offset (allowing for DAYLIGHT Savings)
  57. ;
  58. S1 = S1(N0+1:N0+1)    ; Take hour offset from table
  59. ATOI S1 N0        ; COnvert to binary (w/o error message)
  60. IF FIND S0 "D"          ; Look for daylight savings time
  61.    N0 = N0 - 1        ; Adjust for daylight savings
  62.    ENDIF
  63. ;
  64. ;    Set-up to dial the Naval Observatory
  65. ;
  66. SET FLAG(0) OFF     ; Flag indicates wrap to previous day
  67. ON ESCAPE GOSUB UNAVAILABLE
  68.  
  69. SET BAUD 1200        ; Set parms for USNO (1200,n,8,1)
  70. SET PARITY NONE     ; ..
  71. SET DATA 8        ; ..
  72. SET STOP 1        ; ..
  73. ;
  74. ;    Dial the Naval Observatory
  75. ;
  76.    N99 = 1
  77. LOOP:
  78.    LEGEND "SETTIME v1.0 dialing attempt #"*N99
  79.    TRANSMIT "_MESCa"*"!"; Wake up the modem
  80.    TRANSMIT "_DPREf"*"1-202-653-0351"*"_DSUFf"  ; Dialing command
  81.  
  82.    WAITFOR  "_MCONn"&"" 45 ; Remember to trim trailing blanks
  83.    IF NOT WAITFOR    ; DIAL failed
  84.       TRANSMIT "_MESCa"*"!"
  85.       TRANSMIT "_MHANg" ; Hangup
  86.       INC N99        ; COunt the try
  87.       GOTO LOOP
  88.       ENDIF
  89. ;
  90. ;    Read the UTC
  91. ;
  92. GET_TIME:
  93.    WAITFOR "*" 30
  94.    RGET S0
  95.    RGET S0
  96.    MESSAGE S0
  97.    IF NOT FIND S0(17:19) "UTC"
  98.       GOTO GET_TIME
  99.       ENDIF
  100. ;
  101. ;    Extract the time from the message
  102. ;
  103. ATOI S0(10:11) N1    ; Extract hour #
  104. IF LT N1 N0        ; Test for negative after adjust
  105.    N1 = N1 + 24     ; Ensure positive hour number after adjust
  106.    SET FLAG(0) ON    ; .. and flag the fact
  107.    ENDIF
  108. ;
  109. ;    And give the TIME to DOS
  110. ;
  111. TIME S3 1        ; Save current clock
  112. N1 = N1 - N0        ; Adjust for timezone
  113. S1 = "TIME "*N1&":"&S0(12:13)&":"&S0(14:15)
  114. DOS S1            ; Tell DOS to set the clock
  115. MESSAGE S1        ; Display on screen too
  116. CLOG "* SETTIME clock change from:" *S3*" to "*S1(5:79)
  117. HANGUP
  118. EXIT
  119. ;
  120. ;    Failed DIAL
  121. ;
  122. UNAVAILABLE:
  123.    HANGUP
  124.    MESSAGE "^M^JUnable to reach the Naval Observatory.^M^J"
  125.    EXIT
  126. ;
  127. ;    General exit (modem not connected yet)
  128. ;
  129. EXIT:
  130.    EXIT
  131.