!**************************************************************************************************!
! author : JPH, JWB
!
! purpose: test LVAL GCONTROLS and BUG 1934 (slider messaging)
!**************************************************************************************************!
startmacro

set L:failedTests 0
switch INTERACTIVE interAct GET DEF=TRUE
if interAct then

  res instructions "Use the sliders to change the value of the LVAL below. \n\n&
                    The TOP slider will send many messages, while the BOTTOM &
                    slider will not send a messages until AFTER the slider stops moving.\n\n&
                    Both sliders should show a percent of the max value (200 is max)."

  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 12 /title

  gcontrol label  listTest   "Options" AlwaysOpen
  gcontrol LVAL multi "Multi Slider Msgs" DEF=1 MIN=0 MAX=200 INC=1 /slider  /fmt="## MHz" /edit /percent
  gcontrol LVAL single "Single Slider Msg" DEF=1 MIN=0 MAX=200 INC=1 /slider /msgondrag=f /fmt="## MHz" /percent
  
  shellgui/id=term/attach

  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

