+ else
+ ds_put_cstr (str, name);
+}
+\f
+/* Print and write formats. */
+
+/* Returns V's print format specification. */
+const struct fmt_spec *
+var_get_print_format (const struct variable *v)
+{
+ return &v->print;
+}
+
+/* Sets V's print format specification to PRINT, which must be a
+ valid format specification for a variable of V's width
+ (ordinarily an output format, but input formats are not
+ rejected). */
+void
+var_set_print_format (struct variable *v, const struct fmt_spec *print)
+{
+ assert (fmt_check_width_compat (print, v->width));
+ v->print = *print;
+ dict_var_changed (v);
+}
+
+/* Returns V's write format specification. */
+const struct fmt_spec *
+var_get_write_format (const struct variable *v)
+{
+ return &v->write;
+}
+
+/* Sets V's write format specification to WRITE, which must be a
+ valid format specification for a variable of V's width
+ (ordinarily an output format, but input formats are not
+ rejected). */
+void
+var_set_write_format (struct variable *v, const struct fmt_spec *write)
+{
+ assert (fmt_check_width_compat (write, v->width));
+ v->write = *write;
+ dict_var_changed (v);
+}
+
+/* Sets V's print and write format specifications to FORMAT,
+ which must be a valid format specification for a variable of
+ V's width (ordinarily an output format, but input formats are
+ not rejected). */
+void
+var_set_both_formats (struct variable *v, const struct fmt_spec *format)
+{
+ var_set_print_format (v, format);
+ var_set_write_format (v, format);
+}
+
+/* Returns the default print and write format for a variable of
+ the given TYPE, as set by var_create. The return value can be
+ used to reset a variable's print and write formats to the
+ default. */
+struct fmt_spec
+var_default_formats (int width)
+{
+ return (width == 0
+ ? fmt_for_output (FMT_F, 8, 2)
+ : fmt_for_output (FMT_A, width, 0));
+}
+\f
+/* Return a string representing this variable, in the form most
+ appropriate from a human factors perspective, that is, its
+ variable label if it has one, otherwise its name. */
+const char *
+var_to_string (const struct variable *v)
+{
+ return v->label != NULL ? v->label : v->name;