startmacro/setup u:host n:number
  switch DEBUG   debug        GET DEF=false SDEF=true
  switch VERBOSE verbose      GET DEF=false SDEF=true
  switch STATEM  statemachine GET DEF=false SDEF=true

  pipe init
    panel/setup/controls=gc

    set myTab  {}
    set myTab.format "SF"

    waveform/rt out=_wave FORM=^{myTab.format} ELEM=10e10 SHAPE=SIN AMP=1 FREQ=13.37 PHASE=0 START=0 DELTA=1/32K
    plot/id=3/nice _wave

    if /NRP GT 0 then
      rmif/keymsg/msgid=main/id=rmi/STATEM=^statemachine/VERBOSE=^verbose 9000 ,, {ID=XM,HP="localhost:9001"}
    else
      rmif/keymsg/msgid=main/id=rmi/STATEM=^statemachine/VERBOSE=^verbose 9000 _wave {ID=XM,HP="localhost:9001"}
    endif

    gc label macro "RMIF_TEST"
    gc button butt1 " " "send_A"
    gc button exitb " " "EXIT"
  pipe off
endmacro

!******************************************************************************!
procedure processMessage m:msg
  if debug then
    say "^reg.main.name: Got message name=^msg.name fid=^msg.fid info=^msg.info data=^msg.data"
  endif

  if msg.name EQS "BUTT1" then
    if msg.data EQS "SEND_A" then
      set myData "A"    
    elseif msg.data EQS "SEND_B" then
      set myData "B"    
    else
      set myData "C"
    endif
    
    message send "XM",, "SET" 1 "RLNVAL1=^mydata"
  
  elseif msg.name EQS "EXITB" then
    pipe stop
  
  elseif msg.name EQS "SET" then
   ! Do nothing
   assert/text="^reg.main.name: rcvd SET " msg.data.wtf EQS "ONE"

  else
    ! At clean up process ALL messages
    ! warning "^reg.main.name: unrecognized message ^msg.name"
  endif
return
