!------------------------------------------------------------------------------!
! Tests for LIST command on a filename (without extension) with trimmers
! NOTE: This is can be a non-interactive test but requires graphics.
! Requires: DAT in read AUX list for test1000
!
! Bug    : 1987 LIST exception when using file trimmer syntax
! Author : Neon Ngo
!
!------------------------------------------------------------------------------!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE SDEF=TRUE

  call setDatDir

  pipe on
    if interAct then
      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" "The list displays one item because &
               of file trimmer (0:1)" 24 5 /title
    endif

    ! test case for Bug 1987 filename w/o extension and with file trimmer
    list/id=idlist ^{datDir}.test1000(0:1)
    assert/text="^reg.main.name LIST filename w/o ext and trimmers " reg.idlist rextists

    if interAct isFalse then
      ! this test can be run non-interactively (so just stop macro)
      stop
    endif

  pipe off

endmacro

!------------------------------------------------------------------------------!
procedure processMessage m:msg
  if msg.name EQS "MAIN" then
    assert/text="^reg.main.name Interactive test" "PASS" SUBS msg.data
    pipe stop

  else
    say "^reg.main.name: Unhandled messagename: ^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
