startmacro

call setDatDir

pipe init
  panel/id=panel/setup/msgid=main
  !fname tmpfile area=test name=dr500984-3
  !fname templateFile area=test name=dr500984-3_template ext=prm

  list/id=idlist/win=pane1/msgid=main ^{datDir}.fftdemo

  gcontrol label macro "MACRO"
  gcontrol choice "ACTION"     "Action" "GET SELECTED ROW,CLOSE FILE,END" 0
  gcontrol text idtext "Instructions" "Select a row in the list, then select CLOSE FILE from Action menu..." 24 5 /title

  set reg.panel.MW.setTitle "DR500984-3 test"
  res l:currrow 0

pipe wait
pipe off

endmacro

!******************************************************************************!
procedure processMessage
  if msg.fid eqs "PANEL" or msg.fid eqs "MAIN"
    if msg.data eqs "GET SELECTED ROW"
      res x reg.idlist.gs.getselectedrowdata
      set reg.panel.controls.idtext.value "Selected row data: ^x"
    elseif msg.data eqs "CLOSE FILE"
      message send idlist,,"CLOSEFILE" ,, "*"
      set reg.panel.controls.idtext.value "File is now closed. Select GET SELECTED ROW &
      from Action menu. (This used to cause an array index out of bounds exception.)"
    elseif msg.data eqs "END"
      pipe stop
    endif
  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
