!------------------------------------------------------------------------------!
! Test for XMidas/NeXtMidas compatible file size issue. Problem is that X-Midas
! has more stringent requirements for file formatting. NeXtMidas will read the
! file generated by this test but X-Midas will not.
! X-Midas generates the following error:
!
!     X-Midas> xdatalist /home/jsr/testfile_jsr_4104.tmp
!     m$bfread read 3 - incorrect number of bytes read
!      ERROR: Reading file /home/jsr/testfile_jsr_4104.tmp
!
! Start X-Midas.
! Run this macro.
! Switch to X-Midas shell and xdatalist the 'testfile'.
! When this macro has finished, xdatalist the 'testfile' again and you will get
! the above error.
!
!   Author : J. Helton
!   Version: $Id: test_bad_xm_file.mm,v 1.1 2008/05/12 13:50:40 jsr Exp $
!------------------------------------------------------------------------------!
startmacro/msgid=main/quiet

  env get pid mpid
  env get user muser

  fname testfile HOME testfile_^{muser}_^{mpid} tmp AUX
  say " "
  say "testfile= ^testfile"

  if ^testfile nfexists then
    file open/d/n ctag ^testfile{sr=(SDP/2a,CHAN/1A,MSN/1A,RCVR/1A,TASK/2A,MCTR/SI)}
    file close ctag
  endif

  table tab1 create {sdp="xxxyyy",chan="745",msn="123401",rcvr="1",task="task12",mctr="0"}

  status ^testfile sz=numRows

!  list2 ^testfile

  file open/d/w cttag ^testfile
    invoke ,, cttag.setData(^numRows,^tab1)
    invoke ,, cttag.setData(1,^tab1)
  file close cttag

!  say " Done writing"
  say " "
  say " File Before Data Removal"
  say " "
  status ^testfile
!  list2 ^testfile

  pause/quiet 3.0

  file open/d/w cttag ^testfile
    invoke ,, cttag.removeData(1.0)
  file close cttag
  say " "
  say " File After Data Removal"
  say " "
  status ^testfile
!  list2 ^testfile

!  erase testfile
 
endmacro
