!******************************************************************************!
! Tests for DATALIST command.
!
!   Author : J. Czechowski IV
!******************************************************************************!
startmacro/tsetup=nxm.sys.test.test_datalist_setup.tbl
  switch INTERACTIVE  interAct     GET DEF=TRUE SDEF=TRUE  ! for normal interactive test(s)
  switch STANDALONE   standalone   GET DEF=TRUE SDEF=TRUE
  switch COREGRAPHICS coregraphics GET DEF=FALSE SDEF=TRUE  ! for a quick check of graphics - more extreme tests - since 3.8.1

  call setDatDir

  if interAct OR coreGraphics then
    pipe on
      panel/msgid=MAIN/setup/controls=gc

      if standalone isTrue then
        gcontrol label macro "MACRO"
        gcontrol menu MAIN "Exit with Status = " "PASS,FAIL" /tleft
        set gc.MAIN.itemColors {PASS=GREEN,FAIL=RED}
      endif

      gcontrol text idtext "INSTRUCTIONS" "Verify the output from DATALIST." 24 7 /title

      shellgui/id=idshellgui/attach
      say "EXPECTED OUTPUT:"
      say "  0: ABSC=1.0  ORD=1.0  ORD2=12.0  ORD3=14.0"
      say "  1: ABSC=3.0  ORD=2.0  ORD2=7.0  ORD3=12.0"
      say "  2: ABSC=4.0  ORD=4.0  ORD2=9.0  ORD3=8.0"
      say "  3: ABSC=3.0  ORD=15.0  ORD2=4.0  ORD3=3.0"
      say "  4: ABSC=1.0  ORD=16.0  ORD2=7.0  ORD3=9.0"
      say "  5: ABSC=2.0  ORD=6.0  ORD2=3.0  ORD3=10.0"
      say ""
      say ""
      say "ACTUAL OUTPUT:"
      DATALIST/bg ^{datDir}.testxy3000.prm

    pipe off
  endif

endmacro

!******************************************************************************!
procedure processMessage m:msg
  if msg.name EQS "MAIN" then
    if msg.data EQS "EXIT" then
      pipe stop
    else
      assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
      pipe stop
    endif
  else
    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
