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

2.5.6 Variable Labels

A variable label is a string that describes a variable. Variable labels may contain spaces and punctuation not allowed in variable names. See VARIABLE LABELS in PSPP Users Guide, for a user-level description of variable labels.

The most commonly useful functions for variable labels are those to retrieve a variable’s label:

Function: const char * var_to_string (const struct variable *var)

Returns var’s variable label, if it has one, otherwise var’s name. In either case the caller must not attempt to modify or free the returned string.

This function is useful for user output.

Function: const char * var_get_label (const struct variable *var)

Returns var’s variable label, if it has one, or a null pointer otherwise.

A few other variable label functions are also provided:

Function: void var_set_label (struct variable *var, const char *label)

Sets var’s variable label to a copy of label, or removes any label from var if label is a null pointer or contains only spaces. Leading and trailing spaces are removed from the variable label and its remaining content is truncated at 255 bytes.

Function: void var_clear_label (struct variable *var)

Removes any variable label from var.

Function: bool var_has_label (const struct variable *var)

Returns true if var has a variable label, false otherwise.