$ ! C L O C K . C O M $ ! $ ! Written by dave walp $ ! assumes the terminal is a vt100. $ SET NOVERIFY $ ON CONTROL_Y THEN GOTO abort $ $ !---------------------------------------------------------------------------- $ ! $ ! This first section sets up the two variables. $ ! update = the update delay time ( a period between 1 and 59 sec.) $ ! alarm = a option stoping time ( rings terminal bell and exit program ) $ ! $ ! These variables can be gotten from the command line or the users can be $ ! prompted for values ( defaults exist if the users just types return $ ! when he is being prompted ) $ ! $ ! There are validity checks for values of the variable. The user will $ ! be prompted until the a correct value is given. $ ! $ !---------------------------------------------------------------------------- $ $ ! assume there is no parameters on the command line $ comLine := F $ $ ! no parameters on the command line, prompt users for parameters $ IF P1 .EQS. "" THEN GOTO prompt $ $ ! put params into variables and flag there were params on command line $ update := 'P1' $ alarm := 'P2' $ comLine := T $ GOTO testUp $ $ prompt: $ ! clear the screen and go home $ WRITE SYS$OUTPUT "" $ $ getUp: $ ! prompt the user for the update iterval $ INQUIRE update "$_Update Interval < SS > " $ $ testUp: $ ! test if the update value is alright $ $ ! use default value if users types $ IF update .EQS. "" THEN update = 50 $ $ ! test for range and if ok go to seting alarm variable $ IF ( update .GE. 1 ) .AND. ( update .LE. 59 ) THEN GOTO setA $ $ ! value was bad, give error and reprompt for value $ WRITE SYS$OUTPUT "Update Interval must be between 1 and 59 seconds!" $ GOTO getUp $ $ setA: $ ! if there parameters on the command line goto $ ! directly to testing the value without prompting $ IF comLine .EQS. "T" THEN GOTO testA $ $ getA: $ ! prompt the user for the alarm time $ INQUIRE alarm "$_Alarm Time < HH:MM > " $ $ testA: $ ! if users typed just to the prompt OR $ ! if there was no second parameter on the command line $ ! THEN use default value ( No alarm ) and goto seting up clock screen $ IF alarm .NES. "" THEN GOTO noDefault $ alarm := 99:99 $ GOTO setScreen $ $ noDefault: $ ! test the validity of the alarm time $ $ ! append a zero to the front of the time if required $ IF 'F$LENGHT(alarm) .EQ. 4 THEN alarm := "0" + alarm $ $ ! size of the time must be 5 characters $ IF 'F$LENGHT(alarm) .NE. 5 THEN GOTO errorA $ $ ! find the colan in the time $ colan = 'F$LOCATE(":",alarm) $ ! the colan must be the third character $ IF colan .NE. 2 THEN GOTO errorA $ $ ! test the hour portion of the time $ hour = 'F$EXTRACT(0,2,alarm) $ IF (hour .LT. 0) .OR (hour .GT. 23) THEN GOTO errorA $ $ ! test the minute portion of the time $ min = 'F$EXTRACT(3,2,alarm) $ IF (min .GE. 0 ) .AND. (min .LE. 59) THEN GOTO setScreen $ $ errorA: $ ! a error has been found give error message and try again $ WRITE SYS$OUTPUT "Alarm time must be in 24 hour time. """Hours:Minutes""" " $ GOTO getA $ $ $ setScreen: $ $ !---------------------------------------------------------------------------- $ ! $ ! This section of the program paints the screen $ ! $ ! See VT100 manual for escape sequences $ ! $ !---------------------------------------------------------------------------- $ $ ! clear screen, alternate character set, 80 column width, black background $ ! and reverse write $ WRITE SYS$OUTPUT ")0[?5;3l[?6l" $ SET TERM/WIDTH=80 $ $ ! write space in correct places $ ! turn bold on and write more spaces $ ! turn reverse off and write lines via graphic set $ ! write inner decore $ ! set scrolling region, turn bold off and sign it $ TYPE SYS$INPUT #6 #4  #3  #6 #6 #6 #3oooooooooooooooooooooooooooooooo #3qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq  >`< >`<  ~>`<~ ~>`<~  $ $ $ !---------------------------------------------------------------------------- $ ! $ ! This section updates the time displayed and the led $ ! $ !---------------------------------------------------------------------------- $ $ ! set up the initial values for the LEDS and old values $ led = 0 $ shift = 1 $ oldHour = 99 $ oldNow := 99:99 $ $ lChar := "+" $ $ ! Top of the loop $ top: $ $ ! assume no changes ( null writes ) $ timeStr := $ charStr1 := $ charStr2 := $ $ ! get the time and see if hour minutes have changed $ now := 'F$TIME() $ COLON = 'F$LOCATE(":",now)-2 $ newNow := 'F$EXTRACT(COLON,5,now) $ IF oldNow .EQS. newNow THEN GOTO setLeds $ $ ! reset the old $ oldNow := newNow $ $ ! repaint the innner decore of the clock $ $ ! find the characters in the sequence $ IF lChar .NES. ">" THEN GOTO tryStar $ lChar := "*" $ rChar := "*" $ GOTO gotChar $ tryStar: $ IF lChar .NES. "*" THEN GOTO isPlus $ lChar := "+" $ rChar := "+" $ GOTO gotChar $ isPlus: $ lChar := ">" $ rChar := "<" $ $ gotChar: $ ! create the print strings $ charStr1 := ""'lchar'""'rchar'""'lchar'""'rchar' $ charStr2 := ""'lchar'""'rchar'""'lchar'""'rchar'"" $ $ ! extract the hour portion from the time $ hour = 'F$EXTRACT(0,2,newNow) $ $ ! check if the hour has changed $ IF hour .EQ. oldHour THEN GOTO setMin $ $ ! save the new value $ oldHour = hour $ $ ! assign the correct postFix $ post := "PM" $ IF hour .LE. 11 THEN post := "AM" $ $ printHour = hour $ ! convert from 24 hour time to 12 hour time $ IF printHour .GT. 12 THEN printHour = printHour - 12 $ $!!!! IF 'F$EXTRACT(0,1,printHour) .EQS. "0" THEN printHour = printHour - "0" $ $ ! padd if needed $ IF printHour .LT. 10 THEN printHour := " ''printHour'" $ $ setMin: $ ! set up the time displayed $ time := "''printHour'''F$EXTRACT(2,3,newNow)' ''post'" $ timeStr := " "'time'"  "'time'" " $ $ setLeds: $ ! set up the spining lights $ $ ! assume they are not going to be cleared $ clearLed := $ $ ! test for left boundery condition $ IF (led .NE. 1) .OR. (shift .NE. -1) THEN GOTO notLeft $ shift = 1 $ led = 0 $ clearLed := 0; ! to clear the leds $ GOTO notRight $ $ ! test for right boundery condition $ notLeft: $ IF (led .NE. 4) .OR. (shift .NE. 1) THEN GOTO notRight $ shift = -1 $ led = 5 $ clearLed := 0; ! to clear the leds $ $ notRight: $ ! shift the current led $ led = led + shift $ ledStr := "[''clearLed'''led'q" $ $ ! Display the the time and work the lights $ WRITE SYS$OUTPUT charStr1, charStr2, ledStr, timeStr, "" $ $ ! Check to see if alarm should go off $ IF newNow .GES. alarm THEN GOTO done $ $ ! Wait x amount of seconds (so we do not gobble up cpu time) $ WAIT 00:00:'update' $ GOTO top $ $ !---------------------------------------------------------------------------- $ ! $ ! this section cleans up the screen and exits $ ! $ !---------------------------------------------------------------------------- $ $ done: $ ! ring the bell first ( used then alarm goes off ) $ WRITE SYS$OUTPUT "" $ $ abort: $ WRITE SYS$OUTPUT "" $!!!! IF WIDE THEN SET TERM/WIDTH=132 $!!!! WHERE