\subsection{NXdata}
NXdata is a module for writing Powder Diffraction Data files. The
routines here are somewhat obsolete as they refer to NeXus writing
using the  standard Napi routines which is quite involved. Usually,
NeXus files are written from SICS through the NXDICT aware utility
routines in NXUTIL.

If not stated
otherwise, all routines return 1 on successful completion and 0 when an
error is detected. Please note, that many of these routines expect to find
certain data items in the Sics Interpreter. This implies, that any naming
changes in the initialisation file might force changes in here as well. 

@d Protos @{
   char *SNXMakeFileName(SicsInterp *pSics, SConnection *pCon);
@}
SNXMakeFileName creates a new filename from the SICS variables SicsDataPath,
SicsDataPresript, SicsDataNumber and SicsDataEnding. SicsDataNumber will be
incremented as well. The function returns a newly allocate buffer with the
assembled filename or NULL on error. Note, that the caller is responsible
for freeing the memory associated with the filename afterwards.

@d Protos @{
   NXhandle SNXStartFile(SConnection *pCon, SicsInterp *pSics); 
@}
First calls SNXMakeFileName in order to get a new Filename. 
Then a new Nexus file is
created and all the standard  headings are filled in: Filename, User,
instrument, date etc. This routine also installs an error handler which
prints errors to pCon.
If successful, the SicsDataNumber is incremented and
an NXhandle into the new file is returned. If there is a problem, NULL
will be returned. The file returned will be positioned at root level.   

@d Protos @{
   int SNXStartEntry(NXhandle Nfil, int iNew, SicsInterp *pSics);
@}

@d Protos @{
   void SNXFormatTime(char *pBuffer, int iBufLen);
@}

SNXFormatTime formats the current system time in a form compatible to the 
NeXus standard. Input parameters is a Buffer to hold the string and a
length of the buffer. Maximum iBufLen characters will be copied to that
buffer.

SNXStartEntry  creates a new entry corresponding to iNew in the Nexus file
Nfil. SNXStartEntry  will position Nfil in this new entry. Any data items
labeled as Comment or intent will be written to the file as well.


@d Protos @{
  int SNFinishFile(NXhandle Nfil);
@}

SNFinishFile will end a Nexus file properly. 

@d Protos @{
  int SNMakeDMC(SConnection *pCon, SicsInterp *pSics);
@}

SNMakeDMC produces a Nexus DMC data file from the currently valid
information. It orchestrates all of the above.

@d Protos @{
int SNStoreDMC(SConnection *pCon, SicsInterp *pSics, void *pData, int argc,
           char *argv[]);
@}  
SNStoreData is the wrapper function used to install a DMC data storage
command in the Sics interpreter.


@o nxdata.h @{
/*-------------------------------------------------------------------------
                         N X D A T A

  Some  routines for handling Nexus data file writing.

  Mark Koennecke, April 1997
  
  copyright: see implementation file.
--------------------------------------------------------------------------*/
#ifndef SICSNXDATA
#define SICSNXDATA
@< Protos@>  
#endif 

@}
