!******************************************************************************!
! Test case for LayerMulti showing elements in data file beyond default
! transfer length (was 512 prior to NXM 2.5.4, where it is set to 1024)
! Additionally, this also tests NXM-1262 when a data file with one column is
! plotted without having it's color or the colormap specified. Before NXM 2.5.5
! MColor had be assigning it's color to black, which match the background color
! and hence it was not visible.
!
! Arguments: None
!
! Note: The default number of elements to test against was increased to 2000 to
! show that Y1 and Y2 are calcuated based on the first transfer length of data
! (hence their correct range had to be specified.) We should come up with a better
! way of how the ranges are calcuated when data is plotted in this paged-mode.)
!
! Issue    NXM-1155 LayerMulti: Only shows first 512 elements of the file
!          NXM-1262 MColor: interpColors() uses background color for
!                   colors index 1, when ncolors is 1
! Since    NeXtMidas 2.5.3
! Author:  Neon Ngo
! 
!******************************************************************************!
startmacro D:numElements[2000]

  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  if interAct then
    set testfile "ram:temp_testplot_layermulti"
    ! create testfile with one y-trace (column)
    res amp numElements/2
    waveform OUT=^{testfile}{SR=(DATA/SF)} FORM=SF ELEM=^numElements &
             SHAPE=SIN AMP=amp FREQ=1/numElements PHASE=3/4

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

      set myInstructions "Should see a sine wave with amplitude of ^amp plotted &
                      from 0 to ^numElements on X-axis."

      gcontrol text idtext "Instructions" "^myInstructions" 24 7 /title

      ! 2008-02-29 NTN: there is current issue where Y1 & Y2 are only calculated by
      !                 first transfer length of data (hence we have to set it for this test)
      ! NXM-1262: not specifing color or color map as file qualifer to test that it is still visible
      plot ^testfile{LAYER={LT="Multi",COLUMNS="DATA"}} Y1=-amp Y2=amp /READOUT="-DateString"

    pipe off

  endif  ! interAct

endmacro

!**************************************************************************************************!
procedure processMessage
  if msg.name eqs "MAIN" then
    assert/text="Plot LayerMulti file with > 512 elements." msg.data eqss "PASS";
    pipe stop
  elseif msg.name eqs "STATE"
    pipe ^msg.data

  else
    warning "^reg.main.name: unrecognized message ^msg.name from ^msg.fid"
  endif
return
