[futurebasic] Re: [FB] Adjusting time

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 1999 : Group Archive : Group : All Groups

From: Joe Lewis Wilkins <PepeToo@...>
Date: Sun, 22 Aug 1999 23:18:00 -0700
Ooops! Forgot to fix AM to PM and PM to AM. Use following instead of previous.
Also not sure that 12 is represented is consistantly. You'll have to check to
see that all conditions are covered.

Joe Wilkins

'------------------ Globals -------------------------
DIM gProgramEnds
DIM gZone%
END GLOBALS
gZone% = 2                                        'Default
'------------------ Functions -----------------------
LOCAL FN mainWindow
  WINDOW #1,"Time Adjuster Demo", (6,40)-(295,280), _docNoGrow
  TEXT _geneva, 12

  MENU 1,0,_enable,"File"
  MENU 1,1,_enable,"Quit/Q"

  EDIT FIELD #1,"Current System Time:",(10,20)-(170,37),_statNoFramed,
_rightJust
  EDIT FIELD #2,"",(175,20)-(275,37),_statFramed, _centerJust
  EDIT FIELD #3,"Time Adjustment Factor:",(10,54)-(170,71),_statNoFramed,
_rightJust
  EDIT FIELD #4,"0",(175,54)-(275,71),_statFramed, _centerJust
  EDIT FIELD #5,"Adjusted Time:",(10,86)-(170,103),_statNoFramed, _rightJust
  EDIT FIELD #6,"",(175,86)-(275,103),_statFramed, _centerJust

  EDIT FIELD #7,"Demo written for Eastern Time
Zone.",(10,210)-(275,225),_statNoFramed, _centerJust

  BUTTON #1, _activeBtn,"Atlantic time",(25,120)-(145,135),_radio
  BUTTON #2, _markedBtn,"Eastern time",(150,120)-(280,135),_radio
  BUTTON #3, _activeBtn,"Central time",(25,140)-(145,165),_radio
  BUTTON #4, _activeBtn,"Mountain time",(150,140)-(280,165),_radio
  BUTTON #5, _activeBtn,"Pacific time",(25,160)-(145,195),_radio

  BUTTON #6, 1,"Quit",(220,178)-(275,198),_shadow

  WINDOW #1

END FN

LOCAL FN adjustTime$
  currTime$ = EDIT$(2)
  amPM$ = RIGHT$(currTime$,2)
  hrs% = VAL(currTime$)
  SELECT gZone%
    CASE 1: adjHrs% = hrs% + 1
    CASE 2: adjHrs% = hrs%
    CASE 3: adjHrs% = hrs% - 1
    CASE 4: adjHrs% = hrs% - 2
    CASE 5: adjHrs% = hrs% - 3
  END SELECT
  '
  IF adjHrs% > 12 THEN adjHrs% = adjHrs% - 11
  LONG IF adjHrs% > 9
    adjustTime$ = RIGHT$(STR$(adjHrs%),2) + MID$(currTime$,3,6)
  XELSE
    adjustTime$ = "0"+RIGHT$(STR$(adjHrs%),1) + MID$(currTime$,3,6)
  END IF
  '
  LONG IF hrs% > adjHrs%
    LONG IF amPM$ = "AM"
       amPM$ = "PM"
    XELSE
      amPM$ = "AM"
    END IF
  END IF
  adjustTime$ = adjustTime$+" "+amPM$
END FN = adjustTime$


LOCAL FN doTimer
  t$ = TIME$
  hrs% = VAL(t$)
  LONG IF hrs% >12
    hrs% = hrs% - 12
    LONG IF hrs% > 9
      t$ = MID$(STR$(hrs%),2,2) + RIGHT$(t$,6) + " PM"
    XELSE
      t$ = MID$(STR$(hrs%),2,1) + RIGHT$(t$,6) + " PM"
    END IF
  XELSE
    t$ = t$ + " AM"
  END IF
  '
  EDIT$(2) = t$
  aStr$ = FN adjustTime$
  EDIT$(6) = aStr$
END FN


LOCAL FN radioGroup (btnClicked, first, last)
  FOR btnNum = first TO last
    LONG IF BUTTON(btnNum) = _markedBtn
      BUTTON #btnNum, _activeBtn
    END IF
  NEXT btnNum
  BUTTON # btnClicked, _markedBtn
END FN


LOCAL FN doDialog
  evnt = DIALOG(0)
  id = DIALOG(evnt)
  SELECT evnt
    CASE _wndClose
      WINDOW CLOSE #1
      gProgramEnds = true
    CASE _btnClick
      SELECT id
        CASE(1)
          FN radioGroup(1, 1, 5)
          EDIT$(4) = "+1 hour change"
        CASE(2)
          FN radioGroup(2, 1, 5)
          EDIT$(4) = "0 hour change"
        CASE(3)
          FN radioGroup(3, 1, 5)
          EDIT$(4) = "-1 hour change"
        CASE(4)
          FN radioGroup(4, 1, 5)
          EDIT$(4) = "-2 hour change"
        CASE(5)
          FN radioGroup(5, 1, 5)
          EDIT$(4) = "-3 hour change"
        CASE(6)
          gProgramEnds = true
      END SELECT
      gZone% = id
      FN doTimer
  END SELECT
END FN

LOCAL FN doMenu
  menuID% = MENU(_menuID)
  itemID% = MENU(_itemID)
  IF menuID% = 1 AND itemID% = 1 THEN END
  MENU
END FN

'---------------------- Main -------------------------
WINDOW OFF
COORDINATE WINDOW

ON DIALOG FN doDialog
ON MENU FN doMenu
ON TIMER(1) FN doTimer

FN mainWindow

DO
  HANDLEEVENTS
UNTIL gProgramEnds
END