home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / settim.zip / SETTIME.WAS < prev   
Text File  |  1993-01-06  |  41KB  |  766 lines

  1. ;SETTIME.WAS v1.00 Sets system clock with NIST ACTS or USNO time.
  2.  
  3. ;****************************************************************************
  4. ;*                                                                          *
  5. ;* SETTIME.WAS                                                              *
  6. ;*                                                                          *
  7. ;* A modification of:                                                       *
  8. ;*       NBS.WAS                                                            *
  9. ;*       Copyright (C) 1992 Datastorm Technologies, Inc.                    *
  10. ;*       All rights reserved.                                               *
  11. ;*                                                                          *
  12. ;* Purpose:  Automatically calls the National Institute of Standards and    *
  13. ;* Technology or the US Naval Observatory and downloads the current time    *
  14. ;* then updates your computer with this time.                               *
  15. ;*                                                                          *
  16. ;* The skeleton of this script was the NBS.WAS script supplied on the CIS   *
  17. ;* DataStorm Forum by DataStorm and was written by Chris Brandow and Tom    *
  18. ;* Stuart.  The original script is copyrighted by DataStorm and was used    *
  19. ;* in this program with the permission of DataStorm.  Special thanks to     *
  20. ;* Paul Heim for his review, comments and recommendations on the script.    *
  21. ;*                                                                          *
  22. ;* Some errors and oversights in the original script have been corrected.   *
  23. ;* The ability to also call the US Naval Observatory was added.  Provision  *
  24. ;* was included to use the script for normal long distance calling, for use *
  25. ;* through a PBX switchboard such as in a hotel and includes the capability *
  26. ;* of using a calling card.  Some additional timezones have been included.  *
  27. ;*                                                                          *
  28. ;* This ASPECT SCRIPT is provided as FREEWARE not requiring registration.   *
  29. ;* There is no warranty of any kind, express or implied, including without  *
  30. ;* limitation, any warranties of merchantability and/or fitness for any     *
  31. ;* particular purpose.  Use of this program is at your own risk.            *
  32. ;*                                                                          *
  33. ;* For true time aficionados we should point out that the Menu choice for   *
  34. ;* "UTC (GMT/Zulu)" time zone is a misnomer.  "GMT" no longer exists, the   *
  35. ;* old Greenwich Observatory having been closed for several years, and even *
  36. ;* then was never really the same as "UTC".  "Zulu" is a common aviation    *
  37. ;* and military acronym for the old "GMT".  The three are considered to be  *
  38. ;* one and the same in typical lay usage today.  Obviously the Daylight     *
  39. ;* Savings toggle will have no effect if the UTC (GMT/Zulu) Time Zone is    *
  40. ;* selected.                                                                *
  41. ;*                                                                          *
  42. ;* The correction factor of 2 seconds applied in procedure GetData is to    *
  43. ;* compensate for typical delays in processing the received time and        *
  44. ;* setting the clock under most circumstances.  If applying this correction *
  45. ;* factor would force the next minute, the correction factor is reduced     *
  46. ;* to not force the next minute, or is ignored.  The correction was based   *
  47. ;* on the use of a 25 MHertz processor.  For faster or slower processors    *
  48. ;* you may want to change the value of 2 in the following define to 1 or 3. *
  49. ;*                                                                          *
  50. ;* Prepared by:  Ralph Deitrick, CompuServe UID 76547,3434                  *
  51. ;* Assisted by:  Paul K. Heim, CompuServe UID 74066,635                     *
  52. ;*                                                                          *
  53. ;****************************************************************************
  54.  
  55. #define Delay 2               ; correction for UTC time to setting clock delay
  56.  
  57. ;**************************  I M P O R T A N T  *****************************
  58. ;*                           ~~~~~~~~~~~~~~~~~                              *
  59. ;*                                                                          *
  60. ;* The "defines" following this information box REQUIRE the input of the    *
  61. ;* user.  The Prefix must contain any dialing prefix required, such as:     *
  62. ;*                                                                          *
  63. ;*     #define NormalPrefix "1 "         (for normal long distance)         *
  64. ;*     #define PBXPrefix "9W "           (for long distance from PBX)       *
  65. ;*     #define CCardPrefix "10288 0 "    (AT&T calling card long distance)  *
  66. ;*                                                                          *
  67. ;* Other Long Distance Service access numbers are:  "10222 0"  for MCI      *
  68. ;*                                                  "10333 0"  for Sprint   *
  69. ;*                                                                          *
  70. ;* If you use some other Long Distance Service you will probably already    *
  71. ;* know the access number or can obtain it from your local operator.  No    *
  72. ;* provision has been included to wait for a second dial tone if using an   *
  73. ;* 800 number access.                                                       *
  74. ;*                                                                          *
  75. ;* It is also necessary to define _your_ calling card number if you plan    *
  76. ;* to use it.  Fill in the Calling Card information as Follows:             *
  77. ;*                                                                          *
  78. ;*     #define CCardNumber "000 000 0000 0000"  (AT&T calling card number)  *
  79. ;*                                                                          *
  80. ;* The pause before sending the Calling Card number is provided by:         *
  81. ;*                                                                          *
  82. ;*     #define DialWait ",,,,,,,,"        (8 commas = 16 seconds)           *
  83. ;*                                                                          *
  84. ;* This is a 16 second pause which may need adjustment for your particular  *
  85. ;* long distance service.  Each *comma* represents a 2 second delay.  Some  *
  86. ;* modems accept the character "$" providing for a wait until the "Bong".   *
  87. ;*                                                                          *
  88. ;* Some PBX exchanges will not accept a long calling card dialing string    *
  89. ;* unless the dialing is performed very slowly ( defined as DialSpeed ).    *
  90. ;* If you need to use very slow speed dialing, make sure the definition of  *
  91. ;* the modem register setting in DialSpeed meets your requirements.         *
  92. ;*                                                                          *
  93. ;* Additionally, any Prefix/Suffix can be specified as a default value to   *
  94. ;* be displayed at program startup by changing the appropriate statement    *
  95. ;* below for UseCard, UsePBX or UseSlow from 0 to 1.                        *
  96. ;*                                                                          *
  97. ;****************************************************************************
  98.  
  99. #define NormalPrefix "1 "
  100. #define PBXPrefix "8 "
  101. #define CCardPrefix "10288 0 "
  102. #define CCardNumber "677 160 2192 6712"
  103. #define CCardWait ",,,,,,,,,"                   ; use "$" _if_ supported
  104. #define DialSpeed "S11=200"
  105. integer UsePBX=0                            ; use PBX prefix   (1), not use (0)
  106. integer UseCard=0                           ; use Calling Card (1), not use (0)
  107. integer UseSlow=0                           ; use Slow Dialing (1), not use (0)
  108.  
  109. ;************  ATTENTION - - - ERROR  CORRECTING  MODEM  USERS  *************
  110. ;*             ~~~~~~~~~       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~              *
  111. ;*                                                                          *
  112. ;* The Nation Institute of Standards and Technology as well as the US Naval *
  113. ;* Observatory time services require the use of non-error-correcting modem  *
  114. ;* connections.  Please verify that the following modem commands are correct*
  115. ;* for your modem or alter the modem commands to be compatible with _your_  *
  116. ;* particular make of modem.  The modem will be reset to your normal Prowin *
  117. ;* initialization condition after completion of resetting the computer time.*
  118. ;*                                                                          *
  119. ;****************************************************************************
  120.  
  121. #define NoEC "ATN0&Q0"                ; Setup for the Gateway 2000 Telepath
  122.  
  123. ;**************************  DEFAULT TIME ZONE  *****************************
  124. ;*                                                                          *
  125. ;* You can set the default time zone to be displayed in the Main Menu at    *
  126. ;* initial startup.  These are also the values that will be used if you     *
  127. ;* select to use automatic operation as discussed below.  Use the TimeZone  *
  128. ;* number listed below in the following "TimeZone =" statement              *
  129. ;*                                                                          *
  130. ;*                           Europe   = 1                                   *
  131. ;*                           UK       = 2                                   *
  132. ;*                           Atlantic = 3                                   *
  133. ;*                           Eastern  = 4                                   *
  134. ;*                           Central  = 5                                   *
  135. ;*                           Mountain = 6                                   *
  136. ;*                           Pacific  = 7                                   *
  137. ;*                           Alaska   = 8                                   *
  138. ;*                           Hawaii   = 9                                   *
  139. ;*                           Japan    = 10                                  *
  140. ;*                           UTC/GMT  = 11                                  *
  141. ;*                                                                          *
  142. ;*  If you wish to include daylight savings time as a default condition,    *
  143. ;*  you should also set the DaylightSavings value below to 1.               *
  144. ;*                                                                          *
  145. ;****************************************************************************
  146.  
  147. integer TimeZone = 9      ;default time zone (Hawaii) to be shown at startup
  148. integer DaylightSavings = 0           ; use daylight savings (1), don't use (0)
  149.  
  150. ;*************************  DEFAULT TIME SERVICE  ***************************
  151. ;*                                                                          *
  152. ;* The default Time Service will be set to USNO in Washington for any Time  *
  153. ;* Zone East of Mountain and to NIST in Boulder for Mountain and all Time   *
  154. ;* Zones West of there.  If you desire a different default Time Service,    *
  155. ;* replace the zero in the >Select = 0< statement below with                *
  156. ;*                                                                          *
  157. ;*                          0 for auto select of NIST or USNO               *
  158. ;*                          1 for NIST in Boulder                           *
  159. ;*                          2 for USNO in Washington                        *
  160. ;*                                                                          *
  161. ;* Again it should be noted that this default value will be used during     *
  162. ;* automatic operation.                                                     *
  163. ;*                                                                          *
  164. ;****************************************************************************
  165.  
  166. integer Select = 2          ; replace with 1 for ACTS (NIST) and 2 for USNO
  167.  
  168. ;**************************  AUTOMATIC  OPERATION  **************************
  169. ;*                                                                          *
  170. ;* If default values have been provided for ALL desired selections, then it *
  171. ;* is possible to make the operation of this program fully automatic.  The  *
  172. ;* defines listed below will determine if the program runs without further  *
  173. ;* user intervention and whether the program returns to the terminal screen *
  174. ;* or exits the Prowin program to Windows.  Once automatic operation is set *
  175. ;* it will be necessary to return to this ASP file to change the selection  *
  176. ;* and then re-compile to discontinue automatic operation.                  *
  177. ;*                                                                          *
  178. ;* If AutoRun is set to >1<, then to run the program from the DOS prompt,   *
  179. ;* issue the command:                                                       *
  180. ;*                           WIN PW SETTIME.WAX                             *
  181. ;*                                                                          *
  182. ;* CAUTION - If you are using a STARTUP.WAX script you may want to consider *
  183. ;*           inactivating it, since it will be run before SETTIME when you  *
  184. ;*           specify the automatic mode of operation. If the script run by  *
  185. ;*           STARTUP automatically returns to terminal without intervention,*
  186. ;*           then there should be no problem.                               *
  187. ;*                                                                          *
  188. ;*         - Use of automatic operation is NOT recommended when using the   *
  189. ;*           comma method of providing a Credit Card wait due to the lack   *
  190. ;*           of consistency in this required delay time period.             *
  191. ;*                                                                          *
  192. ;****************************************************************************
  193.  
  194. integer AutoRun=0                     ; run manually (0), run automatically (1)
  195. integer AutoExit=0                    ; exit to terminal (0), exit to DOS (1)
  196.  
  197. ;****************************************************************************
  198. ;* ADDITIONAL GLOBAL VARIABLES                                              *
  199. ;****************************************************************************
  200.  
  201. #define NISNumber "303 494 4774"
  202. #define NAVNumber "202 653 0351"
  203. long Speed
  204. integer FinishedFlag = 0, UTCintHours, Var
  205. string FonNumber, NewTime, OldTime, Msg1, Msg2, BaudMsg
  206.  
  207. ; ===========================  START OF SCRIPT  =============================
  208.  
  209. ;****************************************************************************
  210. ;*                                                                          *
  211. ;* Main                                                                     *
  212. ;* The procedure Main sets the default number for the National Institute of *
  213. ;* Standards and Technology, stores the user's default initialization string*
  214. ;* and baud rate, puts the dialog box on the screen and clears the screen   *
  215. ;* when finished.  The modem is returned to its original state by a call in *
  216. ;* the GetData procedure.                                                   *
  217. ;*                                                                          *
  218. ;* Calls: DrawDialog, HandleEvent, GetData, StartUp                         *
  219. ;* Modifies globals: Speed                                                  *
  220. ;*                                                                          *
  221. ;****************************************************************************
  222.  
  223. proc Main
  224.  
  225.    clear                                             ; clear the screen
  226.    if Select==0
  227.       if le TimeZone 5
  228.          Select = 2
  229.       else
  230.          Select = 1
  231.       endif
  232.    endif
  233.    call DefineFon                                    ; assemble default phone #
  234.    set terminal type ansibbs                         ; set which clears screen
  235.    fetch baudrate Speed                              ; obtain present baud rate
  236.    when userexit call CleanUp                        ; if "running man" clicked
  237.    when target 0 "UTC" call GetData                  ; prompt on NIST or USNO
  238.    DrawDialog()                                      ; put menu on screen
  239.    if AutoRun == 1
  240.       pause 3
  241.       call HandleEvent
  242.    else
  243.       when dialog call HandleEvent                   ; handles menu selection
  244.    endif
  245.    while FinishedFlag != 1                           ; loop until finished
  246.    endwhile
  247.    call ReSet                                        ; modem to original state
  248.    clear                                             ; clear the screen
  249.    if AutoExit == 1
  250.       closePW                                        ; finish and leave PW
  251.    else
  252.       halt                                           ; finish & go to terminal
  253.    endif
  254.  
  255. endproc ;Main
  256.  
  257. ;****************************************************************************
  258. ;*                                                                          *
  259. ;* DRAWDIALOG                                                               *
  260. ;* The procedure DrawDialog places the dialog box on the screen for the     *
  261. ;* user to set up the options needed for the appropriate time to be set     *
  262. ;* and selecting which time service to use.  The phone number is presented  *
  263. ;* in an editbox so that any prefix or suffix can be modified.              *
  264. ;*                                                                          *
  265. ;* Calls: nothing                                                           *
  266. ;* Called by: Main                                                          *
  267. ;* Modifies globals: DaylightSavings, TimeZone, FonNumber, UsePBX, UseCard, *
  268. ;*                   UseSlow                                                *
  269. ;*                                                                          *
  270. ;****************************************************************************
  271.  
  272. proc DrawDialog
  273.  
  274.    dialogbox 2 40 185 182 7 "Clock Reset Program"
  275.       groupbox 5 5 75 172 "Time Zone"
  276.       radiobutton 10 20 45 10 "Eu&rope" TimeZone
  277.       radiobutton 10 33 45 10 "&UK"
  278.       radiobutton 10 46 45 10 "&Atlantic"
  279.       radiobutton 10 59 45 10 "&Eastern"
  280.       radiobutton 10 72 45 10 "Ce&ntral"
  281.       radiobutton 10 85 45 10 "&Mountain"
  282.       radiobutton 10 98 45 10 "&Pacific"
  283.       radiobutton 10 111 45 10 "Alas&ka"
  284.       radiobutton 10 123 45 10 "&Hawaii"
  285.       radiobutton 10 136 45 10 "&Japan"
  286.       radiobutton 10 149 68 10 "U&TC (GMT/Zulu)" endgroup
  287.       checkbox 10 162 68 10 "Daylight &Savings" DaylightSavings
  288.       groupbox 85 5 95 72 "ACTS Service"
  289.       radiobutton 90 20 83 10 "NIST, &Boulder,CO" Select
  290.       radiobutton 90 35 88 10 "USNO, &Washington,DC" endgroup
  291.       text 90 50 83 9 left "Number can be edited:"
  292.       editbox 88 60 89 12 FonNumber
  293.       groupbox 85 85 95 60 "Dialing Prefix/Suffix"
  294.       checkbox 90 100 83 10 "Use PB&X dialing" UsePBX
  295.       checkbox 90 115 83 10 "&Include Calling Card" UseCard
  296.       checkbox 90 130 83 10 "&Low Speed dialing" UseSlow
  297.       pushbutton 85 155 45 14 "&Dial" normal default
  298.       pushbutton 135 155 45 14 "&Cancel" normal
  299.    enddialog
  300.  
  301. endproc
  302.  
  303. ;****************************************************************************
  304. ;*                                                                          *
  305. ;* HANDLEEVENT                                                              *
  306. ;* The procedure HandleEvent tells which pushbutton was selected and acts   *
  307. ;* upon that button with the appropriate action.                            *
  308. ;*                                                                          *
  309. ;* Calls: ReSet                                                             *
  310. ;* Called by: Main                                                          *
  311. ;* Modifies globals: FinishedFlag, FonNumber                                *
  312. ;*                                                                          *
  313. ;****************************************************************************
  314.  
  315. proc HandleEvent
  316.    integer Choice
  317.  
  318.    if AutoRun == 1
  319.       Choice = 10
  320.    else
  321.       Choice = $DIALOG
  322.    endif
  323.    switch Choice
  324.       case 10                                  ; if Dial was hit
  325.          destroydlg                            ; remove menu display
  326.          dialogbox 2 80 100 20 7 "PROGRESS REPORT"
  327.             text 20 5 60 12 center "Preparing Modem"
  328.          enddialog
  329.          pause 2
  330.          call StartUp                          ; initialize modem for non EC
  331.          destroydlg                            ; remove progress report
  332.          dialogbox 2 80 120 65 7 "MODEM SETUP STATUS"
  333.             text 20  5 80 12 center "Baudrate set to 1200"
  334.             text 20 20 80 12 center "No Error Correction"
  335.             text 20 35 80 12 center "No Data Compression"
  336.             text 20 50 80 12 center "Flow control disabled"
  337.          enddialog
  338.          pause 4                               ; provide reading time
  339.          destroydlg                            ; remove setup status message
  340.          fetch dialdir maxdial I0
  341.          set dialdir maxdial 3
  342.          dialnumber FonNumber                  ;   repeat dial the number
  343.          while $dialing                        ; wait for dialing completion
  344.          endwhile
  345.          if not $carrier
  346.             DrawDialog()
  347.             pause 3
  348.             FinishedFlag = 1                   ;   set flag to quit
  349.          endif
  350.          set dialdir maxdial I0
  351.       endcase
  352.  
  353.       case 11                                  ; if Cancel was hit
  354.          hangup                                ;   hangup line
  355.          while $carrier                        ; wait until off line
  356.          endwhile
  357.          FinishedFlag = 1                      ;   set flag to quit
  358.       endcase
  359.    endswitch
  360.    call DefineFon
  361.    updatedlg 128                               ; update phone number in menu
  362. endproc ;HandleEvent
  363.  
  364. ;****************************************************************************
  365. ;*                                                                          *
  366. ;* DEFINEFON                                                                *
  367. ;* The procedure DefineFon assembles the various components of the phone    *
  368. ;* number to be dialed.                                                     *
  369. ;*                                                                          *
  370. ;* Calls: none                                                              *
  371. ;* Called by: Main, HandleEvent                                             *
  372. ;* Modifies globals: FonNumber                                              *
  373. ;*                                                                          *
  374. ;****************************************************************************
  375.  
  376. proc DefineFon
  377.  
  378.    if UsePBX==1                                ; if using PBX
  379.       if UseCard==1                            ;         and using Calling Card
  380.          strfmt FonNumber "%s%s" PBXPrefix CCardPrefix
  381.       else                                     ; case of not using calling Card
  382.          strfmt FonNumber "%s%s" PBXPrefix NormalPrefix
  383.       endif
  384.    else                                        ; otherwise, if NOT using PBX
  385.       if UseCard==1                            ;    but ARE using Calling Card
  386.          FonNumber=CCardPrefix
  387.       else                                     ; NOT using PBX NOR CallingCard
  388.          FonNumber=NormalPrefix
  389.       endif
  390.    endif
  391.    if Select==1
  392.       strcat FonNumber NISNumber
  393.    endif
  394.    if Select==2
  395.       strcat FonNumber NAVNumber
  396.    endif
  397.    if UseCard==1
  398.       strcat FonNumber CCardWait
  399.       strcat FonNumber CCardNumber
  400.    endif
  401.  
  402. endproc ;DefineFon
  403.  
  404. ;****************************************************************************
  405. ;*                                                                          *
  406. ;* GETDATA                                                                  *
  407. ;* The procedure GetData will wait to get connected and then trap the first *
  408. ;* time information coming in from the National Bureau of Standards or the  *
  409. ;* Naval Observatory and parse out the hours, minutes, and seconds into     *
  410. ;* separate variables.                                                      *
  411. ;*                                                                          *
  412. ;* Calls: WhatZone, SetClock, ReSet Report                                  *
  413. ;* Called by: Main                                                          *
  414. ;* Modifies globals: FinishedFlag, UTCintHourd, OldTime, NewTime, DataFlag  *
  415. ;*                                                                          *
  416. ;****************************************************************************
  417.  
  418. proc GetData
  419. string DataIn = "", UTCHours, UTCMinutes, UTCSeconds, UTCFinal = "", Char
  420. integer UTCintSeconds, Len
  421.  
  422.    clearwhen target 0
  423.    dialogbox 2 20 100 20 7 "PROGRESS REPORT"
  424.       text 20 5 60 12 center "Acquiring Data"
  425.    enddialog
  426.    waitfor "UTC" 1
  427.    set aspect rxdata on                          ; script handles incoming data
  428.    pause 1
  429.    comgets DataIn 40 3                           ; Get the time data
  430.    set aspect rxdata off                         ; Prowin handles incoming data
  431.    hangup                                        ; disconnect from service
  432.    switch Select
  433.       case 1
  434.          strdelete DataIn 0 24                   ; pull out important item
  435.          strdelete DataIn 9 8
  436.          strextract UTCHours DataIn ":" 0        ; separate hours
  437.          strextract UTCMinutes DataIn ":" 1      ; separate minutes
  438.          strextract UTCSeconds DataIn ":" 2      ; separate seconds
  439.          substr UTCSeconds UTCSeconds 0 2        ; delete extra characters
  440.       endcase
  441.       case 2
  442.          strdelete DataIn 0 15                   ; pull out important item
  443.          strdelete DataIn 6 19
  444.          substr UTCHours DataIn 0 2              ; separate hours
  445.          substr UTCMinutes DataIn 2 2            ; separate minutes
  446.          substr UTCSeconds DataIn 4 2            ; separate seconds
  447.       endcase
  448.    endswitch
  449.    atoi UTCHours UTCintHours                     ; put hours into integer
  450.    call WhatZone                                 ; figure actual # of hours
  451.    if UTCintHours < 0                            ; adjust for less than 8
  452.       UTCintHours = 24 + UTCintHours
  453.    endif
  454.    itoa UTCintHours UTCFinal                     ; put hours back to string
  455.    atoi UTCSeconds UTCintSeconds                 ; put seconds into integer
  456.    UTCintSeconds = UTCintSeconds + Delay         ; add 2 sec delay encountered
  457.    itoa UTCintSeconds UTCSeconds                 ; put seconds into string
  458.    strlen UTCSeconds Len
  459.    if Len==1
  460.       Char="0"
  461.       strcat Char UTCSeconds
  462.       UTCSeconds=Char
  463.    endif
  464.    if UTCintSeconds > 59                         ; don't let 2 second addition
  465.       UTCSeconds="59"                            ;      exceed 59 minutes
  466.    endif
  467.    strcat UTCFinal ":"                           ; make the final string
  468.    strcat UTCFinal UTCMinutes                    ;     for output to
  469.    strcat UTCFinal ":"                           ;          the file
  470.    strcat UTCFinal UTCSeconds
  471.    strlen UTCFinal Len
  472.    if Len==7                                     ; does hours only have 1 digit
  473.       NewTime="0"
  474.    else                                          ; hours is double digit
  475.       NewTime=""
  476.    endif
  477.    strcat NewTime UTCFinal                       ; add the time data
  478.    destroydlg
  479.    strfmt Msg1 "to %s" UTCFinal
  480.    dialogbox 2 80 100 35 7 "PROGRESS REPORT"
  481.       text 20 5 60 12 center "Resetting Clock"
  482.       vtext 20 20 60 12 center Msg1
  483.    enddialog
  484.    OldTime=$time24                               ; system time before resetting
  485.    substr OldTime Oldtime 0 8
  486.    Call SetClock                                 ; Call proc to set clock
  487.    destroydlg                                    ; remove Progress dialog box
  488.    call Report                                   ; summarize results on screen
  489.    DrawDialog()
  490.    pause 3
  491.    FinishedFlag = 1                              ; Set flag = 1 to say finish
  492.  
  493. endproc ;GetData
  494.  
  495. ;****************************************************************************
  496. ;*                                                                          *
  497. ;* WHATZONE                                                                 *
  498. ;* The procedure WhatZone determines what number the hours should be based  *
  499. ;* on the radio button selection from the dialog box.  This is selected     *
  500. ;* for the correct time zone and will be changed accordingly.  Also, the    *
  501. ;* daylight savings is determined from the checkbox inside the dialog box   *
  502. ;* as well.                                                                 *
  503. ;*                                                                          *
  504. ;* Calls: nothing                                                           *
  505. ;* Called by: GetData                                                       *
  506. ;* Modifies globals: UTCintHours                                            *
  507. ;*                                                                          *
  508. ;****************************************************************************
  509.  
  510. proc WhatZone
  511.  
  512.    switch TimeZone                               ; Based on time zone
  513.       case 1                                     ;   Europe
  514.          if DaylightSavings == 1                 ;   "Summer" time
  515.             UTCintHours = UTCintHours - 22
  516.          else
  517.             UTCintHours = UTCintHours - 23
  518.          endif
  519.       endcase
  520.  
  521.       case 2                                     ;   UK
  522.          if DaylightSavings == 1                 ;   "Summer" time
  523.             UTCintHours = UTCintHours - 23
  524.          else
  525.             UTCintHours = UTCintHours
  526.          endif
  527.       endcase
  528.  
  529.       case 3                                     ;   Atlantic
  530.          if DaylightSavings == 1
  531.             UTCintHours = UTCintHours - 3
  532.          else
  533.             UTCintHours = UTCintHours - 4
  534.          endif
  535.       endcase
  536.  
  537.       case 4                                     ;   Eastern
  538.          if DaylightSavings == 1
  539.             UTCintHours = UTCintHours - 4
  540.          else
  541.             UTCintHours = UTCintHours - 5
  542.          endif
  543.       endcase
  544.  
  545.       case 5                                     ;   Central
  546.          if DaylightSavings == 1
  547.             UTCintHours = UTCintHours - 5
  548.          else
  549.             UTCintHours = UTCintHours - 6
  550.          endif
  551.       endcase
  552.  
  553.       case 6                                     ;   Mountain
  554.          if DaylightSavings == 1
  555.             UTCintHours = UTCintHours - 6
  556.          else
  557.             UTCintHours = UTCintHours - 7
  558.          endif
  559.       endcase
  560.  
  561.       case 7                                     ;   Pacific
  562.          if DaylightSavings == 1
  563.             UTCintHours = UTCintHours - 7
  564.          else
  565.             UTCintHours = UTCintHours - 8
  566.          endif
  567.       endcase
  568.  
  569.       case 8                                     ;   Alaska
  570.          if DaylightSavings == 1
  571.             UTCintHours = UTCintHours - 8
  572.          else
  573.             UTCintHours = UTCintHours - 9
  574.          endif
  575.       endcase
  576.  
  577.       case 9                                     ;   Hawaii
  578.          if DaylightSavings == 1
  579.             UTCintHours = UTCintHours - 9
  580.          else
  581.             UTCintHours = UTCintHours - 10
  582.          endif
  583.       endcase
  584.  
  585.       case 10                                    ;   Japan
  586.          if DaylightSavings == 1
  587.             UTCintHours = UTCintHours - 13
  588.          else
  589.             UTCintHours = UTCintHours - 14
  590.          endif
  591.       endcase
  592.  
  593.       case 11                                    ;   UTC - old GMT
  594.          UTCintHours = UTCintHours               ; (no daylight savings adjust)
  595.       endcase
  596.    endswitch                                     ; Set the hours to match
  597.  
  598. endproc
  599.  
  600. ;****************************************************************************
  601. ;*                                                                          *
  602. ;* SETCLOCK                                                                 *
  603. ;* The procedure SetClock does the actual setting of the system clock via a *
  604. ;* DOS command with a directed filename.  The time is stored into the file  *
  605. ;* in a string format and then the file is piped through the time command.  *
  606. ;*                                                                          *
  607. ;* Calls: nothing                                                           *
  608. ;* Called by: GetData                                                       *
  609. ;* Modifies globals: None                                                   *
  610. ;*                                                                          *
  611. ;****************************************************************************
  612.  
  613. proc SetClock
  614.  
  615.    fopen 0 "temp.txt" CREATE TEXT                ; Open the time string file
  616.    fputs 0 NewTime                               ; Put them in the file
  617.    fclose 0                                      ; Close the file
  618.    dos "time < temp.txt" HIDDEN                  ; Execute the time command
  619.    pause 5
  620.    delfile "temp.txt"                            ; Delete the time file
  621.  
  622. endproc ;SetClock
  623.  
  624. ;****************************************************************************
  625. ;*                                                                          *
  626. ;* STARTUP                                                                  *
  627. ;* The procedure StartUp obtains and saves the baud rate and initialization *
  628. ;* string to be used for restoring the modem state at script completion.    *
  629. ;* The modem is reset to a non-error-correcting condition and baud rate is  *
  630. ;* set to the required value of 1200.                                       *
  631. ;*                                                                          *
  632. ;* Calls: nothing                                                           *
  633. ;* Called by: HandleEvent                                                   *
  634. ;* Modifies globals: none                                                   *
  635. ;*                                                                          *
  636. ;****************************************************************************
  637.  
  638. proc StartUp
  639.  
  640.    set port databits 8                           ; set databits
  641.    set port duplex full                          ; set full duplex
  642.    set port parity none                          ; set parity none
  643.    set port stopbits 1                           ; set stopbits
  644.    set terminal enquiry off                      ; enquiry off avoids noise ^e
  645.    set baudrate 1200                             ; set required baud rate
  646.    transmit NoEC                                 ; turn off error correction
  647.    transmit "^M"
  648.    waitfor "OK"                                  ; wait for modem to finish
  649.    if UseSlow==1
  650.       transmit "AT"
  651.       transmit DialSpeed
  652.       transmit "^M"
  653.       waitfor "OK"                               ; wait for modem to finish
  654.    endif
  655.  
  656. endproc ;StartUp
  657.  
  658. ;****************************************************************************
  659. ;*                                                                          *
  660. ;* RESET                                                                    *
  661. ;* The procedure ReSet returns the modem to the original baud rate and      *
  662. ;* re-initializes it to provide the original error correction status.       *
  663. ;*                                                                          *
  664. ;* Calls: nothing                                                           *
  665. ;* Called by: Main                                                          *
  666. ;* Modifies globals: none                                                   *
  667. ;*                                                                          *
  668. ;****************************************************************************
  669.  
  670. proc ReSet
  671.  
  672.    dialogbox 2 80 100 20 7 "PROGRESS REPORT"
  673.       text 20 5 60 12 center "Resetting Modem"
  674.    enddialog
  675.    set baudrate speed                            ; reset original baud rate
  676.    fetch modem init S0                           ; obtain initialization string
  677.    transmit "ATZ^M"                              ;in case not in initialization
  678.    waitfor "OK"                                  ; wait for modem to finish
  679.    pause 1
  680.    set txpace 100
  681.    transmit S0                                   ; re-initialize modem
  682.    transmit "^M"
  683.    waitfor "OK"                                  ; wait for modem to finish
  684.    set txpace 0
  685.    pause 1
  686.    destroydlg                                    ; remove Progress dialog box
  687.    strfmt BaudMsg "Baudrate reset to %d" Speed        ; original Baudrate
  688.    dialogbox 2 80 120 55 7 "MODEM SETUP STATUS"
  689.       vtext 20 8 80 10 center BaudMsg
  690.       text 20 25 80 10 center "Prowin initialization"
  691.       text 20 37 80 10 center "condition restored"
  692.    enddialog
  693.    pause 5
  694.  
  695. endproc ;ReSet
  696.  
  697. ;****************************************************************************
  698. ;*                                                                          *
  699. ;* REPORT                                                                   *
  700. ;* The procedure Report places a dialog box on the screen to display the    *
  701. ;* DOS clock reading before resetting and the time value used to reset the  *
  702. ;* clock.                                                                   *
  703. ;*                                                                          *
  704. ;* Calls: nothing                                                           *
  705. ;* Called by: GetData                                                       *
  706. ;* Modifies globals: Msg1, Msg2                                             *
  707. ;*                                                                          *
  708. ;****************************************************************************
  709.  
  710. proc Report
  711.  
  712.    clearwhen dialog                                   ; stop using HandleEvent
  713.    strfmt Msg1 "DOS TIME WAS   %s" OldTime            ; original DOS time value
  714.    strfmt Msg2 "TIME RESET TO  %s" NewTime            ; reset value of time
  715.    dialogbox 130 90 100 50 14 "TIME RESET RESULT"     ; produce dialog box
  716.     vtext 5 5 110 8 left Msg1
  717.     vtext 5 15 110 8 left Msg2
  718.     pushbutton 30 30 40 15 "&Proceed" normal default
  719.    enddialog
  720.    Var = 8
  721.    while $dialog != 10                                ; wait for pushbutton
  722.       if Var ==0
  723.          exitwhile
  724.       else
  725.          Pause 1
  726.          dec Var
  727.        endif
  728.    endwhile
  729.    destroydlg                                         ; remove dialog box
  730.  
  731. endproc ;Report
  732.  
  733. ;****************************************************************************
  734. ;*                                                                          *
  735. ;* CLEANUP                                                                  *
  736. ;* The procedure CleanUp is accessed if the user exits the script in an     *
  737. ;* unexpected manner such as clicking on the running man and makes sure     *
  738. ;* the modem is returned to its original state.                             *
  739. ;*                                                                          *
  740. ;* Calls: ReSet                                                             *
  741. ;* Called by: Main                                                          *
  742. ;* Modifies globals: none                                                   *
  743. ;*                                                                          *
  744. ;****************************************************************************
  745.  
  746. proc CleanUp
  747.  
  748.    destroydlg                          ; remove any dialog box on screen
  749.    clearwhen dialog                    ; shut down
  750.    clearwhen target 0                  ;           any open
  751.    clearwhen userexit                  ;                    when statements
  752.    set aspect rxdata off               ; make sure Prowin handles incoming data
  753.    hangup                              ; make sure phone is on hook
  754.    call ReSet                                        ; modem to original state
  755.    clear                                             ; clear the screen
  756.    if AutoExit == 1
  757.       closePW                                        ; finish and leave PW
  758.    else
  759.       halt                                           ; finish & go to terminal
  760.    endif
  761.  
  762. endproc ;CleanUp
  763.  
  764. ;             ============  end of script  ===============
  765.  
  766.