! Test adding a row to a LIST that is shown (visible) and that is on a hidden tab (not visible)
!
! @bug     2230 LIST: Data added to a list that has not initially drawn yet will get added to the top
! @author  Neon Ngo
! @since   NeXtMidas 2.9.0
!
startmacro

  call setDatDir

  set file    "^{datDir}.testxy3000.prm"  ! The file to initially list
  set tab     {absc=1,ord=2,ord2=3,ord3=4}  ! The row of data to add
  set counter 100                           ! starting counter value for addRow()
  set delay   0.5                           ! delay between adding rows (sec)

  pipe on
    panel/msgid=MAIN/setup/controls=gc

    list/id=shownlist/drawhidden  ^file
    list/id=hiddenlist/drawhidden ^file

    gcontrol label macro "MACRO"
    gcontrol menu    main "Exit with Status = " "PASS,FAIL" /tleft
    set gc.main.itemColors {PASS=GREEN,FAIL=RED}

    set instructions "A row of data is added every ^delay seconds. Show the 'Initially Hidden List' &
                      and verify that it displays the initial file contents of ^file (absc values: 1.0, 3.0, 4.0, 3.0, 1.0, 2.0) first before &
                      any of the rows added (where the ASBC values start counting by 1 starting from 100.
    gcontrol text    idtext "Instructions" "^instructions" 24 12 /title

    res this.timer(0) delay
  pipe off
endmacro

!******************************************************************************!
procedure processMessage m:msg
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: Interactive tests" msg.data eqss "PASS"
    pipe stop
  elseif msg.name eqs "TIMER" then
    res tab.absc counter
    invoke junk reg.shownlist.addRow(tab)
    invoke junk reg.hiddenlist.addRow(tab)
    calc counter counter 1 +
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid dats: ^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
