startmacro
!
! Test the plotting of files with the /ALL switch.
!
! Author:  Jeanette McCall
!
  set instructions "Select the various buttons to test the various OPENFILE message qualifiers\n\n&
                    ALL         quals={/ALL}\n&
                    ALL=TRUE    quals={/ALL=TRUE}\n&
                    ALL=FALSE   quals={/ALL=FALSE}\n&
                    NONE        quals={}"

  res Z:boolTrue TRUE
  res Z:boolFale FALSE
  invoke ,, nxm.sys.prim.plot.setRestoreDefaultOptions(^boolTrue)

  ! Make a 1/2M (medium) file
  if test_plot_all_medium NFEXISTS then
    info "^reg.main.name: generating medium size (1/2M) file..."
    WAVEFORM,OUT=test_plot_all_medium,FORM=SF,ELEM=.5M,SHAPE=SAW,AMP=1,FREQ=1/128,PHASE=0,START=0,DELTA=1
    HEADERMOD test_plot_all_medium FS=128
  endif

  res numEls FILE(test_plot_all_medium).size
  res frameSize FILE(test_plot_all_medium).framesize
  calc numBytes numEls frameSize *

  info "^reg.main.name: medium file of ^numBytes bytes"

  ! Make a 4M (large) file
  if test_plot_all_large NFEXISTS then
    info "^reg.main.name: generating large size (4M) file..."
    mergefile/replay=8 test_plot_all_medium test_plot_all_large
    HEADERMOD test_plot_all_large FS=128
  endif
  res numEls FILE(test_plot_all_large).size
  res frameSize FILE(test_plot_all_large).framesize
  calc numMBytes numEls frameSize * 1M /

  !info "^reg.main.name: large file of ^numMBytes MBytes"

  pipe on
    panel/setup/controls=gc
    gcontrol menu   main   "Exit with Status = " "PASS,FAIL" /tleft
    gcontrol text   idtext "Instructions" "^{instructions}" 24 11 /title
    gcontrol button qualifier "Plot Qualifier" "ALL,ALL=TRUE,ALL=FALSE,NONE" ""

    set gc.main.itemColors {PASS=GREEN,FAIL=RED}

    plot/id=plot_all

  pipe off

  invoke ,, nxm.sys.prim.plot.setRestoreDefaultOptions(^boolFalse)

endmacro

procedure processMessage m:msg
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop
  elseif msg.name eqs "QUALIFIER" then
    if msg.data EQS ALL then
      res currQuals "{/ALL}"
      res titleExt  "{/ALL}"
    elseif msg.data EQS "ALL=TRUE" then
      res currQuals "{/ALL=true}"
      res titleExt  "{/ALL=true}"
    elseif msg.data EQS "ALL=FALSE" then
      res currQuals "{/ALL=false}"
      res titleExt "{/ALL=false}"
    else
      res currQuals "{}"
      res titleExt "{}"
    endif

    pause 0.5
    message,FUNC=send,ID=PLOT_ALL,NAME=OPENFILE,INFO=-1,DATA=test_plot_all_large quals=^currQuals
    set reg.panel.panes.plot_all.title "OPENFILE quals=^{titleExt}"

  else
    say "Unhandled message ^msg.name = ^msg.data from ^msg.fid"
  endif



return
