! Test the plotting of files for ALL layers (those layers that require the MAP
! option tree are tested with nxm/map/test/test_plot.mm).
!
! Author:  J. Hallam / J. Bauer
! Version: $Id: test_plot_bug2151.mm,v 1.1 2010/04/16 18:02:59 jwb Exp $
!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE
  
  env set usenative "NONE"
  
  res s:currFile "NONE"
  
  aux ram ram|home|dat
  
  if interAct then
    pipe on
      wave file1 form=sf elem=1m shape=white 
      wave file2 form=sf elem=1m shape=sin
      panel/msgid=MAIN/setup/controls=gc
      plot/id=idplot/READOUT="+OnAxis|+DateString"
      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" "Should see the plot change files every two seconds" 24 7 /title
      
      gcontrol button myButt "" "SWAP FILE" none
      
      gcontrol button auto "" "SWAP EVERY 2 SEC"
      
      message send id=main name="START"
    pipe off
  endif
  
  env set usenative "ALL"
  
endmacro

!************************************************************
procedure processMessage m:msg
  
  if msg.name eqs "MAIN" then
    assert/text="Plot Bug 2151 files tests" msg.data eqss "PASS"
    pipe stop
  elseif msg.name eqs "MYBUTT" then
    call processFiles 1
  elseif msg.name eqs "AUTO" then
    call processFiles 20
  elseif msg.name eqs "START" then
    call processFiles msg.info
  endif

return

!************************************************************
procedure processFiles l:number[1]

  if currFile eqs "NONE" then
    set currFile "file1"
  elseif currFile eqss "file1"
    set currFile "file2"
  elseif currFile eqss "file2"
    set currFile "file1"
  endif
  
  info "Opening ^currFile"
  message send id=idplot name="OPENFILE" info=-1 data="^currFile"
  
  calc number number 1 -
  if number gt 0.0 then 
    pause 2.0
    message send id=main name="START" info=^number 
  endif
  !pause 2.0
  !message send id=main name="START"
  
return