!**************************************************************************************************!
! author : ADW
!
! purpose: test TVAL GCONTROLS
!**************************************************************************************************!
startmacro
  set L:failedTests 0
  switch INTERACTIVE interAct GET DEF=TRUE
  if interAct then
    res instructions "Use the GValue widgets to increment the TVAL's below. \n\n&
                      The Default time should be 00:00:00 and should increment by &
                      seconds. \n\n&
                      Time 1 & 2 should display the time at which the test case &
                      was initialized. \n\n&
                      Time 1 should increment by seconds. \n\n&
                      Time 2 should increment by 10 seconds. \n\n&
                      Date & Time 1 & 2 should display the date and time at which &
                      the test case was initialized. \n\n&
                      Date & Time 1 should increment by minutes. \n\n&
                      Date & Time 2 should increment by hours. \n\n&
                      Roll Over should display 1999:12:31::23:59:59 and should &
                      roll over to 2000:01:01::00:00:00 upon incrementing."
    
    timex now currTime sod=sod
    
    pipe on
      panel/msgid=MAIN/controls=gc/setup
      gcontrol label  MACRO "MACRO"
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.MAIN.itemColors {PASS=GREEN,FAIL=RED}

      gcontrol text idtext "INSTRUCTIONS" "^instructions" 24 20 /title

      gcontrol TVAL defTime "Default" ! Since 3.5.1, defaults work out-of-the-box

      gcontrol TVAL nowTime1 "Time 1" sod /fmt="HH:MM:SS.SSSS"
      gcontrol TVAL nowTime2 "Time 2" sod 1 86400 10

      gcontrol TVAL nowTime3 "Date & Time 1" currTime 1 -1 1:00
      gcontrol TVAL nowTime4 "Date & Time 2" currTime min=1 max=-1 inc=1:00:00

      gcontrol TVAL nowTime5 "SDF  of Time2" currTime /fmt="SDF:MMM dd H:m:s.SSSS" ! format will auto-correct
      gcontrol TVAL nowTime6 "SDF  of Time2" currTime /fmt="SDF:DDD::HH:mm:ss.SSSSS"
      gcontrol TVAL nowTime7 "SDF  of Time2" currTime /fmt="SDF:EE MM dd yyyy HH:mm:ss.SSSS EEEE"
      gcontrol TVAL rollOver "Roll Over" 1999:12:31::23:59:59
    pipe off
  endif
endmacro

procedure processMessage m:msg
  if msg.name eqs "MAIN"
    if failedTests EQ 0 then
      assert/text="^reg.main.name: user indicated" msg.data eqs "PASS"
    else
      assert/text="^reg.main.name: detected ^failedTests failures" "FAIL"
    endif
    pipe stop
  elseif msg.name eqs "MULTI" or msg.name eqs "SINGLE" then
    say "MSG: name=^msg.name data=^msg.data"
  else
    ! do nothing
    !say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

procedure failedATest s:msg
  assert/text="^reg.main.name: ^msg" FALSE
  calc L:failedTests failedTests 1 +
return