!******************************************************************************!
!
! Tests the GCONTROL /GC switch. This switch allows the default values for widgets
! to be obtained from the given table
!
! Note: This test will run automatically to test that the control values are the ones specified
!       in the table 'gcDefTab'
!
! @author  jph
!
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE  ! for defects or more obscure test case(s)

  ! These are used with the /GC switch.  Each key must match a control ID
  set gcDefTab {MAIN=PASS,&
                  MENUWITHGC=ITEM1,&
                  CHOICEWITHGC=CHOICE2,&
                  CHOICEWITHOUTGC=CHOICE3,&
                  BUTTON=""}
                  
  set instructions "You should see a default value selected as follows: \n\n  &
                    MAIN (EXIT)=  PASS \n  &
                    MENU=         ITEM1 \n  &
                    CHOICE w/ GC=  CHOICE2 \n  &
                    CHOICE no GC= CHOICE3 \n  &
                    BUTTON=       none \n\n&
                    Click PASS if the defaults are set correctly."

  pipe on

    panel/msgid=MAIN/setup/controls=gc

    gcontrol       MENU   main            "Exit with Status = " "PASS,FAIL"                /tleft /gc=gcDefTab
    gcontrol text idtext "Instructions" "^instructions" 24 11 /title
    gcontrol/msg=f MENU   menuWithGC      "MENU with /GC      " "ITEM1,ITEM2"              /tleft /gc=gcDefTab
    gcontrol/msg=f CHOICE choiceWithGC    "CHOICE with /GC    " "ITEM1,ITEM2"              /tleft /gc=gcDefTab
    gcontrol/msg=f CHOICE choiceWithoutGC "CHOICE with NO /GC " "CHOICE1,CHOICE2,CHOICE3"  /tleft /gc=gcDefTab
    gcontrol/msg=f BUTTON button          ""                    "BUTTON" /tleft /gc=gcDefTab 

    message FUNC=send ID=MAIN NAME=START
  pipe off

endmacro

!**********************************************************************************************************************!
procedure processMessage m:msg

if msg.name eqs "START"
  foreach key IN gc
!res gc.^{key}.value
!res gcDefTab.^{key}
    if ^{key} eqs "IDTEXT" then
      ! do nothing for text box
    else
      assert/text="^reg.main.name: ^key default" gc.^{key}.value EQS "^gcDefTab.^{key}"
    endif
  endfor

  if interAct ISFALSE then pipe stop

elseif msg.name eqs "MAIN" then
  assert/text="^reg.main.name: user indicated" msg.data eqs "PASS"
  pipe stop

else
  warning "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
endif

return

