Seppo Mustonen : Programming Survo in C

Functions in library SURVO.LIB


char *name;      /* name of data file */
int len;         /* record length */
int m1;          /* max # of fields */
int m;           /* # of fields */
long n;          /* # of observations */
int f;           /* max field name length */
int extra;       /* field attribute length */
int textn;       /* # of comment lines */
int textlen;     /* length of comment line */
char *text[];    /* pointers to comment lines */
char *varname[]; /* names of fields */
int varlen[];    /* field lengths */
char *vartype[]; /* field attributes */

The fi_create function creates a new SURVO 84C data file with a pathname name. If the path is not given, the current data pathname given by the global variable edisk is used. The default extension is .SVO. If n>0, n missing observations will be saved.

The data file has the following structure:

 Header fields:  64 bytes (46 bytes in use)     bytes      offset
 "SURVO 84C DATA  "               char          16           0
 record length (len)              int            2          16
 max # of fields (m1)             int            2          18
 # of fields (m)                  int            2          20
 # of observations (n)            long           4          22
 max length of field name (f)     int            2          26
 length of field attr. (extra)    int            2          28
 # of comment lines (textn)       int            2          30
 length of comment line (textlen) int            2          32
 start of comments (text)         long           4          34
 start of field descr. (var)      long           4          38
 start of data (data)             long           4          42
Comments: text=64
Length of comments textn*textlen bytes
Field descriptions: var=text+textn*textlen
Following information repeated m1 times (f+extra bytes for each field):
   position in record (varpos)   int            2           0
   length of field (varlen)      int            2           2
   type (1,2,4,8,S) (vartype)    char           1           4
   activation                    char           1           5
   protection                    char           1           6
   other mask bytes              char     extra-7           7
   name (varname)                char           f       extra
Data: data=var+m1*(f+extra)=64+textn*textlen+m1*(f+extra)
Observation j starts from data+(j-1)*len
Return Value

fi_create returns 1 if the file is succesfully created and -1 otherwise. If a data file with the same name already exists, fi_create asks for permission to overwrite.


In practice, SURVO 84C data files are created automatically by various FILE operations. They use fi_create as a subroutine. A direct fi_create call is seldom needed.

Front page of Survo C libraries