!******************************************************************************!
! purpose: test list2 exit methods
!
! author : JWB
!******************************************************************************!
startmacro s:type["ALL"]
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)

  call setDatDir

  set L:failedTests 0
if interAct then
  res exit_ret    "FALSE"
  res exit_msg    "FALSE"
  res exit_win    "FALSE"
  res exit_menu   "FALSE"

  if type eqs "ALL" then
    set exit_ret  "<== TRUE"
    set exit_msg  "<== TRUE"
    set exit_msg  "<== TRUE"
    set exit_menu "<== TRUE"
  elseif type eqs "RET" then
    set exit_ret  "<== TRUE"
  elseif type eqs "MSG" then
    set type "MESSAGE"
    set exit_msg  "<== TRUE"
  elseif type eqs "WIN" then
    set exit_win  "<== TRUE"
  elseif type eqs "MENU" then
    set exit_menu "<== TRUE"
  endif

  set instructions {}
  set instructions.INSTR "EXIT parameters for the List: You should only be able &
                           to EXIT the List2 if the method below is TRUE."
  set instructions.EXIT_RETURN " Will pressing RETURN (when focused) exit? ^exit_ret"
  set instructions.EXIT_MENU "   Will a Middle Mouse Button MENU exit? ^exit_menu"
  set instructions.EXIT_MESSAGE "Will sending a MESSAGE (use button below) exit? ^exit_msg"
  set instructions.EXIT_WINDOW " Will pressing the WINDOW ('X') exit? ^exit_win"

  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 label  instLabel  "Instructions"
  gcontrol panel  instDispl  "Instructions" 200 115

  textdisplay/id=instDispl TEXT=instructions
  gcontrol button exitbutton "" "SEND EXIT MESSAGE"

  list2/id=idlist/exit=^type/wpos=(580,25,440,400) ^{datDir}.cities.prm

  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 "EXITBUTTON" then
    message FUNC=SEND ID=idlist NAME=EXIT
  else
    ! do nothing
    !say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

!******************************************************************************!
! Set the dat directory
!******************************************************************************!
procedure setDatDir
  invoke nxmMajor env.nmversion.subString(0,1)
  invoke major java.lang.Integer.valueOf(nxmMajor)
  if major GE 4 then
    invoke s:datDir           nxm.sys.test.DatLocator.getDatDirLocation()
    invoke s:datDirSlash      nxm.sys.test.DatLocator.getDatDirSlashLocation()
    invoke z:sysDatFull       nxm.sys.test.DatLocator.sysDatFull()
    invoke z:sysTestDatExists nxm.sys.test.DatLocator.sysTestDatExists()
  else
    set s:datDir           "nxm.sys.dat"
    set s:datDirSlash      "nxm/sys/dat"
    set z:sysDatFull       true
    set z:sysTestDatExists false
  endif
return

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