+
+
+/* Get a string representing the value.
+ That is, if it has a label, then return that label,
+ otherwise, if the value is alpha, then return the string for it,
+ else format it and return the formatted string
+*/
+const char *
+value_to_string (const union value *val, const struct variable *var)
+{
+ char *s;
+
+ assert (val != NULL);
+ assert (var != NULL);
+
+ s = val_labs_find (var->val_labs, *val);
+ if (s == NULL)
+ {
+ static char buf[256];
+ if (var->width != 0)
+ str_copy_buf_trunc (buf, sizeof buf, val->s, var->width);
+ else
+ snprintf(buf, 100, "%g", val->f);
+ s = buf;
+ }
+
+ return s;
+}