Next: , Up: Input and Output Formats   [Contents][Index]

2.2.1 Constructing and Verifying Formats

These functions construct struct fmt_specs and verify that they are valid.

Function: struct fmt_spec fmt_for_input (enum fmt_type type, int w, int d)
Function: struct fmt_spec fmt_for_output (enum fmt_type type, int w, int d)

Constructs a struct fmt_spec with the given type, w, and d, asserts that the result is a valid input (or output) format, and returns it.

Function: struct fmt_spec fmt_for_output_from_input (const struct fmt_spec *input)

Given input, which must be a valid input format, returns the equivalent output format. See Input and Output Formats in PSPP Users Guide, for the rules for converting input formats into output formats.

Function: struct fmt_spec fmt_default_for_width (int width)

Returns the default output format for a variable of the given width. For a numeric variable, this is F8.2 format; for a string variable, it is the A format of the given width.

The following functions check whether a struct fmt_spec is valid for various uses and return true if so, false otherwise. When any of them returns false, it also outputs an explanatory error message using msg. To suppress error output, enclose a call to one of these functions by a msg_disable/msg_enable pair.

Function: bool fmt_check (const struct fmt_spec *format, bool for_input)
Function: bool fmt_check_input (const struct fmt_spec *format)
Function: bool fmt_check_output (const struct fmt_spec *format)

Checks whether format is a valid input format (for fmt_check_input, or fmt_check if for_input) or output format (for fmt_check_output, or fmt_check if not for_input).

Function: bool fmt_check_type_compat (const struct fmt_spec *format, enum val_type type)

Checks whether format matches the value type type, that is, if type is VAL_NUMERIC and format is a numeric format or type is VAL_STRING and format is a string format.

Function: bool fmt_check_width_compat (const struct fmt_spec *format, int width)

Checks whether format may be used as an output format for a value of the given width.

fmt_var_width, described in the following section, can be also be used to determine the value width needed by a format.

Next: , Up: Input and Output Formats   [Contents][Index]