Seppo Mustonen : Programming Survo in C

Functions in library SURVO.LIB

data_load
Summary

int data_load(data,j,i,px)
SURVO_DATA *data; /* pointer to data structure */
long j;           /* # of observation (record) */
int i;            /* # of variable (field)  */
double *px;       /* pointer to data value  */
Description

The data_load function reads the value *px of the jth observation in variable # i (i=0,1,...,data->m-1) from data opened by data_open or data_open2.

Both numeric (N) and string (S) fields can be loaded by data_load. In the latter case the string value is converted to double by the standard function atof.

Return Value

data_load returns 1 if the value is found. Otherwise -1 is returned.

See Also

data_alpha_load

Example

int i;
long j;
double x;
SURVO_DATA dat;

i=data_open("TEST",&dat);
if (i<0) return;
sprintf(sbuf,"\nValues of variable %s:",dat.varname[3]);
sur_print(sbuf);
for (j=dat.l1; j<=dat.l2; ++j)
  {
  data_load(&dat,j,3,&x);
  sprintf(sbuf, "\nValue of var. # %d in obs. # %ld is %f", i+1,j,x);
  sur_print(sbuf);
  }
/* open TEST and print values of var. #4 */


Front page of Survo C libraries