;NBSTIME.ASP v2.20 Sets system clock with NBS time. ;**************************************************************************** ;* * ;* NBSTIME.ASP * ;* Copyright (C) 1992 Datastorm Technologies, Inc. * ;* All rights reserved. * ;* * ;* Purpose: Automatically calls the National Bureau of Standards and * ;* downloads the current time and updates your computer with this time. * ;* * ;* This ASPECT SCRIPT is intended only as a sample of ASPECT programming. * ;* DATASTORM makes no warranty of any kind, express or implied, including * ;* without limitation, any warranties of merchantability and/or fitness * ;* for a particular purpose. Use of this program is at your own risk. * ;* * ;* Authors: Chris Brandow & Tom Stuart * ;* * ;**************************************************************************** ;**************************************************************************** ;* GLOBAL VARIABLES * ;**************************************************************************** integer DaylightSavings = 0, TimeZone = 2, FinishedFlag = 0 string NBSNumber ;**************************************************************************** ;* * ;* Main * ;* The procedure Main sets the default number for the National Bureau of * ;* of Standards, calls the procedure to draw the "dialog box" on the screen,* ;* and then passes control to the HandleEvent routine while checking for the* ;* flag to be set to one indicating the program should finish. * ;* * ;* Calls: DrawDialog, HandleEvent * ;* Modifies globals: NBSNumber * ;* * ;**************************************************************************** proc Main NBSNumber = "13034944774" ;Set the default number call DrawDialog call HandleEvent while FinishedFlag != 1 endwhile clear exit endproc ;**************************************************************************** ;* * ;* DRAWDIALOG * ;* The procedure DrawDialog places the dialog box on the screen for the user* ;* to set up the options needed for the appropriate time to be set. If the * ;* needs to have a dialing prefix like "9," or "8,", he/she can put it into * ;* the number in this box. * ;* * ;* Calls: nothing * ;* Called by: Main * ;* Modifies globals: none * ;* * ;**************************************************************************** proc DrawDialog box 3 16 13 66 00 box 2 14 12 64 79 atsay 2 16 79 "µ National Bureau of Standards Æ" atsay 4 18 64 "NBS Number: " atsay 4 42 64 "Time Zone: " atsay 6 42 79 "Eastern - 1" atsay 7 42 79 "Central - 2" atsay 8 42 79 "Mountain - 3" atsay 9 42 79 "Pacific - 4" atsay 10 42 79 "Exit Script - 0" atsay 8 18 64 "Daylight Savings?" atsay 10 18 79 "Yes - 1 No - 0" endproc ;**************************************************************************** ;* * ;* HANDLEEVENT * ;* The procedure HandleEvent tells us which pushbutton was selected and * ;* acts upon that button with the appropriate action. * ;* * ;* Calls: GetData * ;* Called by: Main * ;* Modifies globals: FinishedFlag, TimeZone, DaylightSavings, NBSNumber * ;* * ;**************************************************************************** proc HandleEvent atget 6 18 79 15 NBSNumber DEFAULT atget 4 53 79 1 TimeZone DEFAULT atget 8 36 79 1 DaylightSavings DEFAULT if TimeZone != 0 ;if 0 entered for timezone call GetData ; return ; else ; FinishedFlag = 1 ; finsihed flag set to one endif endproc ;**************************************************************************** ;* * ;* GETDATA * ;* The procedure GetData will wait to get connected and then trap the first * ;* time information coming in from the National Bureau of Standards and * ;* parse out the hours, minutes, and seconds into separate variables. * ;* * ;* Calls: WhatZone, SetClock * ;* Called by: HandleEvent * ;* Modifies globals: FinishedFlag * ;* * ;**************************************************************************** proc GetData string DataIn = "", NBSHours, NBSMinutes, NBSSeconds, NBSFinal = "" integer NBSintHours, CharTest, Counter set rxdata on ;get ready to accept data mdial NBSNumber ;manual dial the number clear waitfor "T) *^M^J" ;string to waitfor coming in rget DataIn 50 15 ;Get the info hangup ;disconnect from NBS for Counter = 0 upto 35 ;test characters for a ':' strpeek DataIn Counter CharTest if CharTest == 58 ;when found exitfor ; . endif ; . endfor ; . Counter = Counter - 2 ;start extracting the data substr NBSHours DataIn Counter 2 Counter = Counter + 3 substr NBSMinutes DataIn Counter 2 Counter = Counter + 3 substr NBSSeconds DataIn Counter 2 atoi NBSHours NBSintHours ;put hours into integer call WhatZone with &NBSintHours ;figure out the actual # ; of hours if NBSintHours < 0 ;adjust for less than 8 NBSintHours = 24 + NBSintHours endif itoa NBSintHours NBSFinal ;put hours back to string strcat NBSFinal ":" ;make the final string strcat NBSFinal NBSMinutes ; for output to strcat NBSFinal ":" ; the file strcat NBSFinal NBSSeconds call SetClock with NBSFinal ;Call proc to set clock FinishedFlag = 1 ;Set flag = 1 to say success endproc ;**************************************************************************** ;* * ;* WHATZONE * ;* The procedure WhatZone determines what number the hours should be based * ;* on the radio button selection from the dialog box. This is selected * ;* for the correct time zone and will be changed accordingly. Also, the * ;* daylight savings is determined from the checkbox inside the dialog box * ;* as well. * ;* * ;* Calls: nothing * ;* Called by: GetData * ;* Modifies globals: none * ;* * ;**************************************************************************** proc WhatZone intparm NBSintHours switch TimeZone ;Based on time zone. case 1 ; Eastern . if DaylightSavings == 1 ; . NBSintHours = NBSintHours - 4 ; . else ; . NBSintHours = NBSintHours - 5 ;  endif ; . endcase ; . ; . case 2 ; Central . if DaylightSavings == 1 ; . NBSintHours = NBSintHours - 5 ; . else ; . NBSintHours = NBSintHours - 6 ; . endif ; . endcase ;  ; . case 3 ; Mountain . if DaylightSavings == 1 ; . NBSintHours = NBSintHours - 6 ; . else ; . NBSintHours = NBSintHours - 7 ; . endif ; . endcase ;  ; . case 4 ; Pacific . if DaylightSavings == 1 ; . NBSintHours = NBSintHours - 7 ; . else ; . NBSintHours = NBSintHours - 8 ; . endif ;  endcase ; endswitch ;Set the hours to match endproc ;**************************************************************************** ;* * ;* SETCLOCK * ;* The procedure SetClock does the actual setting of the system clock via * ;* a DOS command with a directed filename. The time is stored into the file* ;* in a string format and then the file is piped through the time command. * ;* * ;* Calls: nothing * ;* Called by: GetData * ;* Modifies globals: none * ;* * ;**************************************************************************** proc SetClock strparm NBSFinal fopen 0 "tempnbs.txt" "wt" ;Open the time string file substr NBSFinal NBSFinal 0 8 ;Pull the 8 characters fputs 0 NBSFinal ;Put them in the file fputc 0 13 ;Put in a CR for "enter" fclose 0 ;Close the file dos "time < tempnbs.txt" ;Execute the time command pause 1 delete "tempnbs.txt" ;Delete the time file endproc