+/* A variable. */
+struct variable
+ {
+ /* Dictionary information. */
+ char name[VAR_NAME_LEN + 1]; /* Variable name. Mixed case. */
+ int width; /* 0 for numeric, otherwise string width. */
+ struct missing_values miss; /* Missing values. */
+ struct fmt_spec print; /* Default format for PRINT. */
+ struct fmt_spec write; /* Default format for WRITE. */
+ struct val_labs *val_labs; /* Value labels. */
+ char *label; /* Variable label. */
+
+ /* GUI information. */
+ enum measure measure; /* Nominal, ordinal, or continuous. */
+ int display_width; /* Width of data editor column. */
+ enum alignment alignment; /* Alignment of data in GUI. */
+
+ /* Case information. */
+ bool leave; /* Leave value from case to case? */
+
+ /* Data for use by containing dictionary. */
+ struct vardict_info *vardict;
+
+ /* Used only for system and portable file input and output.
+ See short-names.h. */
+ char **short_names;
+ size_t short_name_cnt;
+
+ /* Each command may use these fields as needed. */
+ void *aux;
+ void (*aux_dtor) (struct variable *);
+
+ /* Custom attributes. */
+ struct attrset attributes;
+ };
+\f
+/* Creates and returns a new variable with the given NAME and
+ WIDTH and other fields initialized to default values. The
+ variable is not added to a dictionary; for that, use
+ dict_create_var instead. */
+struct variable *
+var_create (const char *name, int width)
+{
+ struct variable *v;
+ enum val_type type;
+
+ assert (width >= 0 && width <= MAX_STRING);
+
+ v = xmalloc (sizeof *v);
+ v->vardict = NULL;
+ var_set_name (v, name);
+ v->width = width;
+ mv_init (&v->miss, width);
+ v->leave = var_must_leave (v);
+ type = val_type_from_width (width);
+ v->alignment = var_default_alignment (type);
+ v->measure = var_default_measure (type);
+ v->display_width = var_default_display_width (width);
+ v->print = v->write = var_default_formats (width);
+ v->val_labs = NULL;
+ v->label = NULL;
+ v->short_names = NULL;
+ v->short_name_cnt = 0;
+ v->aux = NULL;
+ v->aux_dtor = NULL;
+ attrset_init (&v->attributes);