Next: , Previous: , Up: Variables   [Contents][Index]


2.5.5 Variable Print and Write Formats

Each variable has an associated pair of output formats, called its print format and write format. See Input and Output Formats in PSPP Users Guide, for an introduction to formats. See Input and Output Formats, for a developer’s description of format representation.

The print format is used to convert a variable’s data values to strings for human-readable output. The write format is used similarly for machine-readable output, primarily by the WRITE transformation (see WRITE in PSPP Users Guide). Most often a variable’s print and write formats are the same.

A newly created variable by default has format F8.2 if it is numeric or an A format with the same width as the variable if it is string. Many creators of variables override these defaults.

Both the print format and write format are output formats. Input formats are not part of struct variable. Instead, input programs and transformations keep track of variable input formats themselves.

The following functions work with variable print and write formats.

Function: const struct fmt_spec * var_get_print_format (const struct variable *var)
Function: const struct fmt_spec * var_get_write_format (const struct variable *var)

Returns var’s print or write format, respectively.

Function: void var_set_print_format (struct variable *var, const struct fmt_spec *format)
Function: void var_set_write_format (struct variable *var, const struct fmt_spec *format)
Function: void var_set_both_formats (struct variable *var, const struct fmt_spec *format)

Sets var’s print format, write format, or both formats, respectively, to a copy of format.


Next: Variable Labels, Previous: Variable Value Labels, Up: Variables   [Contents][Index]