Try this:
/*
Written by: Edwin W. Piburn
General Dynamics, Inc.
Niceville, FL
December 2001
This code is in the public domain.
*/
/***
MODULE GetNames
CATEGORY OTI
DESCRIPTION Get component names
INPUT InField; field or field series; (no default); Data field
OUTPUT NameList; string list; List of component names
FLAGS:
BUGS:
AUTHOR:
E. W. Piburn
OWNERSHIP:
This code is in the public domain.
END:
***/
#include <strings.h>
#include "dx/dx.h"
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
Error
m_GetNames (Object *in, Object *out)
{
/*
* in[0] DX field
* out[0] DX String List containing componet names
*
* This procedure creates a string list with the names
* of the components of the input field.
*/
Array s_list;
Object subo;
char *name;
int i;
s_list = DXNewArray (TYPE_STRING, CATEGORY_REAL, 1, 33);
i = 0;
do
{
subo = DXGetEnumeratedComponentValue ((Field)in[0], i, &name);
if (subo != NULL)
{
/* DXMessage ("++++++++ i = %d name is %s.", i, name); */
if (!DXAddArrayData (s_list, i, 1, (Pointer)name))
{
DXSetError (ERROR_MISSING_DATA, "Error adding string data to
array.");
goto error;
}
i++;
}
} while (subo);
/* DXPrintV ((Object)s_list, "rD", NULL); */
out[0] = (Object) s_list;
/*
* successful completion
*/
return OK;
/*
* unsuccessful completion
*/
error:
return ERROR;
}
Patrick Joeckel wrote:
>
> Dear openDX experts,
>
> I would like to write a module which scans a netCDF file and returns
> the names of the netCDF variables as a string list. I started with
> the dx -builder, however "string" or "string lists" is not an option for the
> output of a module. Why is that, and is there a way around?
>
> Any helpful comments are appreciated ...
>
> Yours,
>
> Patrick Joeckel
>
> --
> ---------------------------------------------------------------
> Dr. Patrick Joeckel
> Max Planck Institute for Chemistry
> Joh.-J. Becher Weg 27
> 55128 Mainz phone:++49-6131-305452
> Germany fax :++49-6131-305436
> e-mail:[EMAIL PROTECTED]
> http://www.mpch-mainz.mpg.de/~joeckel
> ---------------------------------------------------------------
> Never trust an operating system you don't have sources for.