! Tests the FOREACH command on TABLE inside interactive NeXtMidas shell.
!
! @bug     1801 FOREACH key intable tab error
! @author  Neon Ngo
! @version $Id: test_foreach_intable.mm,v 1.1 2009/05/01 22:37:36 ntn Exp $
! @since   NeXtMidas 2.7.1
!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  if interAct then
    pipe on
      panel/msgid=MAIN/setup/controls=gc
      gcontrol label  macro   "MACRO"
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}

      gcontrol label instructions "INSTRUCTIONS"
      gcontrol panel tdisp
      textdisplay/id=tdisp text=""

      ! NTN: It would be nice to use SHELLGUI to make this test case more seemless,
      !      but there are a number of issues: have to use shellgui/attach
      !      then in is in a nM-Pipe>, and so on
      !
      message send tdisp,,"APPENDL",,"Start an interactive NeXtMidas shell from the console."
      message send tdisp,,"APPENDL",,"Then run (type) the following:"
      message send tdisp,,"APPENDL",," "
      message send tdisp,,"APPENDL",," foreach x intab opt"
      message send tdisp,,"APPENDL",,"   say x"
      message send tdisp,,"APPENDL",," endfor"
      message send tdisp,,"APPENDL",," "
      message send tdisp,,"APPENDL",,"Should get list of keys in the OPT table."
      message send tdisp,,"APPENDL",,"Should NOT get any ERRORs."

    pipe off
  endif
endmacro

procedure processMessage m:msg
  !say "msg.name ^msg.name, data ^msg.data"

  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: Tests for FOREACH" msg.data eqss "PASS"
    pipe stop
  else
    say "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return
